Move onConsoleMessage implementation to chromium layer
[chromium-blink-merge.git] / cc / output / shader.h
blob561fe28d1049224634025531f857c3e9a52b4fa5
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 tex_scale_location() const { return tex_scale_location_; }
136 int tex_offset_location() const { return tex_offset_location_; }
138 private:
139 int matrix_location_;
140 int tex_scale_location_;
141 int tex_offset_location_;
143 DISALLOW_COPY_AND_ASSIGN(VertexShaderPosTexYUVStretchOffset);
146 class VertexShaderPos {
147 public:
148 VertexShaderPos();
150 void Init(gpu::gles2::GLES2Interface* context,
151 unsigned program,
152 int* base_uniform_index);
153 std::string GetShaderString() const;
154 static std::string GetShaderHead();
155 static std::string GetShaderBody();
157 int matrix_location() const { return matrix_location_; }
159 private:
160 int matrix_location_;
162 DISALLOW_COPY_AND_ASSIGN(VertexShaderPos);
165 class VertexShaderPosTexIdentity {
166 public:
167 void Init(gpu::gles2::GLES2Interface* context,
168 unsigned program,
169 int* base_uniform_index) {}
170 std::string GetShaderString() const;
171 static std::string GetShaderHead();
172 static std::string GetShaderBody();
175 class VertexShaderPosTexTransform {
176 public:
177 VertexShaderPosTexTransform();
179 void Init(gpu::gles2::GLES2Interface* context,
180 unsigned program,
181 int* base_uniform_index);
182 std::string GetShaderString() const;
183 static std::string GetShaderHead();
184 static std::string GetShaderBody();
185 void FillLocations(ShaderLocations* locations) const;
187 int matrix_location() const { return matrix_location_; }
188 int tex_transform_location() const { return tex_transform_location_; }
189 int vertex_opacity_location() const { return vertex_opacity_location_; }
191 private:
192 int matrix_location_;
193 int tex_transform_location_;
194 int vertex_opacity_location_;
196 DISALLOW_COPY_AND_ASSIGN(VertexShaderPosTexTransform);
199 class VertexShaderQuad {
200 public:
201 VertexShaderQuad();
203 void Init(gpu::gles2::GLES2Interface* context,
204 unsigned program,
205 int* base_uniform_index);
206 std::string GetShaderString() const;
207 static std::string GetShaderHead();
208 static std::string GetShaderBody();
210 int matrix_location() const { return matrix_location_; }
211 int viewport_location() const { return -1; }
212 int quad_location() const { return quad_location_; }
213 int edge_location() const { return -1; }
215 private:
216 int matrix_location_;
217 int quad_location_;
219 DISALLOW_COPY_AND_ASSIGN(VertexShaderQuad);
222 class VertexShaderQuadAA {
223 public:
224 VertexShaderQuadAA();
226 void Init(gpu::gles2::GLES2Interface* context,
227 unsigned program,
228 int* base_uniform_index);
229 std::string GetShaderString() const;
230 static std::string GetShaderHead();
231 static std::string GetShaderBody();
233 int matrix_location() const { return matrix_location_; }
234 int viewport_location() const { return viewport_location_; }
235 int quad_location() const { return quad_location_; }
236 int edge_location() const { return edge_location_; }
238 private:
239 int matrix_location_;
240 int viewport_location_;
241 int quad_location_;
242 int edge_location_;
244 DISALLOW_COPY_AND_ASSIGN(VertexShaderQuadAA);
248 class VertexShaderQuadTexTransformAA {
249 public:
250 VertexShaderQuadTexTransformAA();
252 void Init(gpu::gles2::GLES2Interface* context,
253 unsigned program,
254 int* base_uniform_index);
255 std::string GetShaderString() const;
256 static std::string GetShaderHead();
257 static std::string GetShaderBody();
258 void FillLocations(ShaderLocations* locations) const;
260 int matrix_location() const { return matrix_location_; }
261 int viewport_location() const { return viewport_location_; }
262 int quad_location() const { return quad_location_; }
263 int edge_location() const { return edge_location_; }
264 int tex_transform_location() const { return tex_transform_location_; }
266 private:
267 int matrix_location_;
268 int viewport_location_;
269 int quad_location_;
270 int edge_location_;
271 int tex_transform_location_;
273 DISALLOW_COPY_AND_ASSIGN(VertexShaderQuadTexTransformAA);
276 class VertexShaderTile {
277 public:
278 VertexShaderTile();
280 void Init(gpu::gles2::GLES2Interface* context,
281 unsigned program,
282 int* base_uniform_index);
283 std::string GetShaderString() const;
284 static std::string GetShaderHead();
285 static std::string GetShaderBody();
287 int matrix_location() const { return matrix_location_; }
288 int viewport_location() const { return -1; }
289 int quad_location() const { return quad_location_; }
290 int edge_location() const { return -1; }
291 int vertex_tex_transform_location() const {
292 return vertex_tex_transform_location_;
295 private:
296 int matrix_location_;
297 int quad_location_;
298 int vertex_tex_transform_location_;
300 DISALLOW_COPY_AND_ASSIGN(VertexShaderTile);
303 class VertexShaderTileAA {
304 public:
305 VertexShaderTileAA();
307 void Init(gpu::gles2::GLES2Interface* context,
308 unsigned program,
309 int* base_uniform_index);
310 std::string GetShaderString() const;
311 static std::string GetShaderHead();
312 static std::string GetShaderBody();
314 int matrix_location() const { return matrix_location_; }
315 int viewport_location() const { return viewport_location_; }
316 int quad_location() const { return quad_location_; }
317 int edge_location() const { return edge_location_; }
318 int vertex_tex_transform_location() const {
319 return vertex_tex_transform_location_;
322 private:
323 int matrix_location_;
324 int viewport_location_;
325 int quad_location_;
326 int edge_location_;
327 int vertex_tex_transform_location_;
329 DISALLOW_COPY_AND_ASSIGN(VertexShaderTileAA);
332 class VertexShaderVideoTransform {
333 public:
334 VertexShaderVideoTransform();
336 void Init(gpu::gles2::GLES2Interface* context,
337 unsigned program,
338 int* base_uniform_index);
339 std::string GetShaderString() const;
340 static std::string GetShaderHead();
341 static std::string GetShaderBody();
343 int matrix_location() const { return matrix_location_; }
344 int tex_matrix_location() const { return tex_matrix_location_; }
346 private:
347 int matrix_location_;
348 int tex_matrix_location_;
350 DISALLOW_COPY_AND_ASSIGN(VertexShaderVideoTransform);
353 class FragmentTexBlendMode {
354 public:
355 int backdrop_location() const { return backdrop_location_; }
356 int original_backdrop_location() const { return original_backdrop_location_; }
357 int backdrop_rect_location() const { return backdrop_rect_location_; }
359 BlendMode blend_mode() const { return blend_mode_; }
360 void set_blend_mode(BlendMode blend_mode) { blend_mode_ = blend_mode; }
361 bool has_blend_mode() const { return blend_mode_ != BLEND_MODE_NONE; }
362 void set_mask_for_background(bool mask_for_background) {
363 mask_for_background_ = mask_for_background;
365 bool mask_for_background() const { return mask_for_background_; }
367 protected:
368 FragmentTexBlendMode();
370 std::string SetBlendModeFunctions(std::string shader_string) const;
372 int backdrop_location_;
373 int original_backdrop_location_;
374 int backdrop_rect_location_;
376 private:
377 BlendMode blend_mode_;
378 bool mask_for_background_;
380 std::string GetHelperFunctions() const;
381 std::string GetBlendFunction() const;
382 std::string GetBlendFunctionBodyForRGB() const;
385 class FragmentTexAlphaBinding : public FragmentTexBlendMode {
386 public:
387 FragmentTexAlphaBinding();
389 void Init(gpu::gles2::GLES2Interface* context,
390 unsigned program,
391 int* base_uniform_index);
392 int alpha_location() const { return alpha_location_; }
393 int fragment_tex_transform_location() const { return -1; }
394 int sampler_location() const { return sampler_location_; }
396 private:
397 int sampler_location_;
398 int alpha_location_;
400 DISALLOW_COPY_AND_ASSIGN(FragmentTexAlphaBinding);
403 class FragmentTexColorMatrixAlphaBinding : public FragmentTexBlendMode {
404 public:
405 FragmentTexColorMatrixAlphaBinding();
407 void Init(gpu::gles2::GLES2Interface* context,
408 unsigned program,
409 int* base_uniform_index);
410 int alpha_location() const { return alpha_location_; }
411 int color_matrix_location() const { return color_matrix_location_; }
412 int color_offset_location() const { return color_offset_location_; }
413 int fragment_tex_transform_location() const { return -1; }
414 int sampler_location() const { return sampler_location_; }
416 private:
417 int sampler_location_;
418 int alpha_location_;
419 int color_matrix_location_;
420 int color_offset_location_;
423 class FragmentTexOpaqueBinding : public FragmentTexBlendMode {
424 public:
425 FragmentTexOpaqueBinding();
427 void Init(gpu::gles2::GLES2Interface* context,
428 unsigned program,
429 int* base_uniform_index);
430 int alpha_location() const { return -1; }
431 int fragment_tex_transform_location() const { return -1; }
432 int background_color_location() const { return -1; }
433 int sampler_location() const { return sampler_location_; }
435 private:
436 int sampler_location_;
438 DISALLOW_COPY_AND_ASSIGN(FragmentTexOpaqueBinding);
441 class FragmentTexBackgroundBinding : public FragmentTexBlendMode {
442 public:
443 FragmentTexBackgroundBinding();
445 void Init(gpu::gles2::GLES2Interface* context,
446 unsigned program,
447 int* base_uniform_index);
448 int background_color_location() const { return background_color_location_; }
449 int sampler_location() const { return sampler_location_; }
451 private:
452 int background_color_location_;
453 int sampler_location_;
455 DISALLOW_COPY_AND_ASSIGN(FragmentTexBackgroundBinding);
458 class FragmentShaderRGBATexVaryingAlpha : public FragmentTexOpaqueBinding {
459 public:
460 std::string GetShaderString(
461 TexCoordPrecision precision, SamplerType sampler) const;
462 static std::string GetShaderHead();
463 static std::string GetShaderBody();
466 class FragmentShaderRGBATexPremultiplyAlpha : public FragmentTexOpaqueBinding {
467 public:
468 std::string GetShaderString(
469 TexCoordPrecision precision, SamplerType sampler) const;
470 static std::string GetShaderHead();
471 static std::string GetShaderBody();
474 class FragmentShaderTexBackgroundVaryingAlpha
475 : public FragmentTexBackgroundBinding {
476 public:
477 std::string GetShaderString(
478 TexCoordPrecision precision, SamplerType sampler) const;
479 static std::string GetShaderHead();
480 static std::string GetShaderBody();
483 class FragmentShaderTexBackgroundPremultiplyAlpha
484 : public FragmentTexBackgroundBinding {
485 public:
486 std::string GetShaderString(
487 TexCoordPrecision precision, SamplerType sampler) const;
488 static std::string GetShaderHead();
489 static std::string GetShaderBody();
492 class FragmentShaderRGBATexAlpha : public FragmentTexAlphaBinding {
493 public:
494 std::string GetShaderString(
495 TexCoordPrecision precision, SamplerType sampler) const;
496 static std::string GetShaderHead();
497 static std::string GetShaderBody();
498 void FillLocations(ShaderLocations* locations) const;
501 class FragmentShaderRGBATexColorMatrixAlpha
502 : public FragmentTexColorMatrixAlphaBinding {
503 public:
504 std::string GetShaderString(TexCoordPrecision precision,
505 SamplerType sampler) const;
506 static std::string GetShaderHead();
507 static std::string GetShaderBody();
508 void FillLocations(ShaderLocations* locations) const;
511 class FragmentShaderRGBATexOpaque : public FragmentTexOpaqueBinding {
512 public:
513 std::string GetShaderString(
514 TexCoordPrecision precision, SamplerType sampler) const;
515 static std::string GetShaderHead();
516 static std::string GetShaderBody();
519 class FragmentShaderRGBATex : public FragmentTexOpaqueBinding {
520 public:
521 std::string GetShaderString(
522 TexCoordPrecision precision, SamplerType sampler) const;
523 static std::string GetShaderHead();
524 static std::string GetShaderBody();
527 // Swizzles the red and blue component of sampled texel with alpha.
528 class FragmentShaderRGBATexSwizzleAlpha : public FragmentTexAlphaBinding {
529 public:
530 std::string GetShaderString(
531 TexCoordPrecision precision, SamplerType sampler) const;
532 static std::string GetShaderHead();
533 static std::string GetShaderBody();
536 // Swizzles the red and blue component of sampled texel without alpha.
537 class FragmentShaderRGBATexSwizzleOpaque : public FragmentTexOpaqueBinding {
538 public:
539 std::string GetShaderString(
540 TexCoordPrecision precision, SamplerType sampler) const;
541 static std::string GetShaderHead();
542 static std::string GetShaderBody();
545 class FragmentShaderRGBATexAlphaAA : public FragmentTexBlendMode {
546 public:
547 FragmentShaderRGBATexAlphaAA();
549 void Init(gpu::gles2::GLES2Interface* context,
550 unsigned program,
551 int* base_uniform_index);
552 std::string GetShaderString(
553 TexCoordPrecision precision, SamplerType sampler) const;
554 static std::string GetShaderHead();
555 static std::string GetShaderBody();
556 void FillLocations(ShaderLocations* locations) const;
558 int alpha_location() const { return alpha_location_; }
559 int sampler_location() const { return sampler_location_; }
561 private:
562 int sampler_location_;
563 int alpha_location_;
565 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaAA);
568 class FragmentTexClampAlphaAABinding : public FragmentTexBlendMode {
569 public:
570 FragmentTexClampAlphaAABinding();
572 void Init(gpu::gles2::GLES2Interface* context,
573 unsigned program,
574 int* base_uniform_index);
575 int alpha_location() const { return alpha_location_; }
576 int sampler_location() const { return sampler_location_; }
577 int fragment_tex_transform_location() const {
578 return fragment_tex_transform_location_;
581 private:
582 int sampler_location_;
583 int alpha_location_;
584 int fragment_tex_transform_location_;
586 DISALLOW_COPY_AND_ASSIGN(FragmentTexClampAlphaAABinding);
589 class FragmentShaderRGBATexClampAlphaAA
590 : public FragmentTexClampAlphaAABinding {
591 public:
592 std::string GetShaderString(
593 TexCoordPrecision precision, SamplerType sampler) const;
594 static std::string GetShaderHead();
595 static std::string GetShaderBody();
598 // Swizzles the red and blue component of sampled texel.
599 class FragmentShaderRGBATexClampSwizzleAlphaAA
600 : public FragmentTexClampAlphaAABinding {
601 public:
602 std::string GetShaderString(
603 TexCoordPrecision precision, SamplerType sampler) const;
604 static std::string GetShaderHead();
605 static std::string GetShaderBody();
608 class FragmentShaderRGBATexAlphaMask : public FragmentTexBlendMode {
609 public:
610 FragmentShaderRGBATexAlphaMask();
611 std::string GetShaderString(
612 TexCoordPrecision precision, SamplerType sampler) const;
613 static std::string GetShaderHead();
614 static std::string GetShaderBody();
615 void FillLocations(ShaderLocations* locations) const;
616 void Init(gpu::gles2::GLES2Interface* context,
617 unsigned program,
618 int* base_uniform_index);
619 int alpha_location() const { return alpha_location_; }
620 int sampler_location() const { return sampler_location_; }
621 int mask_sampler_location() const { return mask_sampler_location_; }
622 int mask_tex_coord_scale_location() const {
623 return mask_tex_coord_scale_location_;
625 int mask_tex_coord_offset_location() const {
626 return mask_tex_coord_offset_location_;
629 private:
630 int sampler_location_;
631 int mask_sampler_location_;
632 int alpha_location_;
633 int mask_tex_coord_scale_location_;
634 int mask_tex_coord_offset_location_;
636 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaMask);
639 class FragmentShaderRGBATexAlphaMaskAA : public FragmentTexBlendMode {
640 public:
641 FragmentShaderRGBATexAlphaMaskAA();
642 std::string GetShaderString(
643 TexCoordPrecision precision, SamplerType sampler) const;
644 static std::string GetShaderHead();
645 static std::string GetShaderBody();
646 void FillLocations(ShaderLocations* locations) const;
647 void Init(gpu::gles2::GLES2Interface* context,
648 unsigned program,
649 int* base_uniform_index);
650 int alpha_location() const { return alpha_location_; }
651 int sampler_location() const { return sampler_location_; }
652 int mask_sampler_location() const { return mask_sampler_location_; }
653 int mask_tex_coord_scale_location() const {
654 return mask_tex_coord_scale_location_;
656 int mask_tex_coord_offset_location() const {
657 return mask_tex_coord_offset_location_;
660 private:
661 int sampler_location_;
662 int mask_sampler_location_;
663 int alpha_location_;
664 int mask_tex_coord_scale_location_;
665 int mask_tex_coord_offset_location_;
667 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaMaskAA);
670 class FragmentShaderRGBATexAlphaMaskColorMatrixAA
671 : public FragmentTexBlendMode {
672 public:
673 FragmentShaderRGBATexAlphaMaskColorMatrixAA();
674 std::string GetShaderString(
675 TexCoordPrecision precision, SamplerType sampler) const;
676 static std::string GetShaderHead();
677 static std::string GetShaderBody();
678 void FillLocations(ShaderLocations* locations) const;
679 void Init(gpu::gles2::GLES2Interface* context,
680 unsigned program,
681 int* base_uniform_index);
682 int alpha_location() const { return alpha_location_; }
683 int sampler_location() const { return sampler_location_; }
684 int mask_sampler_location() const { return mask_sampler_location_; }
685 int mask_tex_coord_scale_location() const {
686 return mask_tex_coord_scale_location_;
688 int mask_tex_coord_offset_location() const {
689 return mask_tex_coord_offset_location_;
691 int color_matrix_location() const { return color_matrix_location_; }
692 int color_offset_location() const { return color_offset_location_; }
694 private:
695 int sampler_location_;
696 int mask_sampler_location_;
697 int alpha_location_;
698 int mask_tex_coord_scale_location_;
699 int mask_tex_coord_offset_location_;
700 int color_matrix_location_;
701 int color_offset_location_;
704 class FragmentShaderRGBATexAlphaColorMatrixAA : public FragmentTexBlendMode {
705 public:
706 FragmentShaderRGBATexAlphaColorMatrixAA();
707 std::string GetShaderString(
708 TexCoordPrecision precision, SamplerType sampler) const;
709 static std::string GetShaderHead();
710 static std::string GetShaderBody();
711 void FillLocations(ShaderLocations* locations) const;
712 void Init(gpu::gles2::GLES2Interface* context,
713 unsigned program,
714 int* base_uniform_index);
715 int alpha_location() const { return alpha_location_; }
716 int sampler_location() const { return sampler_location_; }
717 int color_matrix_location() const { return color_matrix_location_; }
718 int color_offset_location() const { return color_offset_location_; }
720 private:
721 int sampler_location_;
722 int alpha_location_;
723 int color_matrix_location_;
724 int color_offset_location_;
727 class FragmentShaderRGBATexAlphaMaskColorMatrix : public FragmentTexBlendMode {
728 public:
729 FragmentShaderRGBATexAlphaMaskColorMatrix();
730 std::string GetShaderString(
731 TexCoordPrecision precision, SamplerType sampler) const;
732 static std::string GetShaderHead();
733 static std::string GetShaderBody();
734 void FillLocations(ShaderLocations* locations) const;
735 void Init(gpu::gles2::GLES2Interface* context,
736 unsigned program,
737 int* base_uniform_index);
738 int alpha_location() const { return alpha_location_; }
739 int sampler_location() const { return sampler_location_; }
740 int mask_sampler_location() const { return mask_sampler_location_; }
741 int mask_tex_coord_scale_location() const {
742 return mask_tex_coord_scale_location_;
744 int mask_tex_coord_offset_location() const {
745 return mask_tex_coord_offset_location_;
747 int color_matrix_location() const { return color_matrix_location_; }
748 int color_offset_location() const { return color_offset_location_; }
750 private:
751 int sampler_location_;
752 int mask_sampler_location_;
753 int alpha_location_;
754 int mask_tex_coord_scale_location_;
755 int mask_tex_coord_offset_location_;
756 int color_matrix_location_;
757 int color_offset_location_;
760 class FragmentShaderYUVVideo : public FragmentTexBlendMode {
761 public:
762 FragmentShaderYUVVideo();
763 std::string GetShaderString(
764 TexCoordPrecision precision, SamplerType sampler) const;
765 static std::string GetShaderHead();
766 static std::string GetShaderBody();
768 void Init(gpu::gles2::GLES2Interface* context,
769 unsigned program,
770 int* base_uniform_index);
771 int y_texture_location() const { return y_texture_location_; }
772 int u_texture_location() const { return u_texture_location_; }
773 int v_texture_location() const { return v_texture_location_; }
774 int alpha_location() const { return alpha_location_; }
775 int yuv_matrix_location() const { return yuv_matrix_location_; }
776 int yuv_adj_location() const { return yuv_adj_location_; }
777 int clamp_rect_location() const { return clamp_rect_location_; }
779 private:
780 int y_texture_location_;
781 int u_texture_location_;
782 int v_texture_location_;
783 int alpha_location_;
784 int yuv_matrix_location_;
785 int yuv_adj_location_;
786 int clamp_rect_location_;
788 DISALLOW_COPY_AND_ASSIGN(FragmentShaderYUVVideo);
791 class FragmentShaderYUVAVideo : public FragmentTexBlendMode {
792 public:
793 FragmentShaderYUVAVideo();
794 std::string GetShaderString(
795 TexCoordPrecision precision, SamplerType sampler) const;
796 static std::string GetShaderHead();
797 static std::string GetShaderBody();
799 void Init(gpu::gles2::GLES2Interface* context,
800 unsigned program,
801 int* base_uniform_index);
803 int y_texture_location() const { return y_texture_location_; }
804 int u_texture_location() const { return u_texture_location_; }
805 int v_texture_location() const { return v_texture_location_; }
806 int a_texture_location() const { return a_texture_location_; }
807 int alpha_location() const { return alpha_location_; }
808 int yuv_matrix_location() const { return yuv_matrix_location_; }
809 int yuv_adj_location() const { return yuv_adj_location_; }
810 int clamp_rect_location() const { return clamp_rect_location_; }
812 private:
813 int y_texture_location_;
814 int u_texture_location_;
815 int v_texture_location_;
816 int a_texture_location_;
817 int alpha_location_;
818 int yuv_matrix_location_;
819 int yuv_adj_location_;
820 int clamp_rect_location_;
822 DISALLOW_COPY_AND_ASSIGN(FragmentShaderYUVAVideo);
825 class FragmentShaderColor : public FragmentTexBlendMode {
826 public:
827 FragmentShaderColor();
828 std::string GetShaderString(
829 TexCoordPrecision precision, SamplerType sampler) const;
830 static std::string GetShaderHead();
831 static std::string GetShaderBody();
833 void Init(gpu::gles2::GLES2Interface* context,
834 unsigned program,
835 int* base_uniform_index);
836 int color_location() const { return color_location_; }
838 private:
839 int color_location_;
841 DISALLOW_COPY_AND_ASSIGN(FragmentShaderColor);
844 class FragmentShaderColorAA : public FragmentTexBlendMode {
845 public:
846 FragmentShaderColorAA();
847 std::string GetShaderString(
848 TexCoordPrecision precision, SamplerType sampler) const;
849 static std::string GetShaderHead();
850 static std::string GetShaderBody();
852 void Init(gpu::gles2::GLES2Interface* context,
853 unsigned program,
854 int* base_uniform_index);
855 int color_location() const { return color_location_; }
857 private:
858 int color_location_;
860 DISALLOW_COPY_AND_ASSIGN(FragmentShaderColorAA);
863 class FragmentShaderCheckerboard : public FragmentTexBlendMode {
864 public:
865 FragmentShaderCheckerboard();
866 std::string GetShaderString(
867 TexCoordPrecision precision, SamplerType sampler) const;
868 static std::string GetShaderHead();
869 static std::string GetShaderBody();
871 void Init(gpu::gles2::GLES2Interface* context,
872 unsigned program,
873 int* base_uniform_index);
874 int alpha_location() const { return alpha_location_; }
875 int tex_transform_location() const { return tex_transform_location_; }
876 int frequency_location() const { return frequency_location_; }
877 int color_location() const { return color_location_; }
879 private:
880 int alpha_location_;
881 int tex_transform_location_;
882 int frequency_location_;
883 int color_location_;
885 DISALLOW_COPY_AND_ASSIGN(FragmentShaderCheckerboard);
888 } // namespace cc
890 #endif // CC_OUTPUT_SHADER_H_