| 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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 | 349 |
| 350 private: | 350 private: |
| 351 int matrix_location_; | 351 int matrix_location_; |
| 352 int tex_matrix_location_; | 352 int tex_matrix_location_; |
| 353 | 353 |
| 354 DISALLOW_COPY_AND_ASSIGN(VertexShaderVideoTransform); | 354 DISALLOW_COPY_AND_ASSIGN(VertexShaderVideoTransform); |
| 355 }; | 355 }; |
| 356 | 356 |
| 357 class FragmentShaderBase { | 357 class FragmentShaderBase { |
| 358 public: | 358 public: |
| 359 virtual void Init(gpu::gles2::GLES2Interface* context, |
| 360 unsigned program, |
| 361 int* base_uniform_index); |
| 359 std::string GetShaderString(TexCoordPrecision precision, | 362 std::string GetShaderString(TexCoordPrecision precision, |
| 360 SamplerType sampler) const; | 363 SamplerType sampler) const; |
| 361 | 364 void FillLocations(ShaderLocations* locations) const; |
| 362 int backdrop_location() const { return backdrop_location_; } | |
| 363 int original_backdrop_location() const { return original_backdrop_location_; } | |
| 364 int backdrop_rect_location() const { return backdrop_rect_location_; } | |
| 365 | 365 |
| 366 BlendMode blend_mode() const { return blend_mode_; } | 366 BlendMode blend_mode() const { return blend_mode_; } |
| 367 void set_blend_mode(BlendMode blend_mode) { blend_mode_ = blend_mode; } | 367 void set_blend_mode(BlendMode blend_mode) { blend_mode_ = blend_mode; } |
| 368 bool has_blend_mode() const { return blend_mode_ != BLEND_MODE_NONE; } | 368 bool has_blend_mode() const { return blend_mode_ != BLEND_MODE_NONE; } |
| 369 void set_mask_for_background(bool mask_for_background) { | 369 void set_mask_for_background(bool mask_for_background) { |
| 370 mask_for_background_ = mask_for_background; | 370 mask_for_background_ = mask_for_background; |
| 371 } | 371 } |
| 372 bool mask_for_background() const { return mask_for_background_; } | 372 bool mask_for_background() const { return mask_for_background_; } |
| 373 | 373 |
| 374 int sampler_location() const { return sampler_location_; } |
| 375 int alpha_location() const { return alpha_location_; } |
| 376 int color_location() const { return color_location_; } |
| 377 int background_color_location() const { return background_color_location_; } |
| 378 int fragment_tex_transform_location() const { |
| 379 return fragment_tex_transform_location_; |
| 380 } |
| 381 |
| 374 protected: | 382 protected: |
| 375 FragmentShaderBase(); | 383 FragmentShaderBase(); |
| 376 virtual std::string GetShaderSource() const = 0; | 384 virtual std::string GetShaderSource() const = 0; |
| 377 | 385 |
| 378 std::string SetBlendModeFunctions(const std::string& shader_string) const; | 386 std::string SetBlendModeFunctions(const std::string& shader_string) const; |
| 379 | 387 |
| 380 int backdrop_location_; | 388 // Used only if |blend_mode_| is not BLEND_MODE_NONE. |
| 381 int original_backdrop_location_; | 389 int backdrop_location_ = -1; |
| 382 int backdrop_rect_location_; | 390 int original_backdrop_location_ = -1; |
| 391 int backdrop_rect_location_ = -1; |
| 392 |
| 393 bool has_mask_sampler_ = false; |
| 394 int mask_sampler_location_ = -1; |
| 395 int mask_tex_coord_scale_location_ = -1; |
| 396 int mask_tex_coord_offset_location_ = -1; |
| 397 |
| 398 bool has_color_matrix_ = false; |
| 399 int color_matrix_location_ = -1; |
| 400 int color_offset_location_ = -1; |
| 401 |
| 402 bool has_sampler_ = false; |
| 403 int sampler_location_ = -1; |
| 404 |
| 405 bool has_uniform_alpha_ = false; |
| 406 int alpha_location_ = -1; |
| 407 |
| 408 bool has_background_color_ = false; |
| 409 int background_color_location_ = -1; |
| 410 |
| 411 bool has_fragment_tex_transform_ = false; |
| 412 int fragment_tex_transform_location_ = -1; |
| 413 |
| 414 bool has_uniform_color_ = false; |
| 415 int color_location_ = -1; |
| 383 | 416 |
| 384 private: | 417 private: |
| 385 BlendMode blend_mode_; | 418 BlendMode blend_mode_ = BLEND_MODE_NONE; |
| 386 bool mask_for_background_; | 419 bool mask_for_background_ = false; |
| 387 | 420 |
| 388 std::string GetHelperFunctions() const; | 421 std::string GetHelperFunctions() const; |
| 389 std::string GetBlendFunction() const; | 422 std::string GetBlendFunction() const; |
| 390 std::string GetBlendFunctionBodyForRGB() const; | 423 std::string GetBlendFunctionBodyForRGB() const; |
| 391 }; | 424 }; |
| 392 | 425 |
| 393 class FragmentTexAlphaBinding : public FragmentShaderBase { | 426 class FragmentTexAlphaBinding : public FragmentShaderBase { |
| 394 public: | 427 public: |
| 395 FragmentTexAlphaBinding(); | 428 FragmentTexAlphaBinding() { |
| 396 | 429 has_sampler_ = true; |
| 397 void Init(gpu::gles2::GLES2Interface* context, | 430 has_uniform_alpha_ = true; |
| 398 unsigned program, | 431 } |
| 399 int* base_uniform_index); | |
| 400 int alpha_location() const { return alpha_location_; } | |
| 401 int fragment_tex_transform_location() const { return -1; } | |
| 402 int sampler_location() const { return sampler_location_; } | |
| 403 | 432 |
| 404 private: | 433 private: |
| 405 int sampler_location_; | |
| 406 int alpha_location_; | |
| 407 | |
| 408 DISALLOW_COPY_AND_ASSIGN(FragmentTexAlphaBinding); | 434 DISALLOW_COPY_AND_ASSIGN(FragmentTexAlphaBinding); |
| 409 }; | 435 }; |
| 410 | 436 |
| 411 class FragmentTexColorMatrixAlphaBinding : public FragmentShaderBase { | 437 class FragmentTexColorMatrixAlphaBinding : public FragmentShaderBase { |
| 412 public: | 438 public: |
| 413 FragmentTexColorMatrixAlphaBinding(); | 439 FragmentTexColorMatrixAlphaBinding() { |
| 414 | 440 has_sampler_ = true; |
| 415 void Init(gpu::gles2::GLES2Interface* context, | 441 has_uniform_alpha_ = true; |
| 416 unsigned program, | 442 has_color_matrix_ = true; |
| 417 int* base_uniform_index); | 443 } |
| 418 int alpha_location() const { return alpha_location_; } | |
| 419 int color_matrix_location() const { return color_matrix_location_; } | |
| 420 int color_offset_location() const { return color_offset_location_; } | |
| 421 int fragment_tex_transform_location() const { return -1; } | |
| 422 int sampler_location() const { return sampler_location_; } | |
| 423 | 444 |
| 424 private: | 445 private: |
| 425 int sampler_location_; | |
| 426 int alpha_location_; | |
| 427 int color_matrix_location_; | |
| 428 int color_offset_location_; | |
| 429 }; | 446 }; |
| 430 | 447 |
| 431 class FragmentTexOpaqueBinding : public FragmentShaderBase { | 448 class FragmentTexOpaqueBinding : public FragmentShaderBase { |
| 432 public: | 449 public: |
| 433 FragmentTexOpaqueBinding(); | 450 FragmentTexOpaqueBinding() { has_sampler_ = true; } |
| 434 | |
| 435 void Init(gpu::gles2::GLES2Interface* context, | |
| 436 unsigned program, | |
| 437 int* base_uniform_index); | |
| 438 int alpha_location() const { return -1; } | |
| 439 int fragment_tex_transform_location() const { return -1; } | |
| 440 int background_color_location() const { return -1; } | |
| 441 int sampler_location() const { return sampler_location_; } | |
| 442 | 451 |
| 443 private: | 452 private: |
| 444 int sampler_location_; | |
| 445 | |
| 446 DISALLOW_COPY_AND_ASSIGN(FragmentTexOpaqueBinding); | 453 DISALLOW_COPY_AND_ASSIGN(FragmentTexOpaqueBinding); |
| 447 }; | 454 }; |
| 448 | 455 |
| 449 class FragmentTexBackgroundBinding : public FragmentShaderBase { | 456 class FragmentTexBackgroundBinding : public FragmentShaderBase { |
| 450 public: | 457 public: |
| 451 FragmentTexBackgroundBinding(); | 458 FragmentTexBackgroundBinding() { |
| 452 | 459 has_sampler_ = true; |
| 453 void Init(gpu::gles2::GLES2Interface* context, | 460 has_background_color_ = true; |
| 454 unsigned program, | 461 } |
| 455 int* base_uniform_index); | |
| 456 int background_color_location() const { return background_color_location_; } | |
| 457 int sampler_location() const { return sampler_location_; } | |
| 458 | 462 |
| 459 private: | 463 private: |
| 460 int background_color_location_; | |
| 461 int sampler_location_; | |
| 462 | |
| 463 DISALLOW_COPY_AND_ASSIGN(FragmentTexBackgroundBinding); | 464 DISALLOW_COPY_AND_ASSIGN(FragmentTexBackgroundBinding); |
| 464 }; | 465 }; |
| 465 | 466 |
| 466 class FragmentShaderRGBATexVaryingAlpha : public FragmentTexOpaqueBinding { | 467 class FragmentShaderRGBATexVaryingAlpha : public FragmentTexOpaqueBinding { |
| 467 private: | 468 private: |
| 468 std::string GetShaderSource() const override; | 469 std::string GetShaderSource() const override; |
| 469 }; | 470 }; |
| 470 | 471 |
| 471 class FragmentShaderRGBATexPremultiplyAlpha : public FragmentTexOpaqueBinding { | 472 class FragmentShaderRGBATexPremultiplyAlpha : public FragmentTexOpaqueBinding { |
| 472 private: | 473 private: |
| 473 std::string GetShaderSource() const override; | 474 std::string GetShaderSource() const override; |
| 474 }; | 475 }; |
| 475 | 476 |
| 476 class FragmentShaderTexBackgroundVaryingAlpha | 477 class FragmentShaderTexBackgroundVaryingAlpha |
| 477 : public FragmentTexBackgroundBinding { | 478 : public FragmentTexBackgroundBinding { |
| 478 private: | 479 private: |
| 479 std::string GetShaderSource() const override; | 480 std::string GetShaderSource() const override; |
| 480 }; | 481 }; |
| 481 | 482 |
| 482 class FragmentShaderTexBackgroundPremultiplyAlpha | 483 class FragmentShaderTexBackgroundPremultiplyAlpha |
| 483 : public FragmentTexBackgroundBinding { | 484 : public FragmentTexBackgroundBinding { |
| 484 private: | 485 private: |
| 485 std::string GetShaderSource() const override; | 486 std::string GetShaderSource() const override; |
| 486 }; | 487 }; |
| 487 | 488 |
| 488 class FragmentShaderRGBATexAlpha : public FragmentTexAlphaBinding { | 489 class FragmentShaderRGBATexAlpha : public FragmentTexAlphaBinding { |
| 489 public: | |
| 490 void FillLocations(ShaderLocations* locations) const; | |
| 491 | |
| 492 private: | 490 private: |
| 493 std::string GetShaderSource() const override; | 491 std::string GetShaderSource() const override; |
| 494 }; | 492 }; |
| 495 | 493 |
| 496 class FragmentShaderRGBATexColorMatrixAlpha | 494 class FragmentShaderRGBATexColorMatrixAlpha |
| 497 : public FragmentTexColorMatrixAlphaBinding { | 495 : public FragmentTexColorMatrixAlphaBinding { |
| 498 public: | |
| 499 void FillLocations(ShaderLocations* locations) const; | |
| 500 | |
| 501 private: | 496 private: |
| 502 std::string GetShaderSource() const override; | 497 std::string GetShaderSource() const override; |
| 503 }; | 498 }; |
| 504 | 499 |
| 505 class FragmentShaderRGBATexOpaque : public FragmentTexOpaqueBinding { | 500 class FragmentShaderRGBATexOpaque : public FragmentTexOpaqueBinding { |
| 506 private: | 501 private: |
| 507 std::string GetShaderSource() const override; | 502 std::string GetShaderSource() const override; |
| 508 }; | 503 }; |
| 509 | 504 |
| 510 class FragmentShaderRGBATex : public FragmentTexOpaqueBinding { | 505 class FragmentShaderRGBATex : public FragmentTexOpaqueBinding { |
| 511 private: | 506 private: |
| 512 std::string GetShaderSource() const override; | 507 std::string GetShaderSource() const override; |
| 513 }; | 508 }; |
| 514 | 509 |
| 515 // Swizzles the red and blue component of sampled texel with alpha. | 510 // Swizzles the red and blue component of sampled texel with alpha. |
| 516 class FragmentShaderRGBATexSwizzleAlpha : public FragmentTexAlphaBinding { | 511 class FragmentShaderRGBATexSwizzleAlpha : public FragmentTexAlphaBinding { |
| 517 private: | 512 private: |
| 518 std::string GetShaderSource() const override; | 513 std::string GetShaderSource() const override; |
| 519 }; | 514 }; |
| 520 | 515 |
| 521 // Swizzles the red and blue component of sampled texel without alpha. | 516 // Swizzles the red and blue component of sampled texel without alpha. |
| 522 class FragmentShaderRGBATexSwizzleOpaque : public FragmentTexOpaqueBinding { | 517 class FragmentShaderRGBATexSwizzleOpaque : public FragmentTexOpaqueBinding { |
| 523 private: | 518 private: |
| 524 std::string GetShaderSource() const override; | 519 std::string GetShaderSource() const override; |
| 525 }; | 520 }; |
| 526 | 521 |
| 527 class FragmentShaderRGBATexAlphaAA : public FragmentShaderBase { | 522 class FragmentShaderRGBATexAlphaAA : public FragmentShaderBase { |
| 528 public: | 523 public: |
| 529 FragmentShaderRGBATexAlphaAA(); | 524 FragmentShaderRGBATexAlphaAA() { |
| 530 | 525 has_sampler_ = true; |
| 531 void Init(gpu::gles2::GLES2Interface* context, | 526 has_uniform_alpha_ = true; |
| 532 unsigned program, | 527 } |
| 533 int* base_uniform_index); | |
| 534 void FillLocations(ShaderLocations* locations) const; | |
| 535 | |
| 536 int alpha_location() const { return alpha_location_; } | |
| 537 int sampler_location() const { return sampler_location_; } | |
| 538 | 528 |
| 539 private: | 529 private: |
| 540 std::string GetShaderSource() const override; | 530 std::string GetShaderSource() const override; |
| 541 int sampler_location_; | |
| 542 int alpha_location_; | |
| 543 | |
| 544 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaAA); | 531 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaAA); |
| 545 }; | 532 }; |
| 546 | 533 |
| 547 class FragmentTexClampAlphaAABinding : public FragmentShaderBase { | 534 class FragmentTexClampAlphaAABinding : public FragmentShaderBase { |
| 548 public: | 535 public: |
| 549 FragmentTexClampAlphaAABinding(); | 536 FragmentTexClampAlphaAABinding() { |
| 550 | 537 has_sampler_ = true; |
| 551 void Init(gpu::gles2::GLES2Interface* context, | 538 has_uniform_alpha_ = true; |
| 552 unsigned program, | 539 has_fragment_tex_transform_ = true; |
| 553 int* base_uniform_index); | |
| 554 int alpha_location() const { return alpha_location_; } | |
| 555 int sampler_location() const { return sampler_location_; } | |
| 556 int fragment_tex_transform_location() const { | |
| 557 return fragment_tex_transform_location_; | |
| 558 } | 540 } |
| 559 | |
| 560 private: | 541 private: |
| 561 int sampler_location_; | |
| 562 int alpha_location_; | |
| 563 int fragment_tex_transform_location_; | |
| 564 | |
| 565 DISALLOW_COPY_AND_ASSIGN(FragmentTexClampAlphaAABinding); | 542 DISALLOW_COPY_AND_ASSIGN(FragmentTexClampAlphaAABinding); |
| 566 }; | 543 }; |
| 567 | 544 |
| 568 class FragmentShaderRGBATexClampAlphaAA | 545 class FragmentShaderRGBATexClampAlphaAA |
| 569 : public FragmentTexClampAlphaAABinding { | 546 : public FragmentTexClampAlphaAABinding { |
| 570 private: | 547 private: |
| 571 std::string GetShaderSource() const override; | 548 std::string GetShaderSource() const override; |
| 572 }; | 549 }; |
| 573 | 550 |
| 574 // Swizzles the red and blue component of sampled texel. | 551 // Swizzles the red and blue component of sampled texel. |
| 575 class FragmentShaderRGBATexClampSwizzleAlphaAA | 552 class FragmentShaderRGBATexClampSwizzleAlphaAA |
| 576 : public FragmentTexClampAlphaAABinding { | 553 : public FragmentTexClampAlphaAABinding { |
| 577 private: | 554 private: |
| 578 std::string GetShaderSource() const override; | 555 std::string GetShaderSource() const override; |
| 579 }; | 556 }; |
| 580 | 557 |
| 581 class FragmentShaderRGBATexAlphaMask : public FragmentShaderBase { | 558 class FragmentShaderRGBATexAlphaMask : public FragmentShaderBase { |
| 582 public: | 559 public: |
| 583 FragmentShaderRGBATexAlphaMask(); | 560 FragmentShaderRGBATexAlphaMask() { |
| 584 void FillLocations(ShaderLocations* locations) const; | 561 has_sampler_ = true; |
| 585 void Init(gpu::gles2::GLES2Interface* context, | 562 has_uniform_alpha_ = true; |
| 586 unsigned program, | 563 has_mask_sampler_ = true; |
| 587 int* base_uniform_index); | |
| 588 int alpha_location() const { return alpha_location_; } | |
| 589 int sampler_location() const { return sampler_location_; } | |
| 590 int mask_sampler_location() const { return mask_sampler_location_; } | |
| 591 int mask_tex_coord_scale_location() const { | |
| 592 return mask_tex_coord_scale_location_; | |
| 593 } | 564 } |
| 594 int mask_tex_coord_offset_location() const { | |
| 595 return mask_tex_coord_offset_location_; | |
| 596 } | |
| 597 | |
| 598 private: | 565 private: |
| 599 std::string GetShaderSource() const override; | 566 std::string GetShaderSource() const override; |
| 600 int sampler_location_; | |
| 601 int mask_sampler_location_; | |
| 602 int alpha_location_; | |
| 603 int mask_tex_coord_scale_location_; | |
| 604 int mask_tex_coord_offset_location_; | |
| 605 | |
| 606 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaMask); | 567 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaMask); |
| 607 }; | 568 }; |
| 608 | 569 |
| 609 class FragmentShaderRGBATexAlphaMaskAA : public FragmentShaderBase { | 570 class FragmentShaderRGBATexAlphaMaskAA : public FragmentShaderBase { |
| 610 public: | 571 public: |
| 611 FragmentShaderRGBATexAlphaMaskAA(); | 572 FragmentShaderRGBATexAlphaMaskAA() { |
| 612 void FillLocations(ShaderLocations* locations) const; | 573 has_sampler_ = true; |
| 613 void Init(gpu::gles2::GLES2Interface* context, | 574 has_uniform_alpha_ = true; |
| 614 unsigned program, | 575 has_mask_sampler_ = true; |
| 615 int* base_uniform_index); | |
| 616 int alpha_location() const { return alpha_location_; } | |
| 617 int sampler_location() const { return sampler_location_; } | |
| 618 int mask_sampler_location() const { return mask_sampler_location_; } | |
| 619 int mask_tex_coord_scale_location() const { | |
| 620 return mask_tex_coord_scale_location_; | |
| 621 } | 576 } |
| 622 int mask_tex_coord_offset_location() const { | |
| 623 return mask_tex_coord_offset_location_; | |
| 624 } | |
| 625 | |
| 626 private: | 577 private: |
| 627 std::string GetShaderSource() const override; | 578 std::string GetShaderSource() const override; |
| 628 int sampler_location_; | |
| 629 int mask_sampler_location_; | |
| 630 int alpha_location_; | |
| 631 int mask_tex_coord_scale_location_; | |
| 632 int mask_tex_coord_offset_location_; | |
| 633 | |
| 634 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaMaskAA); | 579 DISALLOW_COPY_AND_ASSIGN(FragmentShaderRGBATexAlphaMaskAA); |
| 635 }; | 580 }; |
| 636 | 581 |
| 637 class FragmentShaderRGBATexAlphaMaskColorMatrixAA : public FragmentShaderBase { | 582 class FragmentShaderRGBATexAlphaMaskColorMatrixAA : public FragmentShaderBase { |
| 638 public: | 583 public: |
| 639 FragmentShaderRGBATexAlphaMaskColorMatrixAA(); | 584 FragmentShaderRGBATexAlphaMaskColorMatrixAA() { |
| 640 void FillLocations(ShaderLocations* locations) const; | 585 has_sampler_ = true; |
| 641 void Init(gpu::gles2::GLES2Interface* context, | 586 has_uniform_alpha_ = true; |
| 642 unsigned program, | 587 has_mask_sampler_ = true; |
| 643 int* base_uniform_index); | 588 has_color_matrix_ = true; |
| 644 int alpha_location() const { return alpha_location_; } | |
| 645 int sampler_location() const { return sampler_location_; } | |
| 646 int mask_sampler_location() const { return mask_sampler_location_; } | |
| 647 int mask_tex_coord_scale_location() const { | |
| 648 return mask_tex_coord_scale_location_; | |
| 649 } | 589 } |
| 650 int mask_tex_coord_offset_location() const { | |
| 651 return mask_tex_coord_offset_location_; | |
| 652 } | |
| 653 int color_matrix_location() const { return color_matrix_location_; } | |
| 654 int color_offset_location() const { return color_offset_location_; } | |
| 655 | |
| 656 private: | 590 private: |
| 657 std::string GetShaderSource() const override; | 591 std::string GetShaderSource() const override; |
| 658 int sampler_location_; | |
| 659 int mask_sampler_location_; | |
| 660 int alpha_location_; | |
| 661 int mask_tex_coord_scale_location_; | |
| 662 int mask_tex_coord_offset_location_; | |
| 663 int color_matrix_location_; | |
| 664 int color_offset_location_; | |
| 665 }; | 592 }; |
| 666 | 593 |
| 667 class FragmentShaderRGBATexAlphaColorMatrixAA : public FragmentShaderBase { | 594 class FragmentShaderRGBATexAlphaColorMatrixAA : public FragmentShaderBase { |
| 668 public: | 595 public: |
| 669 FragmentShaderRGBATexAlphaColorMatrixAA(); | 596 FragmentShaderRGBATexAlphaColorMatrixAA() { |
| 670 void FillLocations(ShaderLocations* locations) const; | 597 has_sampler_ = true; |
| 671 void Init(gpu::gles2::GLES2Interface* context, | 598 has_uniform_alpha_ = true; |
| 672 unsigned program, | 599 has_color_matrix_ = true; |
| 673 int* base_uniform_index); | 600 } |
| 674 int alpha_location() const { return alpha_location_; } | |
| 675 int sampler_location() const { return sampler_location_; } | |
| 676 int color_matrix_location() const { return color_matrix_location_; } | |
| 677 int color_offset_location() const { return color_offset_location_; } | |
| 678 | 601 |
| 679 private: | 602 private: |
| 680 std::string GetShaderSource() const override; | 603 std::string GetShaderSource() const override; |
| 681 int sampler_location_; | |
| 682 int alpha_location_; | |
| 683 int color_matrix_location_; | |
| 684 int color_offset_location_; | |
| 685 }; | 604 }; |
| 686 | 605 |
| 687 class FragmentShaderRGBATexAlphaMaskColorMatrix : public FragmentShaderBase { | 606 class FragmentShaderRGBATexAlphaMaskColorMatrix : public FragmentShaderBase { |
| 688 public: | 607 public: |
| 689 FragmentShaderRGBATexAlphaMaskColorMatrix(); | 608 FragmentShaderRGBATexAlphaMaskColorMatrix() { |
| 690 void FillLocations(ShaderLocations* locations) const; | 609 has_sampler_ = true; |
| 691 void Init(gpu::gles2::GLES2Interface* context, | 610 has_uniform_alpha_ = true; |
| 692 unsigned program, | 611 has_mask_sampler_ = true; |
| 693 int* base_uniform_index); | 612 has_color_matrix_ = true; |
| 694 int alpha_location() const { return alpha_location_; } | |
| 695 int sampler_location() const { return sampler_location_; } | |
| 696 int mask_sampler_location() const { return mask_sampler_location_; } | |
| 697 int mask_tex_coord_scale_location() const { | |
| 698 return mask_tex_coord_scale_location_; | |
| 699 } | 613 } |
| 700 int mask_tex_coord_offset_location() const { | |
| 701 return mask_tex_coord_offset_location_; | |
| 702 } | |
| 703 int color_matrix_location() const { return color_matrix_location_; } | |
| 704 int color_offset_location() const { return color_offset_location_; } | |
| 705 | |
| 706 private: | 614 private: |
| 707 std::string GetShaderSource() const override; | 615 std::string GetShaderSource() const override; |
| 708 int sampler_location_; | |
| 709 int mask_sampler_location_; | |
| 710 int alpha_location_; | |
| 711 int mask_tex_coord_scale_location_; | |
| 712 int mask_tex_coord_offset_location_; | |
| 713 int color_matrix_location_; | |
| 714 int color_offset_location_; | |
| 715 }; | 616 }; |
| 716 | 617 |
| 717 class FragmentShaderYUVVideo : public FragmentShaderBase { | 618 class FragmentShaderYUVVideo : public FragmentShaderBase { |
| 718 public: | 619 public: |
| 719 FragmentShaderYUVVideo(); | 620 FragmentShaderYUVVideo(); |
| 720 void SetFeatures(bool use_alpha_texture, bool use_nv12, bool use_color_lut); | 621 void SetFeatures(bool use_alpha_texture, bool use_nv12, bool use_color_lut); |
| 721 | 622 |
| 722 void Init(gpu::gles2::GLES2Interface* context, | 623 void Init(gpu::gles2::GLES2Interface* context, |
| 723 unsigned program, | 624 unsigned program, |
| 724 int* base_uniform_index); | 625 int* base_uniform_index) override; |
| 725 int y_texture_location() const { return y_texture_location_; } | 626 int y_texture_location() const { return y_texture_location_; } |
| 726 int u_texture_location() const { return u_texture_location_; } | 627 int u_texture_location() const { return u_texture_location_; } |
| 727 int v_texture_location() const { return v_texture_location_; } | 628 int v_texture_location() const { return v_texture_location_; } |
| 728 int uv_texture_location() const { return uv_texture_location_; } | 629 int uv_texture_location() const { return uv_texture_location_; } |
| 729 int a_texture_location() const { return a_texture_location_; } | 630 int a_texture_location() const { return a_texture_location_; } |
| 730 int lut_texture_location() const { return lut_texture_location_; } | 631 int lut_texture_location() const { return lut_texture_location_; } |
| 731 int alpha_location() const { return alpha_location_; } | 632 int alpha_location() const { return alpha_location_; } |
| 732 int yuv_matrix_location() const { return yuv_matrix_location_; } | 633 int yuv_matrix_location() const { return yuv_matrix_location_; } |
| 733 int yuv_adj_location() const { return yuv_adj_location_; } | 634 int yuv_adj_location() const { return yuv_adj_location_; } |
| 734 int ya_clamp_rect_location() const { return ya_clamp_rect_location_; } | 635 int ya_clamp_rect_location() const { return ya_clamp_rect_location_; } |
| 735 int uv_clamp_rect_location() const { return uv_clamp_rect_location_; } | 636 int uv_clamp_rect_location() const { return uv_clamp_rect_location_; } |
| 736 int resource_multiplier_location() const { | 637 int resource_multiplier_location() const { |
| 737 return resource_multiplier_location_; | 638 return resource_multiplier_location_; |
| 738 } | 639 } |
| 739 int resource_offset_location() const { return resource_offset_location_; } | 640 int resource_offset_location() const { return resource_offset_location_; } |
| 740 | 641 |
| 741 private: | 642 private: |
| 742 std::string GetShaderSource() const override; | 643 std::string GetShaderSource() const override; |
| 743 | 644 |
| 744 bool use_alpha_texture_; | 645 bool use_alpha_texture_ = false; |
| 745 bool use_nv12_; | 646 bool use_nv12_ = false; |
| 746 bool use_color_lut_; | 647 bool use_color_lut_ = false; |
| 747 | 648 |
| 748 int y_texture_location_; | 649 int y_texture_location_ = -1; |
| 749 int u_texture_location_; | 650 int u_texture_location_ = -1; |
| 750 int v_texture_location_; | 651 int v_texture_location_ = -1; |
| 751 int uv_texture_location_; | 652 int uv_texture_location_ = -1; |
| 752 int a_texture_location_; | 653 int a_texture_location_ = -1; |
| 753 int lut_texture_location_; | 654 int lut_texture_location_ = -1; |
| 754 int alpha_location_; | 655 int alpha_location_ = -1; |
| 755 int yuv_matrix_location_; | 656 int yuv_matrix_location_ = -1; |
| 756 int yuv_adj_location_; | 657 int yuv_adj_location_ = -1; |
| 757 int ya_clamp_rect_location_; | 658 int ya_clamp_rect_location_ = -1; |
| 758 int uv_clamp_rect_location_; | 659 int uv_clamp_rect_location_ = -1; |
| 759 int resource_multiplier_location_; | 660 int resource_multiplier_location_ = -1; |
| 760 int resource_offset_location_; | 661 int resource_offset_location_ = -1; |
| 761 | 662 |
| 762 DISALLOW_COPY_AND_ASSIGN(FragmentShaderYUVVideo); | 663 DISALLOW_COPY_AND_ASSIGN(FragmentShaderYUVVideo); |
| 763 }; | 664 }; |
| 764 | 665 |
| 765 class FragmentShaderColor : public FragmentShaderBase { | 666 class FragmentShaderColor : public FragmentShaderBase { |
| 766 public: | 667 public: |
| 767 FragmentShaderColor(); | 668 FragmentShaderColor() { has_uniform_color_ = true; } |
| 768 | |
| 769 void Init(gpu::gles2::GLES2Interface* context, | |
| 770 unsigned program, | |
| 771 int* base_uniform_index); | |
| 772 int color_location() const { return color_location_; } | |
| 773 | 669 |
| 774 private: | 670 private: |
| 775 std::string GetShaderSource() const override; | 671 std::string GetShaderSource() const override; |
| 776 int color_location_; | |
| 777 | |
| 778 DISALLOW_COPY_AND_ASSIGN(FragmentShaderColor); | 672 DISALLOW_COPY_AND_ASSIGN(FragmentShaderColor); |
| 779 }; | 673 }; |
| 780 | 674 |
| 781 class FragmentShaderColorAA : public FragmentShaderBase { | 675 class FragmentShaderColorAA : public FragmentShaderBase { |
| 782 public: | 676 public: |
| 783 FragmentShaderColorAA(); | 677 FragmentShaderColorAA() { has_uniform_color_ = true; } |
| 784 | |
| 785 void Init(gpu::gles2::GLES2Interface* context, | |
| 786 unsigned program, | |
| 787 int* base_uniform_index); | |
| 788 int color_location() const { return color_location_; } | |
| 789 | 678 |
| 790 private: | 679 private: |
| 791 std::string GetShaderSource() const override; | 680 std::string GetShaderSource() const override; |
| 792 int color_location_; | |
| 793 | |
| 794 DISALLOW_COPY_AND_ASSIGN(FragmentShaderColorAA); | 681 DISALLOW_COPY_AND_ASSIGN(FragmentShaderColorAA); |
| 795 }; | 682 }; |
| 796 | 683 |
| 797 } // namespace cc | 684 } // namespace cc |
| 798 | 685 |
| 799 #endif // CC_OUTPUT_SHADER_H_ | 686 #endif // CC_OUTPUT_SHADER_H_ |
| OLD | NEW |