Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: cc/output/shader.h

Issue 988693005: Chromium roll (https://codereview.chromium.org/976353002) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fixed bad android build patch Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/output/renderer_pixeltest.cc ('k') | cc/output/shader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 enum MaskMode {
63 NO_MASK = 0,
64 HAS_MASK = 1,
65 LAST_MASK_VALUE = HAS_MASK
66 };
67
68 struct ShaderLocations {
69 ShaderLocations();
70
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;
86 };
87
62 // Note: The highp_threshold_cache must be provided by the caller to make 88 // 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. 89 // 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 90 // 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. 91 // reinitialized, if a new or different context is used.
66 CC_EXPORT TexCoordPrecision 92 CC_EXPORT TexCoordPrecision
67 TexCoordPrecisionRequired(gpu::gles2::GLES2Interface* context, 93 TexCoordPrecisionRequired(gpu::gles2::GLES2Interface* context,
68 int* highp_threshold_cache, 94 int* highp_threshold_cache,
69 int highp_threshold_min, 95 int highp_threshold_min,
70 const gfx::Point& max_coordinate); 96 const gfx::Point& max_coordinate);
71 97
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 class VertexShaderPosTexTransform { 175 class VertexShaderPosTexTransform {
150 public: 176 public:
151 VertexShaderPosTexTransform(); 177 VertexShaderPosTexTransform();
152 178
153 void Init(gpu::gles2::GLES2Interface* context, 179 void Init(gpu::gles2::GLES2Interface* context,
154 unsigned program, 180 unsigned program,
155 int* base_uniform_index); 181 int* base_uniform_index);
156 std::string GetShaderString() const; 182 std::string GetShaderString() const;
157 static std::string GetShaderHead(); 183 static std::string GetShaderHead();
158 static std::string GetShaderBody(); 184 static std::string GetShaderBody();
185 void FillLocations(ShaderLocations* locations) const;
159 186
160 int matrix_location() const { return matrix_location_; } 187 int matrix_location() const { return matrix_location_; }
161 int tex_transform_location() const { return tex_transform_location_; } 188 int tex_transform_location() const { return tex_transform_location_; }
162 int vertex_opacity_location() const { return vertex_opacity_location_; } 189 int vertex_opacity_location() const { return vertex_opacity_location_; }
163 190
164 private: 191 private:
165 int matrix_location_; 192 int matrix_location_;
166 int tex_transform_location_; 193 int tex_transform_location_;
167 int vertex_opacity_location_; 194 int vertex_opacity_location_;
168 195
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 class VertexShaderQuadTexTransformAA { 248 class VertexShaderQuadTexTransformAA {
222 public: 249 public:
223 VertexShaderQuadTexTransformAA(); 250 VertexShaderQuadTexTransformAA();
224 251
225 void Init(gpu::gles2::GLES2Interface* context, 252 void Init(gpu::gles2::GLES2Interface* context,
226 unsigned program, 253 unsigned program,
227 int* base_uniform_index); 254 int* base_uniform_index);
228 std::string GetShaderString() const; 255 std::string GetShaderString() const;
229 static std::string GetShaderHead(); 256 static std::string GetShaderHead();
230 static std::string GetShaderBody(); 257 static std::string GetShaderBody();
258 void FillLocations(ShaderLocations* locations) const;
231 259
232 int matrix_location() const { return matrix_location_; } 260 int matrix_location() const { return matrix_location_; }
233 int viewport_location() const { return viewport_location_; } 261 int viewport_location() const { return viewport_location_; }
234 int quad_location() const { return quad_location_; } 262 int quad_location() const { return quad_location_; }
235 int edge_location() const { return edge_location_; } 263 int edge_location() const { return edge_location_; }
236 int tex_transform_location() const { return tex_transform_location_; } 264 int tex_transform_location() const { return tex_transform_location_; }
237 265
238 private: 266 private:
239 int matrix_location_; 267 int matrix_location_;
240 int viewport_location_; 268 int viewport_location_;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 private: 346 private:
319 int matrix_location_; 347 int matrix_location_;
320 int tex_matrix_location_; 348 int tex_matrix_location_;
321 349
322 DISALLOW_COPY_AND_ASSIGN(VertexShaderVideoTransform); 350 DISALLOW_COPY_AND_ASSIGN(VertexShaderVideoTransform);
323 }; 351 };
324 352
325 class FragmentTexBlendMode { 353 class FragmentTexBlendMode {
326 public: 354 public:
327 int backdrop_location() const { return backdrop_location_; } 355 int backdrop_location() const { return backdrop_location_; }
356 int original_backdrop_location() const { return original_backdrop_location_; }
328 int backdrop_rect_location() const { return backdrop_rect_location_; } 357 int backdrop_rect_location() const { return backdrop_rect_location_; }
329 358
330 BlendMode blend_mode() const { return blend_mode_; } 359 BlendMode blend_mode() const { return blend_mode_; }
331 void set_blend_mode(BlendMode blend_mode) { blend_mode_ = blend_mode; } 360 void set_blend_mode(BlendMode blend_mode) { blend_mode_ = blend_mode; }
332 bool has_blend_mode() const { return blend_mode_ != BLEND_MODE_NONE; } 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;
364 }
365 bool mask_for_background() const { return mask_for_background_; }
333 366
334 protected: 367 protected:
335 FragmentTexBlendMode(); 368 FragmentTexBlendMode();
336 369
337 std::string SetBlendModeFunctions(std::string shader_string) const; 370 std::string SetBlendModeFunctions(std::string shader_string) const;
338 371
339 int backdrop_location_; 372 int backdrop_location_;
373 int original_backdrop_location_;
340 int backdrop_rect_location_; 374 int backdrop_rect_location_;
341 375
342 private: 376 private:
343 BlendMode blend_mode_; 377 BlendMode blend_mode_;
378 bool mask_for_background_;
344 379
345 std::string GetHelperFunctions() const; 380 std::string GetHelperFunctions() const;
346 std::string GetBlendFunction() const; 381 std::string GetBlendFunction() const;
347 std::string GetBlendFunctionBodyForRGB() const; 382 std::string GetBlendFunctionBodyForRGB() const;
348 }; 383 };
349 384
350 class FragmentTexAlphaBinding : public FragmentTexBlendMode { 385 class FragmentTexAlphaBinding : public FragmentTexBlendMode {
351 public: 386 public:
352 FragmentTexAlphaBinding(); 387 FragmentTexAlphaBinding();
353 388
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 static std::string GetShaderHead(); 488 static std::string GetShaderHead();
454 static std::string GetShaderBody(); 489 static std::string GetShaderBody();
455 }; 490 };
456 491
457 class FragmentShaderRGBATexAlpha : public FragmentTexAlphaBinding { 492 class FragmentShaderRGBATexAlpha : public FragmentTexAlphaBinding {
458 public: 493 public:
459 std::string GetShaderString( 494 std::string GetShaderString(
460 TexCoordPrecision precision, SamplerType sampler) const; 495 TexCoordPrecision precision, SamplerType sampler) const;
461 static std::string GetShaderHead(); 496 static std::string GetShaderHead();
462 static std::string GetShaderBody(); 497 static std::string GetShaderBody();
498 void FillLocations(ShaderLocations* locations) const;
463 }; 499 };
464 500
465 class FragmentShaderRGBATexColorMatrixAlpha 501 class FragmentShaderRGBATexColorMatrixAlpha
466 : public FragmentTexColorMatrixAlphaBinding { 502 : public FragmentTexColorMatrixAlphaBinding {
467 public: 503 public:
468 std::string GetShaderString(TexCoordPrecision precision, 504 std::string GetShaderString(TexCoordPrecision precision,
469 SamplerType sampler) const; 505 SamplerType sampler) const;
470 static std::string GetShaderHead(); 506 static std::string GetShaderHead();
471 static std::string GetShaderBody(); 507 static std::string GetShaderBody();
508 void FillLocations(ShaderLocations* locations) const;
472 }; 509 };
473 510
474 class FragmentShaderRGBATexOpaque : public FragmentTexOpaqueBinding { 511 class FragmentShaderRGBATexOpaque : public FragmentTexOpaqueBinding {
475 public: 512 public:
476 std::string GetShaderString( 513 std::string GetShaderString(
477 TexCoordPrecision precision, SamplerType sampler) const; 514 TexCoordPrecision precision, SamplerType sampler) const;
478 static std::string GetShaderHead(); 515 static std::string GetShaderHead();
479 static std::string GetShaderBody(); 516 static std::string GetShaderBody();
480 }; 517 };
481 518
(...skipping 27 matching lines...) Expand all
509 public: 546 public:
510 FragmentShaderRGBATexAlphaAA(); 547 FragmentShaderRGBATexAlphaAA();
511 548
512 void Init(gpu::gles2::GLES2Interface* context, 549 void Init(gpu::gles2::GLES2Interface* context,
513 unsigned program, 550 unsigned program,
514 int* base_uniform_index); 551 int* base_uniform_index);
515 std::string GetShaderString( 552 std::string GetShaderString(
516 TexCoordPrecision precision, SamplerType sampler) const; 553 TexCoordPrecision precision, SamplerType sampler) const;
517 static std::string GetShaderHead(); 554 static std::string GetShaderHead();
518 static std::string GetShaderBody(); 555 static std::string GetShaderBody();
556 void FillLocations(ShaderLocations* locations) const;
519 557
520 int alpha_location() const { return alpha_location_; } 558 int alpha_location() const { return alpha_location_; }
521 int sampler_location() const { return sampler_location_; } 559 int sampler_location() const { return sampler_location_; }
522 560
523 private: 561 private:
524 int sampler_location_; 562 int sampler_location_;
525 int alpha_location_; 563 int alpha_location_;
526 564
527 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaAA); 565 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaAA);
528 }; 566 };
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 static std::string GetShaderBody(); 605 static std::string GetShaderBody();
568 }; 606 };
569 607
570 class FragmentShaderRGBATexAlphaMask : public FragmentTexBlendMode { 608 class FragmentShaderRGBATexAlphaMask : public FragmentTexBlendMode {
571 public: 609 public:
572 FragmentShaderRGBATexAlphaMask(); 610 FragmentShaderRGBATexAlphaMask();
573 std::string GetShaderString( 611 std::string GetShaderString(
574 TexCoordPrecision precision, SamplerType sampler) const; 612 TexCoordPrecision precision, SamplerType sampler) const;
575 static std::string GetShaderHead(); 613 static std::string GetShaderHead();
576 static std::string GetShaderBody(); 614 static std::string GetShaderBody();
577 615 void FillLocations(ShaderLocations* locations) const;
578 void Init(gpu::gles2::GLES2Interface* context, 616 void Init(gpu::gles2::GLES2Interface* context,
579 unsigned program, 617 unsigned program,
580 int* base_uniform_index); 618 int* base_uniform_index);
581 int alpha_location() const { return alpha_location_; } 619 int alpha_location() const { return alpha_location_; }
582 int sampler_location() const { return sampler_location_; } 620 int sampler_location() const { return sampler_location_; }
583 int mask_sampler_location() const { return mask_sampler_location_; } 621 int mask_sampler_location() const { return mask_sampler_location_; }
584 int mask_tex_coord_scale_location() const { 622 int mask_tex_coord_scale_location() const {
585 return mask_tex_coord_scale_location_; 623 return mask_tex_coord_scale_location_;
586 } 624 }
587 int mask_tex_coord_offset_location() const { 625 int mask_tex_coord_offset_location() const {
(...skipping 10 matching lines...) Expand all
598 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaMask); 636 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaMask);
599 }; 637 };
600 638
601 class FragmentShaderRGBATexAlphaMaskAA : public FragmentTexBlendMode { 639 class FragmentShaderRGBATexAlphaMaskAA : public FragmentTexBlendMode {
602 public: 640 public:
603 FragmentShaderRGBATexAlphaMaskAA(); 641 FragmentShaderRGBATexAlphaMaskAA();
604 std::string GetShaderString( 642 std::string GetShaderString(
605 TexCoordPrecision precision, SamplerType sampler) const; 643 TexCoordPrecision precision, SamplerType sampler) const;
606 static std::string GetShaderHead(); 644 static std::string GetShaderHead();
607 static std::string GetShaderBody(); 645 static std::string GetShaderBody();
608 646 void FillLocations(ShaderLocations* locations) const;
609 void Init(gpu::gles2::GLES2Interface* context, 647 void Init(gpu::gles2::GLES2Interface* context,
610 unsigned program, 648 unsigned program,
611 int* base_uniform_index); 649 int* base_uniform_index);
612 int alpha_location() const { return alpha_location_; } 650 int alpha_location() const { return alpha_location_; }
613 int sampler_location() const { return sampler_location_; } 651 int sampler_location() const { return sampler_location_; }
614 int mask_sampler_location() const { return mask_sampler_location_; } 652 int mask_sampler_location() const { return mask_sampler_location_; }
615 int mask_tex_coord_scale_location() const { 653 int mask_tex_coord_scale_location() const {
616 return mask_tex_coord_scale_location_; 654 return mask_tex_coord_scale_location_;
617 } 655 }
618 int mask_tex_coord_offset_location() const { 656 int mask_tex_coord_offset_location() const {
(...skipping 11 matching lines...) Expand all
630 }; 668 };
631 669
632 class FragmentShaderRGBATexAlphaMaskColorMatrixAA 670 class FragmentShaderRGBATexAlphaMaskColorMatrixAA
633 : public FragmentTexBlendMode { 671 : public FragmentTexBlendMode {
634 public: 672 public:
635 FragmentShaderRGBATexAlphaMaskColorMatrixAA(); 673 FragmentShaderRGBATexAlphaMaskColorMatrixAA();
636 std::string GetShaderString( 674 std::string GetShaderString(
637 TexCoordPrecision precision, SamplerType sampler) const; 675 TexCoordPrecision precision, SamplerType sampler) const;
638 static std::string GetShaderHead(); 676 static std::string GetShaderHead();
639 static std::string GetShaderBody(); 677 static std::string GetShaderBody();
640 678 void FillLocations(ShaderLocations* locations) const;
641 void Init(gpu::gles2::GLES2Interface* context, 679 void Init(gpu::gles2::GLES2Interface* context,
642 unsigned program, 680 unsigned program,
643 int* base_uniform_index); 681 int* base_uniform_index);
644 int alpha_location() const { return alpha_location_; } 682 int alpha_location() const { return alpha_location_; }
645 int sampler_location() const { return sampler_location_; } 683 int sampler_location() const { return sampler_location_; }
646 int mask_sampler_location() const { return mask_sampler_location_; } 684 int mask_sampler_location() const { return mask_sampler_location_; }
647 int mask_tex_coord_scale_location() const { 685 int mask_tex_coord_scale_location() const {
648 return mask_tex_coord_scale_location_; 686 return mask_tex_coord_scale_location_;
649 } 687 }
650 int mask_tex_coord_offset_location() const { 688 int mask_tex_coord_offset_location() const {
(...skipping 12 matching lines...) Expand all
663 int color_offset_location_; 701 int color_offset_location_;
664 }; 702 };
665 703
666 class FragmentShaderRGBATexAlphaColorMatrixAA : public FragmentTexBlendMode { 704 class FragmentShaderRGBATexAlphaColorMatrixAA : public FragmentTexBlendMode {
667 public: 705 public:
668 FragmentShaderRGBATexAlphaColorMatrixAA(); 706 FragmentShaderRGBATexAlphaColorMatrixAA();
669 std::string GetShaderString( 707 std::string GetShaderString(
670 TexCoordPrecision precision, SamplerType sampler) const; 708 TexCoordPrecision precision, SamplerType sampler) const;
671 static std::string GetShaderHead(); 709 static std::string GetShaderHead();
672 static std::string GetShaderBody(); 710 static std::string GetShaderBody();
673 711 void FillLocations(ShaderLocations* locations) const;
674 void Init(gpu::gles2::GLES2Interface* context, 712 void Init(gpu::gles2::GLES2Interface* context,
675 unsigned program, 713 unsigned program,
676 int* base_uniform_index); 714 int* base_uniform_index);
677 int alpha_location() const { return alpha_location_; } 715 int alpha_location() const { return alpha_location_; }
678 int sampler_location() const { return sampler_location_; } 716 int sampler_location() const { return sampler_location_; }
679 int color_matrix_location() const { return color_matrix_location_; } 717 int color_matrix_location() const { return color_matrix_location_; }
680 int color_offset_location() const { return color_offset_location_; } 718 int color_offset_location() const { return color_offset_location_; }
681 719
682 private: 720 private:
683 int sampler_location_; 721 int sampler_location_;
684 int alpha_location_; 722 int alpha_location_;
685 int color_matrix_location_; 723 int color_matrix_location_;
686 int color_offset_location_; 724 int color_offset_location_;
687 }; 725 };
688 726
689 class FragmentShaderRGBATexAlphaMaskColorMatrix : public FragmentTexBlendMode { 727 class FragmentShaderRGBATexAlphaMaskColorMatrix : public FragmentTexBlendMode {
690 public: 728 public:
691 FragmentShaderRGBATexAlphaMaskColorMatrix(); 729 FragmentShaderRGBATexAlphaMaskColorMatrix();
692 std::string GetShaderString( 730 std::string GetShaderString(
693 TexCoordPrecision precision, SamplerType sampler) const; 731 TexCoordPrecision precision, SamplerType sampler) const;
694 static std::string GetShaderHead(); 732 static std::string GetShaderHead();
695 static std::string GetShaderBody(); 733 static std::string GetShaderBody();
696 734 void FillLocations(ShaderLocations* locations) const;
697 void Init(gpu::gles2::GLES2Interface* context, 735 void Init(gpu::gles2::GLES2Interface* context,
698 unsigned program, 736 unsigned program,
699 int* base_uniform_index); 737 int* base_uniform_index);
700 int alpha_location() const { return alpha_location_; } 738 int alpha_location() const { return alpha_location_; }
701 int sampler_location() const { return sampler_location_; } 739 int sampler_location() const { return sampler_location_; }
702 int mask_sampler_location() const { return mask_sampler_location_; } 740 int mask_sampler_location() const { return mask_sampler_location_; }
703 int mask_tex_coord_scale_location() const { 741 int mask_tex_coord_scale_location() const {
704 return mask_tex_coord_scale_location_; 742 return mask_tex_coord_scale_location_;
705 } 743 }
706 int mask_tex_coord_offset_location() const { 744 int mask_tex_coord_offset_location() const {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 int tex_transform_location_; 881 int tex_transform_location_;
844 int frequency_location_; 882 int frequency_location_;
845 int color_location_; 883 int color_location_;
846 884
847 DISALLOW_COPY_AND_ASSIGN(FragmentShaderCheckerboard); 885 DISALLOW_COPY_AND_ASSIGN(FragmentShaderCheckerboard);
848 }; 886 };
849 887
850 } // namespace cc 888 } // namespace cc
851 889
852 #endif // CC_OUTPUT_SHADER_H_ 890 #endif // CC_OUTPUT_SHADER_H_
OLDNEW
« no previous file with comments | « cc/output/renderer_pixeltest.cc ('k') | cc/output/shader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698