Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / cc / output / shader.h
blob448ff07a8b28aa6958eefb2f1777ef425c28fb85
1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CC_OUTPUT_SHADER_H_
6 #define CC_OUTPUT_SHADER_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "cc/base/cc_export.h"
13 namespace gfx {
14 class Point;
15 class Size;
18 namespace gpu {
19 namespace gles2 {
20 class GLES2Interface;
24 namespace cc {
26 enum TexCoordPrecision {
27 TEX_COORD_PRECISION_NA = 0,
28 TEX_COORD_PRECISION_MEDIUM = 1,
29 TEX_COORD_PRECISION_HIGH = 2,
30 LAST_TEX_COORD_PRECISION = 2
33 enum SamplerType {
34 SAMPLER_TYPE_NA = 0,
35 SAMPLER_TYPE_2D = 1,
36 SAMPLER_TYPE_2D_RECT = 2,
37 SAMPLER_TYPE_EXTERNAL_OES = 3,
38 LAST_SAMPLER_TYPE = 3
41 enum BlendMode {
42 BLEND_MODE_NONE,
43 BLEND_MODE_NORMAL,
44 BLEND_MODE_SCREEN,
45 BLEND_MODE_OVERLAY,
46 BLEND_MODE_DARKEN,
47 BLEND_MODE_LIGHTEN,
48 BLEND_MODE_COLOR_DODGE,
49 BLEND_MODE_COLOR_BURN,
50 BLEND_MODE_HARD_LIGHT,
51 BLEND_MODE_SOFT_LIGHT,
52 BLEND_MODE_DIFFERENCE,
53 BLEND_MODE_EXCLUSION,
54 BLEND_MODE_MULTIPLY,
55 BLEND_MODE_HUE,
56 BLEND_MODE_SATURATION,
57 BLEND_MODE_COLOR,
58 BLEND_MODE_LUMINOSITY,
59 LAST_BLEND_MODE = BLEND_MODE_LUMINOSITY
62 enum MaskMode {
63 NO_MASK = 0,
64 HAS_MASK = 1,
65 LAST_MASK_VALUE = HAS_MASK
68 struct ShaderLocations {
69 ShaderLocations();
71 int sampler = -1;
72 int quad = -1;
73 int edge = -1;
74 int viewport = -1;
75 int mask_sampler = -1;
76 int mask_tex_coord_scale = -1;
77 int mask_tex_coord_offset = -1;
78 int matrix = -1;
79 int alpha = -1;
80 int color_matrix = -1;
81 int color_offset = -1;
82 int tex_transform = -1;
83 int backdrop = -1;
84 int backdrop_rect = -1;
85 int original_backdrop = -1;
88 // Note: The highp_threshold_cache must be provided by the caller to make
89 // the caching multi-thread/context safe in an easy low-overhead manner.
90 // The caller must make sure to clear highp_threshold_cache to 0, so it can be
91 // reinitialized, if a new or different context is used.
92 CC_EXPORT TexCoordPrecision
93 TexCoordPrecisionRequired(gpu::gles2::GLES2Interface* context,
94 int* highp_threshold_cache,
95 int highp_threshold_min,
96 const gfx::Point& max_coordinate);
98 CC_EXPORT TexCoordPrecision TexCoordPrecisionRequired(
99 gpu::gles2::GLES2Interface* context,
100 int *highp_threshold_cache,
101 int highp_threshold_min,
102 const gfx::Size& max_size);
104 class VertexShaderPosTex {
105 public:
106 VertexShaderPosTex();
108 void Init(gpu::gles2::GLES2Interface* context,
109 unsigned program,
110 int* base_uniform_index);
111 std::string GetShaderString() const;
112 static std::string GetShaderHead();
113 static std::string GetShaderBody();
115 int matrix_location() const { return matrix_location_; }
117 private:
118 int matrix_location_;
120 DISALLOW_COPY_AND_ASSIGN(VertexShaderPosTex);
123 class VertexShaderPosTexYUVStretchOffset {
124 public:
125 VertexShaderPosTexYUVStretchOffset();
127 void Init(gpu::gles2::GLES2Interface* context,
128 unsigned program,
129 int* base_uniform_index);
130 std::string GetShaderString() const;
131 static std::string GetShaderHead();
132 static std::string GetShaderBody();
134 int matrix_location() const { return matrix_location_; }
135 int ya_tex_scale_location() const { return ya_tex_scale_location_; }
136 int ya_tex_offset_location() const { return ya_tex_offset_location_; }
137 int uv_tex_scale_location() const { return uv_tex_scale_location_; }
138 int uv_tex_offset_location() const { return uv_tex_offset_location_; }
140 private:
141 int matrix_location_;
142 int ya_tex_scale_location_;
143 int ya_tex_offset_location_;
144 int uv_tex_scale_location_;
145 int uv_tex_offset_location_;
147 DISALLOW_COPY_AND_ASSIGN(VertexShaderPosTexYUVStretchOffset);
150 class VertexShaderPos {
151 public:
152 VertexShaderPos();
154 void Init(gpu::gles2::GLES2Interface* context,
155 unsigned program,
156 int* base_uniform_index);
157 std::string GetShaderString() const;
158 static std::string GetShaderHead();
159 static std::string GetShaderBody();
161 int matrix_location() const { return matrix_location_; }
163 private:
164 int matrix_location_;
166 DISALLOW_COPY_AND_ASSIGN(VertexShaderPos);
169 class VertexShaderPosTexIdentity {
170 public:
171 void Init(gpu::gles2::GLES2Interface* context,
172 unsigned program,
173 int* base_uniform_index) {}
174 std::string GetShaderString() const;
175 static std::string GetShaderHead();
176 static std::string GetShaderBody();
179 class VertexShaderPosTexTransform {
180 public:
181 VertexShaderPosTexTransform();
183 void Init(gpu::gles2::GLES2Interface* context,
184 unsigned program,
185 int* base_uniform_index);
186 std::string GetShaderString() const;
187 static std::string GetShaderHead();
188 static std::string GetShaderBody();
189 void FillLocations(ShaderLocations* locations) const;
191 int matrix_location() const { return matrix_location_; }
192 int tex_transform_location() const { return tex_transform_location_; }
193 int vertex_opacity_location() const { return vertex_opacity_location_; }
195 private:
196 int matrix_location_;
197 int tex_transform_location_;
198 int vertex_opacity_location_;
200 DISALLOW_COPY_AND_ASSIGN(VertexShaderPosTexTransform);
203 class VertexShaderQuad {
204 public:
205 VertexShaderQuad();
207 void Init(gpu::gles2::GLES2Interface* context,
208 unsigned program,
209 int* base_uniform_index);
210 std::string GetShaderString() const;
211 static std::string GetShaderHead();
212 static std::string GetShaderBody();
214 int matrix_location() const { return matrix_location_; }
215 int viewport_location() const { return -1; }
216 int quad_location() const { return quad_location_; }
217 int edge_location() const { return -1; }
219 private:
220 int matrix_location_;
221 int quad_location_;
223 DISALLOW_COPY_AND_ASSIGN(VertexShaderQuad);
226 class VertexShaderQuadAA {
227 public:
228 VertexShaderQuadAA();
230 void Init(gpu::gles2::GLES2Interface* context,
231 unsigned program,
232 int* base_uniform_index);
233 std::string GetShaderString() const;
234 static std::string GetShaderHead();
235 static std::string GetShaderBody();
237 int matrix_location() const { return matrix_location_; }
238 int viewport_location() const { return viewport_location_; }
239 int quad_location() const { return quad_location_; }
240 int edge_location() const { return edge_location_; }
242 private:
243 int matrix_location_;
244 int viewport_location_;
245 int quad_location_;
246 int edge_location_;
248 DISALLOW_COPY_AND_ASSIGN(VertexShaderQuadAA);
252 class VertexShaderQuadTexTransformAA {
253 public:
254 VertexShaderQuadTexTransformAA();
256 void Init(gpu::gles2::GLES2Interface* context,
257 unsigned program,
258 int* base_uniform_index);
259 std::string GetShaderString() const;
260 static std::string GetShaderHead();
261 static std::string GetShaderBody();
262 void FillLocations(ShaderLocations* locations) const;
264 int matrix_location() const { return matrix_location_; }
265 int viewport_location() const { return viewport_location_; }
266 int quad_location() const { return quad_location_; }
267 int edge_location() const { return edge_location_; }
268 int tex_transform_location() const { return tex_transform_location_; }
270 private:
271 int matrix_location_;
272 int viewport_location_;
273 int quad_location_;
274 int edge_location_;
275 int tex_transform_location_;
277 DISALLOW_COPY_AND_ASSIGN(VertexShaderQuadTexTransformAA);
280 class VertexShaderTile {
281 public:
282 VertexShaderTile();
284 void Init(gpu::gles2::GLES2Interface* context,
285 unsigned program,
286 int* base_uniform_index);
287 std::string GetShaderString() const;
288 static std::string GetShaderHead();
289 static std::string GetShaderBody();
291 int matrix_location() const { return matrix_location_; }
292 int viewport_location() const { return -1; }
293 int quad_location() const { return quad_location_; }
294 int edge_location() const { return -1; }
295 int vertex_tex_transform_location() const {
296 return vertex_tex_transform_location_;
299 private:
300 int matrix_location_;
301 int quad_location_;
302 int vertex_tex_transform_location_;
304 DISALLOW_COPY_AND_ASSIGN(VertexShaderTile);
307 class VertexShaderTileAA {
308 public:
309 VertexShaderTileAA();
311 void Init(gpu::gles2::GLES2Interface* context,
312 unsigned program,
313 int* base_uniform_index);
314 std::string GetShaderString() const;
315 static std::string GetShaderHead();
316 static std::string GetShaderBody();
318 int matrix_location() const { return matrix_location_; }
319 int viewport_location() const { return viewport_location_; }
320 int quad_location() const { return quad_location_; }
321 int edge_location() const { return edge_location_; }
322 int vertex_tex_transform_location() const {
323 return vertex_tex_transform_location_;
326 private:
327 int matrix_location_;
328 int viewport_location_;
329 int quad_location_;
330 int edge_location_;
331 int vertex_tex_transform_location_;
333 DISALLOW_COPY_AND_ASSIGN(VertexShaderTileAA);
336 class VertexShaderVideoTransform {
337 public:
338 VertexShaderVideoTransform();
340 void Init(gpu::gles2::GLES2Interface* context,
341 unsigned program,
342 int* base_uniform_index);
343 std::string GetShaderString() const;
344 static std::string GetShaderHead();
345 static std::string GetShaderBody();
347 int matrix_location() const { return matrix_location_; }
348 int tex_matrix_location() const { return tex_matrix_location_; }
350 private:
351 int matrix_location_;
352 int tex_matrix_location_;
354 DISALLOW_COPY_AND_ASSIGN(VertexShaderVideoTransform);
357 class FragmentTexBlendMode {
358 public:
359 int backdrop_location() const { return backdrop_location_; }
360 int original_backdrop_location() const { return original_backdrop_location_; }
361 int backdrop_rect_location() const { return backdrop_rect_location_; }
363 BlendMode blend_mode() const { return blend_mode_; }
364 void set_blend_mode(BlendMode blend_mode) { blend_mode_ = blend_mode; }
365 bool has_blend_mode() const { return blend_mode_ != BLEND_MODE_NONE; }
366 void set_mask_for_background(bool mask_for_background) {
367 mask_for_background_ = mask_for_background;
369 bool mask_for_background() const { return mask_for_background_; }
371 protected:
372 FragmentTexBlendMode();
374 std::string SetBlendModeFunctions(const std::string& shader_string) const;
376 int backdrop_location_;
377 int original_backdrop_location_;
378 int backdrop_rect_location_;
380 private:
381 BlendMode blend_mode_;
382 bool mask_for_background_;
384 std::string GetHelperFunctions() const;
385 std::string GetBlendFunction() const;
386 std::string GetBlendFunctionBodyForRGB() const;
389 class FragmentTexAlphaBinding : public FragmentTexBlendMode {
390 public:
391 FragmentTexAlphaBinding();
393 void Init(gpu::gles2::GLES2Interface* context,
394 unsigned program,
395 int* base_uniform_index);
396 int alpha_location() const { return alpha_location_; }
397 int fragment_tex_transform_location() const { return -1; }
398 int sampler_location() const { return sampler_location_; }
400 private:
401 int sampler_location_;
402 int alpha_location_;
404 DISALLOW_COPY_AND_ASSIGN(FragmentTexAlphaBinding);
407 class FragmentTexColorMatrixAlphaBinding : public FragmentTexBlendMode {
408 public:
409 FragmentTexColorMatrixAlphaBinding();
411 void Init(gpu::gles2::GLES2Interface* context,
412 unsigned program,
413 int* base_uniform_index);
414 int alpha_location() const { return alpha_location_; }
415 int color_matrix_location() const { return color_matrix_location_; }
416 int color_offset_location() const { return color_offset_location_; }
417 int fragment_tex_transform_location() const { return -1; }
418 int sampler_location() const { return sampler_location_; }
420 private:
421 int sampler_location_;
422 int alpha_location_;
423 int color_matrix_location_;
424 int color_offset_location_;
427 class FragmentTexOpaqueBinding : public FragmentTexBlendMode {
428 public:
429 FragmentTexOpaqueBinding();
431 void Init(gpu::gles2::GLES2Interface* context,
432 unsigned program,
433 int* base_uniform_index);
434 int alpha_location() const { return -1; }
435 int fragment_tex_transform_location() const { return -1; }
436 int background_color_location() const { return -1; }
437 int sampler_location() const { return sampler_location_; }
439 private:
440 int sampler_location_;
442 DISALLOW_COPY_AND_ASSIGN(FragmentTexOpaqueBinding);
445 class FragmentTexBackgroundBinding : public FragmentTexBlendMode {
446 public:
447 FragmentTexBackgroundBinding();
449 void Init(gpu::gles2::GLES2Interface* context,
450 unsigned program,
451 int* base_uniform_index);
452 int background_color_location() const { return background_color_location_; }
453 int sampler_location() const { return sampler_location_; }
455 private:
456 int background_color_location_;
457 int sampler_location_;
459 DISALLOW_COPY_AND_ASSIGN(FragmentTexBackgroundBinding);
462 class FragmentShaderRGBATexVaryingAlpha : public FragmentTexOpaqueBinding {
463 public:
464 std::string GetShaderString(
465 TexCoordPrecision precision, SamplerType sampler) const;
466 static std::string GetShaderHead();
467 static std::string GetShaderBody();
470 class FragmentShaderRGBATexPremultiplyAlpha : public FragmentTexOpaqueBinding {
471 public:
472 std::string GetShaderString(
473 TexCoordPrecision precision, SamplerType sampler) const;
474 static std::string GetShaderHead();
475 static std::string GetShaderBody();
478 class FragmentShaderTexBackgroundVaryingAlpha
479 : public FragmentTexBackgroundBinding {
480 public:
481 std::string GetShaderString(
482 TexCoordPrecision precision, SamplerType sampler) const;
483 static std::string GetShaderHead();
484 static std::string GetShaderBody();
487 class FragmentShaderTexBackgroundPremultiplyAlpha
488 : public FragmentTexBackgroundBinding {
489 public:
490 std::string GetShaderString(
491 TexCoordPrecision precision, SamplerType sampler) const;
492 static std::string GetShaderHead();
493 static std::string GetShaderBody();
496 class FragmentShaderRGBATexAlpha : public FragmentTexAlphaBinding {
497 public:
498 std::string GetShaderString(
499 TexCoordPrecision precision, SamplerType sampler) const;
500 static std::string GetShaderHead();
501 static std::string GetShaderBody();
502 void FillLocations(ShaderLocations* locations) const;
505 class FragmentShaderRGBATexColorMatrixAlpha
506 : public FragmentTexColorMatrixAlphaBinding {
507 public:
508 std::string GetShaderString(TexCoordPrecision precision,
509 SamplerType sampler) const;
510 static std::string GetShaderHead();
511 static std::string GetShaderBody();
512 void FillLocations(ShaderLocations* locations) const;
515 class FragmentShaderRGBATexOpaque : public FragmentTexOpaqueBinding {
516 public:
517 std::string GetShaderString(
518 TexCoordPrecision precision, SamplerType sampler) const;
519 static std::string GetShaderHead();
520 static std::string GetShaderBody();
523 class FragmentShaderRGBATex : public FragmentTexOpaqueBinding {
524 public:
525 std::string GetShaderString(
526 TexCoordPrecision precision, SamplerType sampler) const;
527 static std::string GetShaderHead();
528 static std::string GetShaderBody();
531 // Swizzles the red and blue component of sampled texel with alpha.
532 class FragmentShaderRGBATexSwizzleAlpha : public FragmentTexAlphaBinding {
533 public:
534 std::string GetShaderString(
535 TexCoordPrecision precision, SamplerType sampler) const;
536 static std::string GetShaderHead();
537 static std::string GetShaderBody();
540 // Swizzles the red and blue component of sampled texel without alpha.
541 class FragmentShaderRGBATexSwizzleOpaque : public FragmentTexOpaqueBinding {
542 public:
543 std::string GetShaderString(
544 TexCoordPrecision precision, SamplerType sampler) const;
545 static std::string GetShaderHead();
546 static std::string GetShaderBody();
549 class FragmentShaderRGBATexAlphaAA : public FragmentTexBlendMode {
550 public:
551 FragmentShaderRGBATexAlphaAA();
553 void Init(gpu::gles2::GLES2Interface* context,
554 unsigned program,
555 int* base_uniform_index);
556 std::string GetShaderString(
557 TexCoordPrecision precision, SamplerType sampler) const;
558 static std::string GetShaderHead();
559 static std::string GetShaderBody();
560 void FillLocations(ShaderLocations* locations) const;
562 int alpha_location() const { return alpha_location_; }
563 int sampler_location() const { return sampler_location_; }
565 private:
566 int sampler_location_;
567 int alpha_location_;
569 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaAA);
572 class FragmentTexClampAlphaAABinding : public FragmentTexBlendMode {
573 public:
574 FragmentTexClampAlphaAABinding();
576 void Init(gpu::gles2::GLES2Interface* context,
577 unsigned program,
578 int* base_uniform_index);
579 int alpha_location() const { return alpha_location_; }
580 int sampler_location() const { return sampler_location_; }
581 int fragment_tex_transform_location() const {
582 return fragment_tex_transform_location_;
585 private:
586 int sampler_location_;
587 int alpha_location_;
588 int fragment_tex_transform_location_;
590 DISALLOW_COPY_AND_ASSIGN(FragmentTexClampAlphaAABinding);
593 class FragmentShaderRGBATexClampAlphaAA
594 : public FragmentTexClampAlphaAABinding {
595 public:
596 std::string GetShaderString(
597 TexCoordPrecision precision, SamplerType sampler) const;
598 static std::string GetShaderHead();
599 static std::string GetShaderBody();
602 // Swizzles the red and blue component of sampled texel.
603 class FragmentShaderRGBATexClampSwizzleAlphaAA
604 : public FragmentTexClampAlphaAABinding {
605 public:
606 std::string GetShaderString(
607 TexCoordPrecision precision, SamplerType sampler) const;
608 static std::string GetShaderHead();
609 static std::string GetShaderBody();
612 class FragmentShaderRGBATexAlphaMask : public FragmentTexBlendMode {
613 public:
614 FragmentShaderRGBATexAlphaMask();
615 std::string GetShaderString(
616 TexCoordPrecision precision, SamplerType sampler) const;
617 static std::string GetShaderHead();
618 static std::string GetShaderBody();
619 void FillLocations(ShaderLocations* locations) const;
620 void Init(gpu::gles2::GLES2Interface* context,
621 unsigned program,
622 int* base_uniform_index);
623 int alpha_location() const { return alpha_location_; }
624 int sampler_location() const { return sampler_location_; }
625 int mask_sampler_location() const { return mask_sampler_location_; }
626 int mask_tex_coord_scale_location() const {
627 return mask_tex_coord_scale_location_;
629 int mask_tex_coord_offset_location() const {
630 return mask_tex_coord_offset_location_;
633 private:
634 int sampler_location_;
635 int mask_sampler_location_;
636 int alpha_location_;
637 int mask_tex_coord_scale_location_;
638 int mask_tex_coord_offset_location_;
640 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaMask);
643 class FragmentShaderRGBATexAlphaMaskAA : public FragmentTexBlendMode {
644 public:
645 FragmentShaderRGBATexAlphaMaskAA();
646 std::string GetShaderString(
647 TexCoordPrecision precision, SamplerType sampler) const;
648 static std::string GetShaderHead();
649 static std::string GetShaderBody();
650 void FillLocations(ShaderLocations* locations) const;
651 void Init(gpu::gles2::GLES2Interface* context,
652 unsigned program,
653 int* base_uniform_index);
654 int alpha_location() const { return alpha_location_; }
655 int sampler_location() const { return sampler_location_; }
656 int mask_sampler_location() const { return mask_sampler_location_; }
657 int mask_tex_coord_scale_location() const {
658 return mask_tex_coord_scale_location_;
660 int mask_tex_coord_offset_location() const {
661 return mask_tex_coord_offset_location_;
664 private:
665 int sampler_location_;
666 int mask_sampler_location_;
667 int alpha_location_;
668 int mask_tex_coord_scale_location_;
669 int mask_tex_coord_offset_location_;
671 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaMaskAA);
674 class FragmentShaderRGBATexAlphaMaskColorMatrixAA
675 : public FragmentTexBlendMode {
676 public:
677 FragmentShaderRGBATexAlphaMaskColorMatrixAA();
678 std::string GetShaderString(
679 TexCoordPrecision precision, SamplerType sampler) const;
680 static std::string GetShaderHead();
681 static std::string GetShaderBody();
682 void FillLocations(ShaderLocations* locations) const;
683 void Init(gpu::gles2::GLES2Interface* context,
684 unsigned program,
685 int* base_uniform_index);
686 int alpha_location() const { return alpha_location_; }
687 int sampler_location() const { return sampler_location_; }
688 int mask_sampler_location() const { return mask_sampler_location_; }
689 int mask_tex_coord_scale_location() const {
690 return mask_tex_coord_scale_location_;
692 int mask_tex_coord_offset_location() const {
693 return mask_tex_coord_offset_location_;
695 int color_matrix_location() const { return color_matrix_location_; }
696 int color_offset_location() const { return color_offset_location_; }
698 private:
699 int sampler_location_;
700 int mask_sampler_location_;
701 int alpha_location_;
702 int mask_tex_coord_scale_location_;
703 int mask_tex_coord_offset_location_;
704 int color_matrix_location_;
705 int color_offset_location_;
708 class FragmentShaderRGBATexAlphaColorMatrixAA : public FragmentTexBlendMode {
709 public:
710 FragmentShaderRGBATexAlphaColorMatrixAA();
711 std::string GetShaderString(
712 TexCoordPrecision precision, SamplerType sampler) const;
713 static std::string GetShaderHead();
714 static std::string GetShaderBody();
715 void FillLocations(ShaderLocations* locations) const;
716 void Init(gpu::gles2::GLES2Interface* context,
717 unsigned program,
718 int* base_uniform_index);
719 int alpha_location() const { return alpha_location_; }
720 int sampler_location() const { return sampler_location_; }
721 int color_matrix_location() const { return color_matrix_location_; }
722 int color_offset_location() const { return color_offset_location_; }
724 private:
725 int sampler_location_;
726 int alpha_location_;
727 int color_matrix_location_;
728 int color_offset_location_;
731 class FragmentShaderRGBATexAlphaMaskColorMatrix : public FragmentTexBlendMode {
732 public:
733 FragmentShaderRGBATexAlphaMaskColorMatrix();
734 std::string GetShaderString(
735 TexCoordPrecision precision, SamplerType sampler) const;
736 static std::string GetShaderHead();
737 static std::string GetShaderBody();
738 void FillLocations(ShaderLocations* locations) const;
739 void Init(gpu::gles2::GLES2Interface* context,
740 unsigned program,
741 int* base_uniform_index);
742 int alpha_location() const { return alpha_location_; }
743 int sampler_location() const { return sampler_location_; }
744 int mask_sampler_location() const { return mask_sampler_location_; }
745 int mask_tex_coord_scale_location() const {
746 return mask_tex_coord_scale_location_;
748 int mask_tex_coord_offset_location() const {
749 return mask_tex_coord_offset_location_;
751 int color_matrix_location() const { return color_matrix_location_; }
752 int color_offset_location() const { return color_offset_location_; }
754 private:
755 int sampler_location_;
756 int mask_sampler_location_;
757 int alpha_location_;
758 int mask_tex_coord_scale_location_;
759 int mask_tex_coord_offset_location_;
760 int color_matrix_location_;
761 int color_offset_location_;
764 class FragmentShaderYUVVideo : public FragmentTexBlendMode {
765 public:
766 FragmentShaderYUVVideo();
767 std::string GetShaderString(
768 TexCoordPrecision precision, SamplerType sampler) const;
769 static std::string GetShaderHead();
770 static std::string GetShaderBody();
772 void Init(gpu::gles2::GLES2Interface* context,
773 unsigned program,
774 int* base_uniform_index);
775 int y_texture_location() const { return y_texture_location_; }
776 int u_texture_location() const { return u_texture_location_; }
777 int v_texture_location() const { return v_texture_location_; }
778 int alpha_location() const { return alpha_location_; }
779 int yuv_matrix_location() const { return yuv_matrix_location_; }
780 int yuv_adj_location() const { return yuv_adj_location_; }
781 int ya_clamp_rect_location() const { return ya_clamp_rect_location_; }
782 int uv_clamp_rect_location() const { return uv_clamp_rect_location_; }
784 private:
785 int y_texture_location_;
786 int u_texture_location_;
787 int v_texture_location_;
788 int alpha_location_;
789 int yuv_matrix_location_;
790 int yuv_adj_location_;
791 int ya_clamp_rect_location_;
792 int uv_clamp_rect_location_;
794 DISALLOW_COPY_AND_ASSIGN(FragmentShaderYUVVideo);
797 class FragmentShaderYUVAVideo : public FragmentTexBlendMode {
798 public:
799 FragmentShaderYUVAVideo();
800 std::string GetShaderString(
801 TexCoordPrecision precision, SamplerType sampler) const;
802 static std::string GetShaderHead();
803 static std::string GetShaderBody();
805 void Init(gpu::gles2::GLES2Interface* context,
806 unsigned program,
807 int* base_uniform_index);
809 int y_texture_location() const { return y_texture_location_; }
810 int u_texture_location() const { return u_texture_location_; }
811 int v_texture_location() const { return v_texture_location_; }
812 int a_texture_location() const { return a_texture_location_; }
813 int alpha_location() const { return alpha_location_; }
814 int yuv_matrix_location() const { return yuv_matrix_location_; }
815 int yuv_adj_location() const { return yuv_adj_location_; }
816 int ya_clamp_rect_location() const { return ya_clamp_rect_location_; }
817 int uv_clamp_rect_location() const { return uv_clamp_rect_location_; }
819 private:
820 int y_texture_location_;
821 int u_texture_location_;
822 int v_texture_location_;
823 int a_texture_location_;
824 int alpha_location_;
825 int yuv_matrix_location_;
826 int yuv_adj_location_;
827 int ya_clamp_rect_location_;
828 int uv_clamp_rect_location_;
830 DISALLOW_COPY_AND_ASSIGN(FragmentShaderYUVAVideo);
833 class FragmentShaderColor : public FragmentTexBlendMode {
834 public:
835 FragmentShaderColor();
836 std::string GetShaderString(
837 TexCoordPrecision precision, SamplerType sampler) const;
838 static std::string GetShaderHead();
839 static std::string GetShaderBody();
841 void Init(gpu::gles2::GLES2Interface* context,
842 unsigned program,
843 int* base_uniform_index);
844 int color_location() const { return color_location_; }
846 private:
847 int color_location_;
849 DISALLOW_COPY_AND_ASSIGN(FragmentShaderColor);
852 class FragmentShaderColorAA : public FragmentTexBlendMode {
853 public:
854 FragmentShaderColorAA();
855 std::string GetShaderString(
856 TexCoordPrecision precision, SamplerType sampler) const;
857 static std::string GetShaderHead();
858 static std::string GetShaderBody();
860 void Init(gpu::gles2::GLES2Interface* context,
861 unsigned program,
862 int* base_uniform_index);
863 int color_location() const { return color_location_; }
865 private:
866 int color_location_;
868 DISALLOW_COPY_AND_ASSIGN(FragmentShaderColorAA);
871 } // namespace cc
873 #endif // CC_OUTPUT_SHADER_H_