@@ -338,6 +338,9 @@ std::optional<Entity> BlendFilterContents::CreateForegroundAdvancedBlend(
338338 case BlendMode::kColor :
339339 pass.SetPipeline (renderer.GetBlendColorPipeline (options));
340340 break ;
341+ case BlendMode::kPlusAdvanced :
342+ pass.SetPipeline (renderer.GetBlendPlusAdvancedPipeline (options));
343+ break ;
341344 case BlendMode::kLuminosity :
342345 pass.SetPipeline (renderer.GetBlendLuminosityPipeline (options));
343346 break ;
@@ -546,7 +549,7 @@ static std::optional<Entity> PipelineBlend(
546549
547550#define BLEND_CASE (mode ) \
548551 case BlendMode::k##mode: \
549- advanced_blend_proc_ = \
552+ return \
550553 [](const FilterInput::Vector& inputs, const ContentContext& renderer, \
551554 const Entity& entity, const Rect& coverage, BlendMode blend_mode, \
552555 std::optional<Color> fg_color, \
@@ -559,35 +562,39 @@ static std::optional<Entity> PipelineBlend(
559562 }; \
560563 break ;
561564
565+ namespace {
566+ BlendFilterContents::AdvancedBlendProc GetAdvancedBlendProc (
567+ BlendMode blend_mode) {
568+ switch (blend_mode) {
569+ BLEND_CASE (Screen)
570+ BLEND_CASE (Overlay)
571+ BLEND_CASE (Darken)
572+ BLEND_CASE (Lighten)
573+ BLEND_CASE (ColorDodge)
574+ BLEND_CASE (ColorBurn)
575+ BLEND_CASE (HardLight)
576+ BLEND_CASE (SoftLight)
577+ BLEND_CASE (Difference)
578+ BLEND_CASE (Exclusion)
579+ BLEND_CASE (Multiply)
580+ BLEND_CASE (Hue)
581+ BLEND_CASE (Saturation)
582+ BLEND_CASE (Color)
583+ BLEND_CASE (PlusAdvanced)
584+ BLEND_CASE (Luminosity)
585+ default :
586+ FML_UNREACHABLE ();
587+ }
588+ }
589+ } // namespace
590+
562591void BlendFilterContents::SetBlendMode (BlendMode blend_mode) {
563592 if (blend_mode > Entity::kLastAdvancedBlendMode ) {
564593 VALIDATION_LOG << " Invalid blend mode " << static_cast <int >(blend_mode)
565594 << " assigned to BlendFilterContents." ;
566595 }
567596
568597 blend_mode_ = blend_mode;
569-
570- if (blend_mode > Entity::kLastPipelineBlendMode ) {
571- switch (blend_mode) {
572- BLEND_CASE (Screen)
573- BLEND_CASE (Overlay)
574- BLEND_CASE (Darken)
575- BLEND_CASE (Lighten)
576- BLEND_CASE (ColorDodge)
577- BLEND_CASE (ColorBurn)
578- BLEND_CASE (HardLight)
579- BLEND_CASE (SoftLight)
580- BLEND_CASE (Difference)
581- BLEND_CASE (Exclusion)
582- BLEND_CASE (Multiply)
583- BLEND_CASE (Hue)
584- BLEND_CASE (Saturation)
585- BLEND_CASE (Color)
586- BLEND_CASE (Luminosity)
587- default :
588- FML_UNREACHABLE ();
589- }
590- }
591598}
592599
593600void BlendFilterContents::SetForegroundColor (std::optional<Color> color) {
@@ -611,21 +618,29 @@ std::optional<Entity> BlendFilterContents::RenderFilter(
611618 std::nullopt , GetAbsorbOpacity (), GetAlpha ());
612619 }
613620
614- if (blend_mode_ <= Entity::kLastPipelineBlendMode ) {
615- return PipelineBlend (inputs, renderer, entity, coverage, blend_mode_,
621+ BlendMode blend_mode = blend_mode_;
622+ if (blend_mode == BlendMode::kPlus &&
623+ !IsAlphaClampedToOne (
624+ renderer.GetContext ()->GetCapabilities ()->GetDefaultColorFormat ())) {
625+ blend_mode = BlendMode::kPlusAdvanced ;
626+ }
627+
628+ if (blend_mode <= Entity::kLastPipelineBlendMode ) {
629+ return PipelineBlend (inputs, renderer, entity, coverage, blend_mode,
616630 foreground_color_, GetAbsorbOpacity (), GetAlpha ());
617631 }
618632
619- if (blend_mode_ <= Entity::kLastAdvancedBlendMode ) {
633+ if (blend_mode <= Entity::kLastAdvancedBlendMode ) {
620634 if (inputs.size () == 1 && foreground_color_.has_value () &&
621635 GetAbsorbOpacity () == ColorFilterContents::AbsorbOpacity::kYes ) {
622636 return CreateForegroundAdvancedBlend (
623637 inputs[0 ], renderer, entity, coverage, foreground_color_.value (),
624- blend_mode_ , GetAlpha (), GetAbsorbOpacity ());
638+ blend_mode , GetAlpha (), GetAbsorbOpacity ());
625639 }
626- return advanced_blend_proc_ (inputs, renderer, entity, coverage, blend_mode_,
627- foreground_color_, GetAbsorbOpacity (),
628- GetAlpha ());
640+ AdvancedBlendProc advanced_blend_proc = GetAdvancedBlendProc (blend_mode);
641+ return advanced_blend_proc (inputs, renderer, entity, coverage, blend_mode,
642+ foreground_color_, GetAbsorbOpacity (),
643+ GetAlpha ());
629644 }
630645
631646 FML_UNREACHABLE ();
0 commit comments