Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 74397bc

Browse files
committed
applied fix
1 parent e18a852 commit 74397bc

File tree

2 files changed

+31
-28
lines changed

2 files changed

+31
-28
lines changed

impeller/entity/contents/filters/blend_filter_contents.cc

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ static std::optional<Entity> PipelineBlend(
549549

550550
#define BLEND_CASE(mode) \
551551
case BlendMode::k##mode: \
552-
advanced_blend_proc_ = \
552+
return \
553553
[](const FilterInput::Vector& inputs, const ContentContext& renderer, \
554554
const Entity& entity, const Rect& coverage, BlendMode blend_mode, \
555555
std::optional<Color> fg_color, \
@@ -562,36 +562,39 @@ static std::optional<Entity> PipelineBlend(
562562
}; \
563563
break;
564564

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+
565591
void BlendFilterContents::SetBlendMode(BlendMode blend_mode) {
566592
if (blend_mode > Entity::kLastAdvancedBlendMode) {
567593
VALIDATION_LOG << "Invalid blend mode " << static_cast<int>(blend_mode)
568594
<< " assigned to BlendFilterContents.";
569595
}
570596

571597
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-
}
595598
}
596599

597600
void BlendFilterContents::SetForegroundColor(std::optional<Color> color) {
@@ -634,9 +637,10 @@ std::optional<Entity> BlendFilterContents::RenderFilter(
634637
inputs[0], renderer, entity, coverage, foreground_color_.value(),
635638
blend_mode, GetAlpha(), GetAbsorbOpacity());
636639
}
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());
640644
}
641645

642646
FML_UNREACHABLE();

impeller/entity/contents/filters/blend_filter_contents.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ class BlendFilterContents : public ColorFilterContents {
7979
ColorFilterContents::AbsorbOpacity absorb_opacity) const;
8080

8181
BlendMode blend_mode_ = BlendMode::kSourceOver;
82-
AdvancedBlendProc advanced_blend_proc_;
8382
std::optional<Color> foreground_color_;
8483

8584
BlendFilterContents(const BlendFilterContents&) = delete;

0 commit comments

Comments
 (0)