OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_OUTPUT_SHADER_H_ | 5 #ifndef CC_OUTPUT_SHADER_H_ |
6 #define CC_OUTPUT_SHADER_H_ | 6 #define CC_OUTPUT_SHADER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 BLEND_MODE_DIFFERENCE, | 52 BLEND_MODE_DIFFERENCE, |
53 BLEND_MODE_EXCLUSION, | 53 BLEND_MODE_EXCLUSION, |
54 BLEND_MODE_MULTIPLY, | 54 BLEND_MODE_MULTIPLY, |
55 BLEND_MODE_HUE, | 55 BLEND_MODE_HUE, |
56 BLEND_MODE_SATURATION, | 56 BLEND_MODE_SATURATION, |
57 BLEND_MODE_COLOR, | 57 BLEND_MODE_COLOR, |
58 BLEND_MODE_LUMINOSITY, | 58 BLEND_MODE_LUMINOSITY, |
59 LAST_BLEND_MODE = BLEND_MODE_LUMINOSITY | 59 LAST_BLEND_MODE = BLEND_MODE_LUMINOSITY |
60 }; | 60 }; |
61 | 61 |
| 62 struct ShaderLocations { |
| 63 ShaderLocations(); |
| 64 |
| 65 int sampler = -1; |
| 66 int quad = -1; |
| 67 int edge = -1; |
| 68 int viewport = -1; |
| 69 int mask_sampler = -1; |
| 70 int mask_tex_coord_scale = -1; |
| 71 int mask_tex_coord_offset = -1; |
| 72 int matrix = -1; |
| 73 int alpha = -1; |
| 74 int color_matrix = -1; |
| 75 int color_offset = -1; |
| 76 int tex_transform = -1; |
| 77 int backdrop = -1; |
| 78 int backdrop_rect = -1; |
| 79 }; |
| 80 |
62 // Note: The highp_threshold_cache must be provided by the caller to make | 81 // Note: The highp_threshold_cache must be provided by the caller to make |
63 // the caching multi-thread/context safe in an easy low-overhead manner. | 82 // the caching multi-thread/context safe in an easy low-overhead manner. |
64 // The caller must make sure to clear highp_threshold_cache to 0, so it can be | 83 // The caller must make sure to clear highp_threshold_cache to 0, so it can be |
65 // reinitialized, if a new or different context is used. | 84 // reinitialized, if a new or different context is used. |
66 CC_EXPORT TexCoordPrecision | 85 CC_EXPORT TexCoordPrecision |
67 TexCoordPrecisionRequired(gpu::gles2::GLES2Interface* context, | 86 TexCoordPrecisionRequired(gpu::gles2::GLES2Interface* context, |
68 int* highp_threshold_cache, | 87 int* highp_threshold_cache, |
69 int highp_threshold_min, | 88 int highp_threshold_min, |
70 const gfx::Point& max_coordinate); | 89 const gfx::Point& max_coordinate); |
71 | 90 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 class VertexShaderPosTexTransform { | 168 class VertexShaderPosTexTransform { |
150 public: | 169 public: |
151 VertexShaderPosTexTransform(); | 170 VertexShaderPosTexTransform(); |
152 | 171 |
153 void Init(gpu::gles2::GLES2Interface* context, | 172 void Init(gpu::gles2::GLES2Interface* context, |
154 unsigned program, | 173 unsigned program, |
155 int* base_uniform_index); | 174 int* base_uniform_index); |
156 std::string GetShaderString() const; | 175 std::string GetShaderString() const; |
157 static std::string GetShaderHead(); | 176 static std::string GetShaderHead(); |
158 static std::string GetShaderBody(); | 177 static std::string GetShaderBody(); |
| 178 void FillLocations(ShaderLocations* locations) const; |
159 | 179 |
160 int matrix_location() const { return matrix_location_; } | 180 int matrix_location() const { return matrix_location_; } |
161 int tex_transform_location() const { return tex_transform_location_; } | 181 int tex_transform_location() const { return tex_transform_location_; } |
162 int vertex_opacity_location() const { return vertex_opacity_location_; } | 182 int vertex_opacity_location() const { return vertex_opacity_location_; } |
163 | 183 |
164 private: | 184 private: |
165 int matrix_location_; | 185 int matrix_location_; |
166 int tex_transform_location_; | 186 int tex_transform_location_; |
167 int vertex_opacity_location_; | 187 int vertex_opacity_location_; |
168 | 188 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 class VertexShaderQuadTexTransformAA { | 241 class VertexShaderQuadTexTransformAA { |
222 public: | 242 public: |
223 VertexShaderQuadTexTransformAA(); | 243 VertexShaderQuadTexTransformAA(); |
224 | 244 |
225 void Init(gpu::gles2::GLES2Interface* context, | 245 void Init(gpu::gles2::GLES2Interface* context, |
226 unsigned program, | 246 unsigned program, |
227 int* base_uniform_index); | 247 int* base_uniform_index); |
228 std::string GetShaderString() const; | 248 std::string GetShaderString() const; |
229 static std::string GetShaderHead(); | 249 static std::string GetShaderHead(); |
230 static std::string GetShaderBody(); | 250 static std::string GetShaderBody(); |
| 251 void FillLocations(ShaderLocations* locations) const; |
231 | 252 |
232 int matrix_location() const { return matrix_location_; } | 253 int matrix_location() const { return matrix_location_; } |
233 int viewport_location() const { return viewport_location_; } | 254 int viewport_location() const { return viewport_location_; } |
234 int quad_location() const { return quad_location_; } | 255 int quad_location() const { return quad_location_; } |
235 int edge_location() const { return edge_location_; } | 256 int edge_location() const { return edge_location_; } |
236 int tex_transform_location() const { return tex_transform_location_; } | 257 int tex_transform_location() const { return tex_transform_location_; } |
237 | 258 |
238 private: | 259 private: |
239 int matrix_location_; | 260 int matrix_location_; |
240 int viewport_location_; | 261 int viewport_location_; |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 static std::string GetShaderHead(); | 474 static std::string GetShaderHead(); |
454 static std::string GetShaderBody(); | 475 static std::string GetShaderBody(); |
455 }; | 476 }; |
456 | 477 |
457 class FragmentShaderRGBATexAlpha : public FragmentTexAlphaBinding { | 478 class FragmentShaderRGBATexAlpha : public FragmentTexAlphaBinding { |
458 public: | 479 public: |
459 std::string GetShaderString( | 480 std::string GetShaderString( |
460 TexCoordPrecision precision, SamplerType sampler) const; | 481 TexCoordPrecision precision, SamplerType sampler) const; |
461 static std::string GetShaderHead(); | 482 static std::string GetShaderHead(); |
462 static std::string GetShaderBody(); | 483 static std::string GetShaderBody(); |
| 484 void FillLocations(ShaderLocations* locations) const; |
463 }; | 485 }; |
464 | 486 |
465 class FragmentShaderRGBATexColorMatrixAlpha | 487 class FragmentShaderRGBATexColorMatrixAlpha |
466 : public FragmentTexColorMatrixAlphaBinding { | 488 : public FragmentTexColorMatrixAlphaBinding { |
467 public: | 489 public: |
468 std::string GetShaderString(TexCoordPrecision precision, | 490 std::string GetShaderString(TexCoordPrecision precision, |
469 SamplerType sampler) const; | 491 SamplerType sampler) const; |
470 static std::string GetShaderHead(); | 492 static std::string GetShaderHead(); |
471 static std::string GetShaderBody(); | 493 static std::string GetShaderBody(); |
| 494 void FillLocations(ShaderLocations* locations) const; |
472 }; | 495 }; |
473 | 496 |
474 class FragmentShaderRGBATexOpaque : public FragmentTexOpaqueBinding { | 497 class FragmentShaderRGBATexOpaque : public FragmentTexOpaqueBinding { |
475 public: | 498 public: |
476 std::string GetShaderString( | 499 std::string GetShaderString( |
477 TexCoordPrecision precision, SamplerType sampler) const; | 500 TexCoordPrecision precision, SamplerType sampler) const; |
478 static std::string GetShaderHead(); | 501 static std::string GetShaderHead(); |
479 static std::string GetShaderBody(); | 502 static std::string GetShaderBody(); |
480 }; | 503 }; |
481 | 504 |
(...skipping 27 matching lines...) Expand all Loading... |
509 public: | 532 public: |
510 FragmentShaderRGBATexAlphaAA(); | 533 FragmentShaderRGBATexAlphaAA(); |
511 | 534 |
512 void Init(gpu::gles2::GLES2Interface* context, | 535 void Init(gpu::gles2::GLES2Interface* context, |
513 unsigned program, | 536 unsigned program, |
514 int* base_uniform_index); | 537 int* base_uniform_index); |
515 std::string GetShaderString( | 538 std::string GetShaderString( |
516 TexCoordPrecision precision, SamplerType sampler) const; | 539 TexCoordPrecision precision, SamplerType sampler) const; |
517 static std::string GetShaderHead(); | 540 static std::string GetShaderHead(); |
518 static std::string GetShaderBody(); | 541 static std::string GetShaderBody(); |
| 542 void FillLocations(ShaderLocations* locations) const; |
519 | 543 |
520 int alpha_location() const { return alpha_location_; } | 544 int alpha_location() const { return alpha_location_; } |
521 int sampler_location() const { return sampler_location_; } | 545 int sampler_location() const { return sampler_location_; } |
522 | 546 |
523 private: | 547 private: |
524 int sampler_location_; | 548 int sampler_location_; |
525 int alpha_location_; | 549 int alpha_location_; |
526 | 550 |
527 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaAA); | 551 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaAA); |
528 }; | 552 }; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 static std::string GetShaderBody(); | 591 static std::string GetShaderBody(); |
568 }; | 592 }; |
569 | 593 |
570 class FragmentShaderRGBATexAlphaMask : public FragmentTexBlendMode { | 594 class FragmentShaderRGBATexAlphaMask : public FragmentTexBlendMode { |
571 public: | 595 public: |
572 FragmentShaderRGBATexAlphaMask(); | 596 FragmentShaderRGBATexAlphaMask(); |
573 std::string GetShaderString( | 597 std::string GetShaderString( |
574 TexCoordPrecision precision, SamplerType sampler) const; | 598 TexCoordPrecision precision, SamplerType sampler) const; |
575 static std::string GetShaderHead(); | 599 static std::string GetShaderHead(); |
576 static std::string GetShaderBody(); | 600 static std::string GetShaderBody(); |
577 | 601 void FillLocations(ShaderLocations* locations) const; |
578 void Init(gpu::gles2::GLES2Interface* context, | 602 void Init(gpu::gles2::GLES2Interface* context, |
579 unsigned program, | 603 unsigned program, |
580 int* base_uniform_index); | 604 int* base_uniform_index); |
581 int alpha_location() const { return alpha_location_; } | 605 int alpha_location() const { return alpha_location_; } |
582 int sampler_location() const { return sampler_location_; } | 606 int sampler_location() const { return sampler_location_; } |
583 int mask_sampler_location() const { return mask_sampler_location_; } | 607 int mask_sampler_location() const { return mask_sampler_location_; } |
584 int mask_tex_coord_scale_location() const { | 608 int mask_tex_coord_scale_location() const { |
585 return mask_tex_coord_scale_location_; | 609 return mask_tex_coord_scale_location_; |
586 } | 610 } |
587 int mask_tex_coord_offset_location() const { | 611 int mask_tex_coord_offset_location() const { |
(...skipping 10 matching lines...) Expand all Loading... |
598 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaMask); | 622 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaMask); |
599 }; | 623 }; |
600 | 624 |
601 class FragmentShaderRGBATexAlphaMaskAA : public FragmentTexBlendMode { | 625 class FragmentShaderRGBATexAlphaMaskAA : public FragmentTexBlendMode { |
602 public: | 626 public: |
603 FragmentShaderRGBATexAlphaMaskAA(); | 627 FragmentShaderRGBATexAlphaMaskAA(); |
604 std::string GetShaderString( | 628 std::string GetShaderString( |
605 TexCoordPrecision precision, SamplerType sampler) const; | 629 TexCoordPrecision precision, SamplerType sampler) const; |
606 static std::string GetShaderHead(); | 630 static std::string GetShaderHead(); |
607 static std::string GetShaderBody(); | 631 static std::string GetShaderBody(); |
608 | 632 void FillLocations(ShaderLocations* locations) const; |
609 void Init(gpu::gles2::GLES2Interface* context, | 633 void Init(gpu::gles2::GLES2Interface* context, |
610 unsigned program, | 634 unsigned program, |
611 int* base_uniform_index); | 635 int* base_uniform_index); |
612 int alpha_location() const { return alpha_location_; } | 636 int alpha_location() const { return alpha_location_; } |
613 int sampler_location() const { return sampler_location_; } | 637 int sampler_location() const { return sampler_location_; } |
614 int mask_sampler_location() const { return mask_sampler_location_; } | 638 int mask_sampler_location() const { return mask_sampler_location_; } |
615 int mask_tex_coord_scale_location() const { | 639 int mask_tex_coord_scale_location() const { |
616 return mask_tex_coord_scale_location_; | 640 return mask_tex_coord_scale_location_; |
617 } | 641 } |
618 int mask_tex_coord_offset_location() const { | 642 int mask_tex_coord_offset_location() const { |
(...skipping 11 matching lines...) Expand all Loading... |
630 }; | 654 }; |
631 | 655 |
632 class FragmentShaderRGBATexAlphaMaskColorMatrixAA | 656 class FragmentShaderRGBATexAlphaMaskColorMatrixAA |
633 : public FragmentTexBlendMode { | 657 : public FragmentTexBlendMode { |
634 public: | 658 public: |
635 FragmentShaderRGBATexAlphaMaskColorMatrixAA(); | 659 FragmentShaderRGBATexAlphaMaskColorMatrixAA(); |
636 std::string GetShaderString( | 660 std::string GetShaderString( |
637 TexCoordPrecision precision, SamplerType sampler) const; | 661 TexCoordPrecision precision, SamplerType sampler) const; |
638 static std::string GetShaderHead(); | 662 static std::string GetShaderHead(); |
639 static std::string GetShaderBody(); | 663 static std::string GetShaderBody(); |
640 | 664 void FillLocations(ShaderLocations* locations) const; |
641 void Init(gpu::gles2::GLES2Interface* context, | 665 void Init(gpu::gles2::GLES2Interface* context, |
642 unsigned program, | 666 unsigned program, |
643 int* base_uniform_index); | 667 int* base_uniform_index); |
644 int alpha_location() const { return alpha_location_; } | 668 int alpha_location() const { return alpha_location_; } |
645 int sampler_location() const { return sampler_location_; } | 669 int sampler_location() const { return sampler_location_; } |
646 int mask_sampler_location() const { return mask_sampler_location_; } | 670 int mask_sampler_location() const { return mask_sampler_location_; } |
647 int mask_tex_coord_scale_location() const { | 671 int mask_tex_coord_scale_location() const { |
648 return mask_tex_coord_scale_location_; | 672 return mask_tex_coord_scale_location_; |
649 } | 673 } |
650 int mask_tex_coord_offset_location() const { | 674 int mask_tex_coord_offset_location() const { |
(...skipping 12 matching lines...) Expand all Loading... |
663 int color_offset_location_; | 687 int color_offset_location_; |
664 }; | 688 }; |
665 | 689 |
666 class FragmentShaderRGBATexAlphaColorMatrixAA : public FragmentTexBlendMode { | 690 class FragmentShaderRGBATexAlphaColorMatrixAA : public FragmentTexBlendMode { |
667 public: | 691 public: |
668 FragmentShaderRGBATexAlphaColorMatrixAA(); | 692 FragmentShaderRGBATexAlphaColorMatrixAA(); |
669 std::string GetShaderString( | 693 std::string GetShaderString( |
670 TexCoordPrecision precision, SamplerType sampler) const; | 694 TexCoordPrecision precision, SamplerType sampler) const; |
671 static std::string GetShaderHead(); | 695 static std::string GetShaderHead(); |
672 static std::string GetShaderBody(); | 696 static std::string GetShaderBody(); |
673 | 697 void FillLocations(ShaderLocations* locations) const; |
674 void Init(gpu::gles2::GLES2Interface* context, | 698 void Init(gpu::gles2::GLES2Interface* context, |
675 unsigned program, | 699 unsigned program, |
676 int* base_uniform_index); | 700 int* base_uniform_index); |
677 int alpha_location() const { return alpha_location_; } | 701 int alpha_location() const { return alpha_location_; } |
678 int sampler_location() const { return sampler_location_; } | 702 int sampler_location() const { return sampler_location_; } |
679 int color_matrix_location() const { return color_matrix_location_; } | 703 int color_matrix_location() const { return color_matrix_location_; } |
680 int color_offset_location() const { return color_offset_location_; } | 704 int color_offset_location() const { return color_offset_location_; } |
681 | 705 |
682 private: | 706 private: |
683 int sampler_location_; | 707 int sampler_location_; |
684 int alpha_location_; | 708 int alpha_location_; |
685 int color_matrix_location_; | 709 int color_matrix_location_; |
686 int color_offset_location_; | 710 int color_offset_location_; |
687 }; | 711 }; |
688 | 712 |
689 class FragmentShaderRGBATexAlphaMaskColorMatrix : public FragmentTexBlendMode { | 713 class FragmentShaderRGBATexAlphaMaskColorMatrix : public FragmentTexBlendMode { |
690 public: | 714 public: |
691 FragmentShaderRGBATexAlphaMaskColorMatrix(); | 715 FragmentShaderRGBATexAlphaMaskColorMatrix(); |
692 std::string GetShaderString( | 716 std::string GetShaderString( |
693 TexCoordPrecision precision, SamplerType sampler) const; | 717 TexCoordPrecision precision, SamplerType sampler) const; |
694 static std::string GetShaderHead(); | 718 static std::string GetShaderHead(); |
695 static std::string GetShaderBody(); | 719 static std::string GetShaderBody(); |
696 | 720 void FillLocations(ShaderLocations* locations) const; |
697 void Init(gpu::gles2::GLES2Interface* context, | 721 void Init(gpu::gles2::GLES2Interface* context, |
698 unsigned program, | 722 unsigned program, |
699 int* base_uniform_index); | 723 int* base_uniform_index); |
700 int alpha_location() const { return alpha_location_; } | 724 int alpha_location() const { return alpha_location_; } |
701 int sampler_location() const { return sampler_location_; } | 725 int sampler_location() const { return sampler_location_; } |
702 int mask_sampler_location() const { return mask_sampler_location_; } | 726 int mask_sampler_location() const { return mask_sampler_location_; } |
703 int mask_tex_coord_scale_location() const { | 727 int mask_tex_coord_scale_location() const { |
704 return mask_tex_coord_scale_location_; | 728 return mask_tex_coord_scale_location_; |
705 } | 729 } |
706 int mask_tex_coord_offset_location() const { | 730 int mask_tex_coord_offset_location() const { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 int tex_transform_location_; | 867 int tex_transform_location_; |
844 int frequency_location_; | 868 int frequency_location_; |
845 int color_location_; | 869 int color_location_; |
846 | 870 |
847 DISALLOW_COPY_AND_ASSIGN(FragmentShaderCheckerboard); | 871 DISALLOW_COPY_AND_ASSIGN(FragmentShaderCheckerboard); |
848 }; | 872 }; |
849 | 873 |
850 } // namespace cc | 874 } // namespace cc |
851 | 875 |
852 #endif // CC_OUTPUT_SHADER_H_ | 876 #endif // CC_OUTPUT_SHADER_H_ |
OLD | NEW |