@@ -549,7 +549,7 @@ static std::optional<Entity> PipelineBlend(
549
549
550
550
#define BLEND_CASE (mode ) \
551
551
case BlendMode::k##mode: \
552
- advanced_blend_proc_ = \
552
+ return \
553
553
[](const FilterInput::Vector& inputs, const ContentContext& renderer, \
554
554
const Entity& entity, const Rect & coverage, BlendMode blend_mode, \
555
555
std::optional<Color> fg_color, \
@@ -562,36 +562,39 @@ static std::optional<Entity> PipelineBlend(
562
562
}; \
563
563
break ;
564
564
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
+
565
591
void BlendFilterContents::SetBlendMode (BlendMode blend_mode) {
566
592
if (blend_mode > Entity::kLastAdvancedBlendMode ) {
567
593
VALIDATION_LOG << " Invalid blend mode " << static_cast <int >(blend_mode)
568
594
<< " assigned to BlendFilterContents." ;
569
595
}
570
596
571
597
blend_mode_ = blend_mode;
572
-
573
- if (blend_mode > Entity::kLastPipelineBlendMode ) {
574
- switch (blend_mode) {
575
- BLEND_CASE (Screen)
576
- BLEND_CASE (Overlay)
577
- BLEND_CASE (Darken)
578
- BLEND_CASE (Lighten)
579
- BLEND_CASE (ColorDodge)
580
- BLEND_CASE (ColorBurn)
581
- BLEND_CASE (HardLight)
582
- BLEND_CASE (SoftLight)
583
- BLEND_CASE (Difference)
584
- BLEND_CASE (Exclusion)
585
- BLEND_CASE (Multiply)
586
- BLEND_CASE (Hue)
587
- BLEND_CASE (Saturation)
588
- BLEND_CASE (Color)
589
- BLEND_CASE (PlusAdvanced)
590
- BLEND_CASE (Luminosity)
591
- default :
592
- FML_UNREACHABLE ();
593
- }
594
- }
595
598
}
596
599
597
600
void BlendFilterContents::SetForegroundColor (std::optional<Color> color) {
@@ -634,9 +637,10 @@ std::optional<Entity> BlendFilterContents::RenderFilter(
634
637
inputs[0 ], renderer, entity, coverage, foreground_color_.value (),
635
638
blend_mode, GetAlpha (), GetAbsorbOpacity ());
636
639
}
637
- return advanced_blend_proc_ (inputs, renderer, entity, coverage, blend_mode,
638
- foreground_color_, GetAbsorbOpacity (),
639
- 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 ());
640
644
}
641
645
642
646
FML_UNREACHABLE ();
0 commit comments