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