|
15 | 15 | #include "impeller/base/validation.h" |
16 | 16 | #include "impeller/core/formats.h" |
17 | 17 | #include "impeller/core/host_buffer.h" |
| 18 | +#include "impeller/geometry/color.h" |
18 | 19 | #include "impeller/renderer/capabilities.h" |
19 | 20 | #include "impeller/renderer/command_buffer.h" |
20 | 21 | #include "impeller/renderer/pipeline.h" |
@@ -522,8 +523,121 @@ class ContentContext { |
522 | 523 | return GetPipeline(yuv_to_rgb_filter_pipelines_, opts); |
523 | 524 | } |
524 | 525 |
|
525 | | - PipelineRef GetPorterDuffBlendPipeline(ContentContextOptions opts) const { |
526 | | - return GetPipeline(porter_duff_blend_pipelines_, opts); |
| 526 | + // Porter-Duff combined blends. |
| 527 | + PipelineRef GetPorterDuffPipeline(BlendMode mode, |
| 528 | + ContentContextOptions opts) const { |
| 529 | + switch (mode) { |
| 530 | + case BlendMode::kClear: |
| 531 | + return GetClearBlendPipeline(opts); |
| 532 | + case BlendMode::kSource: |
| 533 | + return GetSourceBlendPipeline(opts); |
| 534 | + case BlendMode::kDestination: |
| 535 | + return GetDestinationBlendPipeline(opts); |
| 536 | + case BlendMode::kSourceOver: |
| 537 | + return GetSourceOverBlendPipeline(opts); |
| 538 | + case BlendMode::kDestinationOver: |
| 539 | + return GetDestinationOverBlendPipeline(opts); |
| 540 | + case BlendMode::kSourceIn: |
| 541 | + return GetSourceInBlendPipeline(opts); |
| 542 | + case BlendMode::kDestinationIn: |
| 543 | + return GetDestinationInBlendPipeline(opts); |
| 544 | + case BlendMode::kSourceOut: |
| 545 | + return GetSourceOutBlendPipeline(opts); |
| 546 | + case BlendMode::kDestinationOut: |
| 547 | + return GetDestinationOutBlendPipeline(opts); |
| 548 | + case BlendMode::kSourceATop: |
| 549 | + return GetSourceATopBlendPipeline(opts); |
| 550 | + case BlendMode::kDestinationATop: |
| 551 | + return GetDestinationATopBlendPipeline(opts); |
| 552 | + case BlendMode::kXor: |
| 553 | + return GetXorBlendPipeline(opts); |
| 554 | + case BlendMode::kPlus: |
| 555 | + return GetPlusBlendPipeline(opts); |
| 556 | + case BlendMode::kModulate: |
| 557 | + return GetModulateBlendPipeline(opts); |
| 558 | + case BlendMode::kScreen: |
| 559 | + return GetScreenBlendPipeline(opts); |
| 560 | + case BlendMode::kOverlay: |
| 561 | + case BlendMode::kDarken: |
| 562 | + case BlendMode::kLighten: |
| 563 | + case BlendMode::kColorDodge: |
| 564 | + case BlendMode::kColorBurn: |
| 565 | + case BlendMode::kHardLight: |
| 566 | + case BlendMode::kSoftLight: |
| 567 | + case BlendMode::kDifference: |
| 568 | + case BlendMode::kExclusion: |
| 569 | + case BlendMode::kMultiply: |
| 570 | + case BlendMode::kHue: |
| 571 | + case BlendMode::kSaturation: |
| 572 | + case BlendMode::kColor: |
| 573 | + case BlendMode::kLuminosity: |
| 574 | + VALIDATION_LOG << "Invalid porter duff blend mode " |
| 575 | + << BlendModeToString(mode); |
| 576 | + return GetClearBlendPipeline(opts); |
| 577 | + break; |
| 578 | + } |
| 579 | + } |
| 580 | + |
| 581 | + PipelineRef GetClearBlendPipeline(ContentContextOptions opts) const { |
| 582 | + return GetPipeline(clear_blend_pipelines_, opts); |
| 583 | + } |
| 584 | + |
| 585 | + PipelineRef GetSourceBlendPipeline(ContentContextOptions opts) const { |
| 586 | + return GetPipeline(source_blend_pipelines_, opts); |
| 587 | + } |
| 588 | + |
| 589 | + PipelineRef GetDestinationBlendPipeline(ContentContextOptions opts) const { |
| 590 | + return GetPipeline(destination_blend_pipelines_, opts); |
| 591 | + } |
| 592 | + |
| 593 | + PipelineRef GetSourceOverBlendPipeline(ContentContextOptions opts) const { |
| 594 | + return GetPipeline(source_over_blend_pipelines_, opts); |
| 595 | + } |
| 596 | + |
| 597 | + PipelineRef GetDestinationOverBlendPipeline( |
| 598 | + ContentContextOptions opts) const { |
| 599 | + return GetPipeline(destination_over_blend_pipelines_, opts); |
| 600 | + } |
| 601 | + |
| 602 | + PipelineRef GetSourceInBlendPipeline(ContentContextOptions opts) const { |
| 603 | + return GetPipeline(source_in_blend_pipelines_, opts); |
| 604 | + } |
| 605 | + |
| 606 | + PipelineRef GetDestinationInBlendPipeline(ContentContextOptions opts) const { |
| 607 | + return GetPipeline(destination_in_blend_pipelines_, opts); |
| 608 | + } |
| 609 | + |
| 610 | + PipelineRef GetSourceOutBlendPipeline(ContentContextOptions opts) const { |
| 611 | + return GetPipeline(source_out_blend_pipelines_, opts); |
| 612 | + } |
| 613 | + |
| 614 | + PipelineRef GetDestinationOutBlendPipeline(ContentContextOptions opts) const { |
| 615 | + return GetPipeline(destination_out_blend_pipelines_, opts); |
| 616 | + } |
| 617 | + |
| 618 | + PipelineRef GetSourceATopBlendPipeline(ContentContextOptions opts) const { |
| 619 | + return GetPipeline(source_a_top_blend_pipelines_, opts); |
| 620 | + } |
| 621 | + |
| 622 | + PipelineRef GetDestinationATopBlendPipeline( |
| 623 | + ContentContextOptions opts) const { |
| 624 | + return GetPipeline(destination_a_top_blend_pipelines_, opts); |
| 625 | + } |
| 626 | + |
| 627 | + PipelineRef GetXorBlendPipeline(ContentContextOptions opts) const { |
| 628 | + return GetPipeline(xor_blend_pipelines_, opts); |
| 629 | + } |
| 630 | + |
| 631 | + PipelineRef GetPlusBlendPipeline(ContentContextOptions opts) const { |
| 632 | + return GetPipeline(plus_blend_pipelines_, opts); |
| 633 | + } |
| 634 | + |
| 635 | + PipelineRef GetModulateBlendPipeline(ContentContextOptions opts) const { |
| 636 | + return GetPipeline(modulate_blend_pipelines_, opts); |
| 637 | + } |
| 638 | + |
| 639 | + PipelineRef GetScreenBlendPipeline(ContentContextOptions opts) const { |
| 640 | + return GetPipeline(screen_blend_pipelines_, opts); |
527 | 641 | } |
528 | 642 |
|
529 | 643 | // Advanced blends. |
@@ -826,7 +940,7 @@ class ContentContext { |
826 | 940 |
|
827 | 941 | void CreateDefault(const Context& context, |
828 | 942 | const ContentContextOptions& options, |
829 | | - const std::initializer_list<Scalar>& constants = {}) { |
| 943 | + const std::vector<Scalar>& constants = {}) { |
830 | 944 | auto desc = PipelineHandleT::Builder::MakeDefaultPipelineDescriptor( |
831 | 945 | context, constants); |
832 | 946 | if (!desc.has_value()) { |
@@ -916,7 +1030,24 @@ class ContentContext { |
916 | 1030 | mutable Variants<ClipPipeline> clip_pipelines_; |
917 | 1031 | mutable Variants<GlyphAtlasPipeline> glyph_atlas_pipelines_; |
918 | 1032 | mutable Variants<YUVToRGBFilterPipeline> yuv_to_rgb_filter_pipelines_; |
919 | | - mutable Variants<PorterDuffBlendPipeline> porter_duff_blend_pipelines_; |
| 1033 | + |
| 1034 | + // Porter Duff Blends. |
| 1035 | + mutable Variants<PorterDuffBlendPipeline> clear_blend_pipelines_; |
| 1036 | + mutable Variants<PorterDuffBlendPipeline> source_blend_pipelines_; |
| 1037 | + mutable Variants<PorterDuffBlendPipeline> destination_blend_pipelines_; |
| 1038 | + mutable Variants<PorterDuffBlendPipeline> source_over_blend_pipelines_; |
| 1039 | + mutable Variants<PorterDuffBlendPipeline> destination_over_blend_pipelines_; |
| 1040 | + mutable Variants<PorterDuffBlendPipeline> source_in_blend_pipelines_; |
| 1041 | + mutable Variants<PorterDuffBlendPipeline> destination_in_blend_pipelines_; |
| 1042 | + mutable Variants<PorterDuffBlendPipeline> source_out_blend_pipelines_; |
| 1043 | + mutable Variants<PorterDuffBlendPipeline> destination_out_blend_pipelines_; |
| 1044 | + mutable Variants<PorterDuffBlendPipeline> source_a_top_blend_pipelines_; |
| 1045 | + mutable Variants<PorterDuffBlendPipeline> destination_a_top_blend_pipelines_; |
| 1046 | + mutable Variants<PorterDuffBlendPipeline> xor_blend_pipelines_; |
| 1047 | + mutable Variants<PorterDuffBlendPipeline> plus_blend_pipelines_; |
| 1048 | + mutable Variants<PorterDuffBlendPipeline> modulate_blend_pipelines_; |
| 1049 | + mutable Variants<PorterDuffBlendPipeline> screen_blend_pipelines_; |
| 1050 | + |
920 | 1051 | // Advanced blends. |
921 | 1052 | mutable Variants<BlendColorPipeline> blend_color_pipelines_; |
922 | 1053 | mutable Variants<BlendColorBurnPipeline> blend_colorburn_pipelines_; |
|
0 commit comments