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/macros.h" | 10 #include "base/macros.h" |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 int fragment_tex_transform_location() const { return -1; } | 417 int fragment_tex_transform_location() const { return -1; } |
418 int sampler_location() const { return sampler_location_; } | 418 int sampler_location() const { return sampler_location_; } |
419 | 419 |
420 private: | 420 private: |
421 int sampler_location_; | 421 int sampler_location_; |
422 int alpha_location_; | 422 int alpha_location_; |
423 int color_matrix_location_; | 423 int color_matrix_location_; |
424 int color_offset_location_; | 424 int color_offset_location_; |
425 }; | 425 }; |
426 | 426 |
427 class FragmentTexQuadBase : public FragmentTexBlendMode { | 427 class FragmentTexOpaqueBinding : public FragmentTexBlendMode { |
428 public: | 428 public: |
429 FragmentTexQuadBase() = default; | 429 FragmentTexOpaqueBinding(); |
430 virtual ~FragmentTexQuadBase() = default; | |
431 | |
432 int sampler_location() const { return sampler_location_; } | |
433 virtual int background_color_location() const; | |
434 virtual int tex_clamp_rect_location() const; | |
435 | |
436 protected: | |
437 int sampler_location_ = -1; | |
438 | |
439 private: | |
440 DISALLOW_COPY_AND_ASSIGN(FragmentTexQuadBase); | |
441 }; | |
442 | |
443 class FragmentTexClampBinding : public FragmentTexQuadBase { | |
444 public: | |
445 FragmentTexClampBinding() = default; | |
446 | 430 |
447 void Init(gpu::gles2::GLES2Interface* context, | 431 void Init(gpu::gles2::GLES2Interface* context, |
448 unsigned program, | 432 unsigned program, |
449 int* base_uniform_index); | 433 int* base_uniform_index); |
450 int tex_clamp_rect_location() const final; | 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_; } |
451 | 438 |
452 private: | 439 private: |
453 int tex_clamp_rect_location_ = -1; | 440 int sampler_location_; |
454 | 441 |
455 DISALLOW_COPY_AND_ASSIGN(FragmentTexClampBinding); | 442 DISALLOW_COPY_AND_ASSIGN(FragmentTexOpaqueBinding); |
456 }; | 443 }; |
457 | 444 |
458 class FragmentTexBackgroundBinding : public FragmentTexQuadBase { | 445 class FragmentTexBackgroundBinding : public FragmentTexBlendMode { |
459 public: | 446 public: |
460 FragmentTexBackgroundBinding(); | 447 FragmentTexBackgroundBinding(); |
461 | 448 |
462 void Init(gpu::gles2::GLES2Interface* context, | 449 void Init(gpu::gles2::GLES2Interface* context, |
463 unsigned program, | 450 unsigned program, |
464 int* base_uniform_index); | 451 int* base_uniform_index); |
465 int background_color_location() const final; | 452 int background_color_location() const { return background_color_location_; } |
| 453 int sampler_location() const { return sampler_location_; } |
466 | 454 |
467 private: | 455 private: |
468 int background_color_location_; | 456 int background_color_location_; |
| 457 int sampler_location_; |
469 | 458 |
470 DISALLOW_COPY_AND_ASSIGN(FragmentTexBackgroundBinding); | 459 DISALLOW_COPY_AND_ASSIGN(FragmentTexBackgroundBinding); |
471 }; | 460 }; |
472 | 461 |
473 class FragmentShaderRGBATexClampVaryingAlpha : public FragmentTexClampBinding { | 462 class FragmentShaderRGBATexVaryingAlpha : public FragmentTexOpaqueBinding { |
474 public: | 463 public: |
475 std::string GetShaderString( | 464 std::string GetShaderString( |
476 TexCoordPrecision precision, SamplerType sampler) const; | 465 TexCoordPrecision precision, SamplerType sampler) const; |
477 static std::string GetShaderHead(); | 466 static std::string GetShaderHead(); |
478 static std::string GetShaderBody(); | 467 static std::string GetShaderBody(); |
479 }; | 468 }; |
480 | 469 |
481 class FragmentShaderRGBATexClampPremultiplyAlpha | 470 class FragmentShaderRGBATexPremultiplyAlpha : public FragmentTexOpaqueBinding { |
482 : public FragmentTexClampBinding { | |
483 public: | |
484 std::string GetShaderString(TexCoordPrecision precision, | |
485 SamplerType sampler) const; | |
486 static std::string GetShaderHead(); | |
487 static std::string GetShaderBody(); | |
488 }; | |
489 | |
490 class FragmentShaderRGBATexClamp : public FragmentTexClampBinding { | |
491 public: | 471 public: |
492 std::string GetShaderString( | 472 std::string GetShaderString( |
493 TexCoordPrecision precision, SamplerType sampler) const; | 473 TexCoordPrecision precision, SamplerType sampler) const; |
494 static std::string GetShaderHead(); | 474 static std::string GetShaderHead(); |
495 static std::string GetShaderBody(); | 475 static std::string GetShaderBody(); |
496 }; | 476 }; |
497 | 477 |
498 class FragmentShaderTexBackgroundVaryingAlpha | 478 class FragmentShaderTexBackgroundVaryingAlpha |
499 : public FragmentTexBackgroundBinding { | 479 : public FragmentTexBackgroundBinding { |
500 public: | 480 public: |
(...skipping 24 matching lines...) Expand all Loading... |
525 class FragmentShaderRGBATexColorMatrixAlpha | 505 class FragmentShaderRGBATexColorMatrixAlpha |
526 : public FragmentTexColorMatrixAlphaBinding { | 506 : public FragmentTexColorMatrixAlphaBinding { |
527 public: | 507 public: |
528 std::string GetShaderString(TexCoordPrecision precision, | 508 std::string GetShaderString(TexCoordPrecision precision, |
529 SamplerType sampler) const; | 509 SamplerType sampler) const; |
530 static std::string GetShaderHead(); | 510 static std::string GetShaderHead(); |
531 static std::string GetShaderBody(); | 511 static std::string GetShaderBody(); |
532 void FillLocations(ShaderLocations* locations) const; | 512 void FillLocations(ShaderLocations* locations) const; |
533 }; | 513 }; |
534 | 514 |
535 class FragmentTexOpaqueBinding : public FragmentTexBlendMode { | |
536 public: | |
537 FragmentTexOpaqueBinding(); | |
538 | |
539 void Init(gpu::gles2::GLES2Interface* context, | |
540 unsigned program, | |
541 int* base_uniform_index); | |
542 int alpha_location() const { return -1; } | |
543 int fragment_tex_transform_location() const { return -1; } | |
544 int sampler_location() const { return sampler_location_; } | |
545 | |
546 private: | |
547 int sampler_location_; | |
548 | |
549 DISALLOW_COPY_AND_ASSIGN(FragmentTexOpaqueBinding); | |
550 }; | |
551 | |
552 class FragmentShaderRGBATexOpaque : public FragmentTexOpaqueBinding { | 515 class FragmentShaderRGBATexOpaque : public FragmentTexOpaqueBinding { |
553 public: | 516 public: |
554 std::string GetShaderString( | 517 std::string GetShaderString( |
555 TexCoordPrecision precision, SamplerType sampler) const; | 518 TexCoordPrecision precision, SamplerType sampler) const; |
| 519 static std::string GetShaderHead(); |
| 520 static std::string GetShaderBody(); |
| 521 }; |
| 522 |
| 523 class FragmentShaderRGBATex : public FragmentTexOpaqueBinding { |
| 524 public: |
| 525 std::string GetShaderString( |
| 526 TexCoordPrecision precision, SamplerType sampler) const; |
556 static std::string GetShaderHead(); | 527 static std::string GetShaderHead(); |
557 static std::string GetShaderBody(); | 528 static std::string GetShaderBody(); |
558 }; | 529 }; |
559 | 530 |
560 // Swizzles the red and blue component of sampled texel with alpha. | 531 // Swizzles the red and blue component of sampled texel with alpha. |
561 class FragmentShaderRGBATexSwizzleAlpha : public FragmentTexAlphaBinding { | 532 class FragmentShaderRGBATexSwizzleAlpha : public FragmentTexAlphaBinding { |
562 public: | 533 public: |
563 std::string GetShaderString( | 534 std::string GetShaderString( |
564 TexCoordPrecision precision, SamplerType sampler) const; | 535 TexCoordPrecision precision, SamplerType sampler) const; |
565 static std::string GetShaderHead(); | 536 static std::string GetShaderHead(); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 | 844 |
874 private: | 845 private: |
875 int color_location_; | 846 int color_location_; |
876 | 847 |
877 DISALLOW_COPY_AND_ASSIGN(FragmentShaderColorAA); | 848 DISALLOW_COPY_AND_ASSIGN(FragmentShaderColorAA); |
878 }; | 849 }; |
879 | 850 |
880 } // namespace cc | 851 } // namespace cc |
881 | 852 |
882 #endif // CC_OUTPUT_SHADER_H_ | 853 #endif // CC_OUTPUT_SHADER_H_ |
OLD | NEW |