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