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 FragmentTexOpaqueBinding : public FragmentTexBlendMode { | 427 class FragmentTexQuadBase : public FragmentTexBlendMode { |
428 public: | 428 public: |
429 FragmentTexOpaqueBinding(); | 429 FragmentTexQuadBase() = default; |
| 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; |
430 | 446 |
431 void Init(gpu::gles2::GLES2Interface* context, | 447 void Init(gpu::gles2::GLES2Interface* context, |
432 unsigned program, | 448 unsigned program, |
433 int* base_uniform_index); | 449 int* base_uniform_index); |
434 int alpha_location() const { return -1; } | 450 int tex_clamp_rect_location() const final; |
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_; } | |
438 | 451 |
439 private: | 452 private: |
440 int sampler_location_; | 453 int tex_clamp_rect_location_ = -1; |
441 | 454 |
442 DISALLOW_COPY_AND_ASSIGN(FragmentTexOpaqueBinding); | 455 DISALLOW_COPY_AND_ASSIGN(FragmentTexClampBinding); |
443 }; | 456 }; |
444 | 457 |
445 class FragmentTexBackgroundBinding : public FragmentTexBlendMode { | 458 class FragmentTexBackgroundBinding : public FragmentTexQuadBase { |
446 public: | 459 public: |
447 FragmentTexBackgroundBinding(); | 460 FragmentTexBackgroundBinding(); |
448 | 461 |
449 void Init(gpu::gles2::GLES2Interface* context, | 462 void Init(gpu::gles2::GLES2Interface* context, |
450 unsigned program, | 463 unsigned program, |
451 int* base_uniform_index); | 464 int* base_uniform_index); |
452 int background_color_location() const { return background_color_location_; } | 465 int background_color_location() const final; |
453 int sampler_location() const { return sampler_location_; } | |
454 | 466 |
455 private: | 467 private: |
456 int background_color_location_; | 468 int background_color_location_; |
457 int sampler_location_; | |
458 | 469 |
459 DISALLOW_COPY_AND_ASSIGN(FragmentTexBackgroundBinding); | 470 DISALLOW_COPY_AND_ASSIGN(FragmentTexBackgroundBinding); |
460 }; | 471 }; |
461 | 472 |
462 class FragmentShaderRGBATexVaryingAlpha : public FragmentTexOpaqueBinding { | 473 class FragmentShaderRGBATexClampVaryingAlpha : public FragmentTexClampBinding { |
463 public: | 474 public: |
464 std::string GetShaderString( | 475 std::string GetShaderString( |
465 TexCoordPrecision precision, SamplerType sampler) const; | 476 TexCoordPrecision precision, SamplerType sampler) const; |
466 static std::string GetShaderHead(); | 477 static std::string GetShaderHead(); |
467 static std::string GetShaderBody(); | 478 static std::string GetShaderBody(); |
468 }; | 479 }; |
469 | 480 |
470 class FragmentShaderRGBATexPremultiplyAlpha : public FragmentTexOpaqueBinding { | 481 class FragmentShaderRGBATexClampPremultiplyAlpha |
| 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 { |
471 public: | 491 public: |
472 std::string GetShaderString( | 492 std::string GetShaderString( |
473 TexCoordPrecision precision, SamplerType sampler) const; | 493 TexCoordPrecision precision, SamplerType sampler) const; |
474 static std::string GetShaderHead(); | 494 static std::string GetShaderHead(); |
475 static std::string GetShaderBody(); | 495 static std::string GetShaderBody(); |
476 }; | 496 }; |
477 | 497 |
478 class FragmentShaderTexBackgroundVaryingAlpha | 498 class FragmentShaderTexBackgroundVaryingAlpha |
479 : public FragmentTexBackgroundBinding { | 499 : public FragmentTexBackgroundBinding { |
480 public: | 500 public: |
(...skipping 24 matching lines...) Expand all Loading... |
505 class FragmentShaderRGBATexColorMatrixAlpha | 525 class FragmentShaderRGBATexColorMatrixAlpha |
506 : public FragmentTexColorMatrixAlphaBinding { | 526 : public FragmentTexColorMatrixAlphaBinding { |
507 public: | 527 public: |
508 std::string GetShaderString(TexCoordPrecision precision, | 528 std::string GetShaderString(TexCoordPrecision precision, |
509 SamplerType sampler) const; | 529 SamplerType sampler) const; |
510 static std::string GetShaderHead(); | 530 static std::string GetShaderHead(); |
511 static std::string GetShaderBody(); | 531 static std::string GetShaderBody(); |
512 void FillLocations(ShaderLocations* locations) const; | 532 void FillLocations(ShaderLocations* locations) const; |
513 }; | 533 }; |
514 | 534 |
| 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 |
515 class FragmentShaderRGBATexOpaque : public FragmentTexOpaqueBinding { | 552 class FragmentShaderRGBATexOpaque : public FragmentTexOpaqueBinding { |
516 public: | 553 public: |
517 std::string GetShaderString( | 554 std::string GetShaderString( |
518 TexCoordPrecision precision, SamplerType sampler) const; | 555 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; | |
527 static std::string GetShaderHead(); | 556 static std::string GetShaderHead(); |
528 static std::string GetShaderBody(); | 557 static std::string GetShaderBody(); |
529 }; | 558 }; |
530 | 559 |
531 // Swizzles the red and blue component of sampled texel with alpha. | 560 // Swizzles the red and blue component of sampled texel with alpha. |
532 class FragmentShaderRGBATexSwizzleAlpha : public FragmentTexAlphaBinding { | 561 class FragmentShaderRGBATexSwizzleAlpha : public FragmentTexAlphaBinding { |
533 public: | 562 public: |
534 std::string GetShaderString( | 563 std::string GetShaderString( |
535 TexCoordPrecision precision, SamplerType sampler) const; | 564 TexCoordPrecision precision, SamplerType sampler) const; |
536 static std::string GetShaderHead(); | 565 static std::string GetShaderHead(); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 | 873 |
845 private: | 874 private: |
846 int color_location_; | 875 int color_location_; |
847 | 876 |
848 DISALLOW_COPY_AND_ASSIGN(FragmentShaderColorAA); | 877 DISALLOW_COPY_AND_ASSIGN(FragmentShaderColorAA); |
849 }; | 878 }; |
850 | 879 |
851 } // namespace cc | 880 } // namespace cc |
852 | 881 |
853 #endif // CC_OUTPUT_SHADER_H_ | 882 #endif // CC_OUTPUT_SHADER_H_ |
OLD | NEW |