@@ -339,9 +339,6 @@ std::optional<Entity> BlendFilterContents::CreateForegroundAdvancedBlend(
339339 case BlendMode::kColor :
340340 pass.SetPipeline (renderer.GetBlendColorPipeline (options));
341341 break ;
342- case BlendMode::kPlusAdvanced :
343- pass.SetPipeline (renderer.GetBlendPlusAdvancedPipeline (options));
344- break ;
345342 case BlendMode::kLuminosity :
346343 pass.SetPipeline (renderer.GetBlendLuminosityPipeline (options));
347344 break ;
@@ -665,7 +662,7 @@ static std::optional<Entity> PipelineBlend(
665662
666663#define BLEND_CASE (mode ) \
667664 case BlendMode::k##mode: \
668- return \
665+ advanced_blend_proc_ = \
669666 [](const FilterInput::Vector& inputs, const ContentContext& renderer, \
670667 const Entity& entity, const Rect& coverage, BlendMode blend_mode, \
671668 std::optional<Color> fg_color, \
@@ -678,39 +675,35 @@ static std::optional<Entity> PipelineBlend(
678675 }; \
679676 break ;
680677
681- namespace {
682- BlendFilterContents::AdvancedBlendProc GetAdvancedBlendProc (
683- BlendMode blend_mode) {
684- switch (blend_mode) {
685- BLEND_CASE (Screen)
686- BLEND_CASE (Overlay)
687- BLEND_CASE (Darken)
688- BLEND_CASE (Lighten)
689- BLEND_CASE (ColorDodge)
690- BLEND_CASE (ColorBurn)
691- BLEND_CASE (HardLight)
692- BLEND_CASE (SoftLight)
693- BLEND_CASE (Difference)
694- BLEND_CASE (Exclusion)
695- BLEND_CASE (Multiply)
696- BLEND_CASE (Hue)
697- BLEND_CASE (Saturation)
698- BLEND_CASE (Color)
699- BLEND_CASE (PlusAdvanced)
700- BLEND_CASE (Luminosity)
701- default :
702- FML_UNREACHABLE ();
703- }
704- }
705- } // namespace
706-
707678void BlendFilterContents::SetBlendMode (BlendMode blend_mode) {
708679 if (blend_mode > Entity::kLastAdvancedBlendMode ) {
709680 VALIDATION_LOG << " Invalid blend mode " << static_cast <int >(blend_mode)
710681 << " assigned to BlendFilterContents." ;
711682 }
712683
713684 blend_mode_ = blend_mode;
685+
686+ if (blend_mode > Entity::kLastPipelineBlendMode ) {
687+ switch (blend_mode) {
688+ BLEND_CASE (Screen)
689+ BLEND_CASE (Overlay)
690+ BLEND_CASE (Darken)
691+ BLEND_CASE (Lighten)
692+ BLEND_CASE (ColorDodge)
693+ BLEND_CASE (ColorBurn)
694+ BLEND_CASE (HardLight)
695+ BLEND_CASE (SoftLight)
696+ BLEND_CASE (Difference)
697+ BLEND_CASE (Exclusion)
698+ BLEND_CASE (Multiply)
699+ BLEND_CASE (Hue)
700+ BLEND_CASE (Saturation)
701+ BLEND_CASE (Color)
702+ BLEND_CASE (Luminosity)
703+ default :
704+ FML_UNREACHABLE ();
705+ }
706+ }
714707}
715708
716709void BlendFilterContents::SetForegroundColor (std::optional<Color> color) {
@@ -734,35 +727,27 @@ std::optional<Entity> BlendFilterContents::RenderFilter(
734727 std::nullopt , GetAbsorbOpacity (), GetAlpha ());
735728 }
736729
737- BlendMode blend_mode = blend_mode_;
738- if (blend_mode == BlendMode::kPlus &&
739- !IsAlphaClampedToOne (
740- renderer.GetContext ()->GetCapabilities ()->GetDefaultColorFormat ())) {
741- blend_mode = BlendMode::kPlusAdvanced ;
742- }
743-
744- if (blend_mode <= Entity::kLastPipelineBlendMode ) {
730+ if (blend_mode_ <= Entity::kLastPipelineBlendMode ) {
745731 if (inputs.size () == 1 && foreground_color_.has_value () &&
746732 GetAbsorbOpacity () == ColorFilterContents::AbsorbOpacity::kYes ) {
747733 return CreateForegroundPorterDuffBlend (
748734 inputs[0 ], renderer, entity, coverage, foreground_color_.value (),
749735 blend_mode_, GetAlpha (), GetAbsorbOpacity ());
750736 }
751- return PipelineBlend (inputs, renderer, entity, coverage, blend_mode ,
737+ return PipelineBlend (inputs, renderer, entity, coverage, blend_mode_ ,
752738 foreground_color_, GetAbsorbOpacity (), GetAlpha ());
753739 }
754740
755- if (blend_mode <= Entity::kLastAdvancedBlendMode ) {
741+ if (blend_mode_ <= Entity::kLastAdvancedBlendMode ) {
756742 if (inputs.size () == 1 && foreground_color_.has_value () &&
757743 GetAbsorbOpacity () == ColorFilterContents::AbsorbOpacity::kYes ) {
758744 return CreateForegroundAdvancedBlend (
759745 inputs[0 ], renderer, entity, coverage, foreground_color_.value (),
760- blend_mode , GetAlpha (), GetAbsorbOpacity ());
746+ blend_mode_ , GetAlpha (), GetAbsorbOpacity ());
761747 }
762- AdvancedBlendProc advanced_blend_proc = GetAdvancedBlendProc (blend_mode);
763- return advanced_blend_proc (inputs, renderer, entity, coverage, blend_mode,
764- foreground_color_, GetAbsorbOpacity (),
765- GetAlpha ());
748+ return advanced_blend_proc_ (inputs, renderer, entity, coverage, blend_mode_,
749+ foreground_color_, GetAbsorbOpacity (),
750+ GetAlpha ());
766751 }
767752
768753 FML_UNREACHABLE ();
0 commit comments