From 8b53654118cb5494007e618908126fe0f6ca50d3 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Thu, 14 Sep 2023 13:01:17 -0700 Subject: [PATCH] [Impeller] Add AbsorbOpacity enum. (flutter/engine#45838) Part of https://github.com/flutter/flutter/issues/134681. --- .../src/flutter/impeller/aiks/color_filter.cc | 8 +-- .../src/flutter/impeller/aiks/color_filter.h | 10 +-- .../src/flutter/impeller/aiks/color_source.cc | 5 +- .../src/flutter/impeller/aiks/image_filter.cc | 4 +- engine/src/flutter/impeller/aiks/paint.cc | 9 +-- engine/src/flutter/impeller/aiks/paint.h | 6 +- .../contents/filters/blend_filter_contents.cc | 72 ++++++++++++------- .../contents/filters/blend_filter_contents.h | 22 +++--- .../contents/filters/color_filter_contents.cc | 5 +- .../contents/filters/color_filter_contents.h | 11 ++- .../filters/color_matrix_filter_contents.cc | 6 +- .../filters/linear_to_srgb_filter_contents.cc | 5 +- .../filters/srgb_to_linear_filter_contents.cc | 5 +- 13 files changed, 104 insertions(+), 64 deletions(-) diff --git a/engine/src/flutter/impeller/aiks/color_filter.cc b/engine/src/flutter/impeller/aiks/color_filter.cc index 72868a0c0d..87f7022e1c 100644 --- a/engine/src/flutter/impeller/aiks/color_filter.cc +++ b/engine/src/flutter/impeller/aiks/color_filter.cc @@ -45,7 +45,7 @@ BlendColorFilter::~BlendColorFilter() = default; std::shared_ptr BlendColorFilter::WrapWithGPUColorFilter( std::shared_ptr input, - bool absorb_opacity) const { + ColorFilterContents::AbsorbOpacity absorb_opacity) const { auto filter = ColorFilterContents::MakeBlend(blend_mode_, {std::move(input)}, color_); filter->SetAbsorbOpacity(absorb_opacity); @@ -73,7 +73,7 @@ MatrixColorFilter::~MatrixColorFilter() = default; std::shared_ptr MatrixColorFilter::WrapWithGPUColorFilter( std::shared_ptr input, - bool absorb_opacity) const { + ColorFilterContents::AbsorbOpacity absorb_opacity) const { auto filter = ColorFilterContents::MakeColorMatrix({std::move(input)}, color_matrix_); filter->SetAbsorbOpacity(absorb_opacity); @@ -101,7 +101,7 @@ SrgbToLinearColorFilter::~SrgbToLinearColorFilter() = default; std::shared_ptr SrgbToLinearColorFilter::WrapWithGPUColorFilter( std::shared_ptr input, - bool absorb_opacity) const { + ColorFilterContents::AbsorbOpacity absorb_opacity) const { auto filter = ColorFilterContents::MakeSrgbToLinearFilter({std::move(input)}); filter->SetAbsorbOpacity(absorb_opacity); return filter; @@ -127,7 +127,7 @@ LinearToSrgbColorFilter::~LinearToSrgbColorFilter() = default; std::shared_ptr LinearToSrgbColorFilter::WrapWithGPUColorFilter( std::shared_ptr input, - bool absorb_opacity) const { + ColorFilterContents::AbsorbOpacity absorb_opacity) const { auto filter = ColorFilterContents::MakeSrgbToLinearFilter({std::move(input)}); filter->SetAbsorbOpacity(absorb_opacity); return filter; diff --git a/engine/src/flutter/impeller/aiks/color_filter.h b/engine/src/flutter/impeller/aiks/color_filter.h index 234cbc63c1..1c5bf32dd9 100644 --- a/engine/src/flutter/impeller/aiks/color_filter.h +++ b/engine/src/flutter/impeller/aiks/color_filter.h @@ -43,7 +43,7 @@ class ColorFilter { /// treated as color information. virtual std::shared_ptr WrapWithGPUColorFilter( std::shared_ptr input, - bool absorb_opacity) const = 0; + ColorFilterContents::AbsorbOpacity absorb_opacity) const = 0; /// @brief Returns a function that can be used to filter unpremultiplied /// Impeller Colors on the CPU. @@ -65,7 +65,7 @@ class BlendColorFilter final : public ColorFilter { // |ColorFilter| std::shared_ptr WrapWithGPUColorFilter( std::shared_ptr input, - bool absorb_opacity) const override; + ColorFilterContents::AbsorbOpacity absorb_opacity) const override; // |ColorFilter| ColorFilterProc GetCPUColorFilterProc() const override; @@ -91,7 +91,7 @@ class MatrixColorFilter final : public ColorFilter { // |ColorFilter| std::shared_ptr WrapWithGPUColorFilter( std::shared_ptr input, - bool absorb_opacity) const override; + ColorFilterContents::AbsorbOpacity absorb_opacity) const override; // |ColorFilter| ColorFilterProc GetCPUColorFilterProc() const override; @@ -116,7 +116,7 @@ class SrgbToLinearColorFilter final : public ColorFilter { // |ColorFilter| std::shared_ptr WrapWithGPUColorFilter( std::shared_ptr input, - bool absorb_opacity) const override; + ColorFilterContents::AbsorbOpacity absorb_opacity) const override; // |ColorFilter| ColorFilterProc GetCPUColorFilterProc() const override; @@ -138,7 +138,7 @@ class LinearToSrgbColorFilter final : public ColorFilter { // |ColorFilter| std::shared_ptr WrapWithGPUColorFilter( std::shared_ptr input, - bool absorb_opacity) const override; + ColorFilterContents::AbsorbOpacity absorb_opacity) const override; // |ColorFilter| ColorFilterProc GetCPUColorFilterProc() const override; diff --git a/engine/src/flutter/impeller/aiks/color_source.cc b/engine/src/flutter/impeller/aiks/color_source.cc index 3329bcb4b8..da3191f2d6 100644 --- a/engine/src/flutter/impeller/aiks/color_source.cc +++ b/engine/src/flutter/impeller/aiks/color_source.cc @@ -10,6 +10,7 @@ #include "impeller/aiks/paint.h" #include "impeller/core/sampler_descriptor.h" #include "impeller/entity/contents/conical_gradient_contents.h" +#include "impeller/entity/contents/filters/color_filter_contents.h" #include "impeller/entity/contents/linear_gradient_contents.h" #include "impeller/entity/contents/radial_gradient_contents.h" #include "impeller/entity/contents/runtime_effect_contents.h" @@ -182,8 +183,8 @@ ColorSource ColorSource::MakeImage(std::shared_ptr texture, if (paint.color_filter) { TiledTextureContents::ColorFilterProc filter_proc = [color_filter = paint.color_filter](FilterInput::Ref input) { - return color_filter->WrapWithGPUColorFilter(std::move(input), - false); + return color_filter->WrapWithGPUColorFilter( + std::move(input), ColorFilterContents::AbsorbOpacity::kNo); }; contents->SetColorFilter(filter_proc); } diff --git a/engine/src/flutter/impeller/aiks/image_filter.cc b/engine/src/flutter/impeller/aiks/image_filter.cc index 6420e8c293..7eba48713c 100644 --- a/engine/src/flutter/impeller/aiks/image_filter.cc +++ b/engine/src/flutter/impeller/aiks/image_filter.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "impeller/aiks/image_filter.h" +#include "impeller/entity/contents/filters/color_filter_contents.h" #include "impeller/entity/contents/filters/filter_contents.h" #include "impeller/entity/contents/filters/inputs/filter_input.h" @@ -175,7 +176,8 @@ ColorImageFilter::~ColorImageFilter() = default; std::shared_ptr ColorImageFilter::WrapInput( const FilterInput::Ref& input) const { - return color_filter_->WrapWithGPUColorFilter(input, false); + return color_filter_->WrapWithGPUColorFilter( + input, ColorFilterContents::AbsorbOpacity::kNo); } std::shared_ptr ColorImageFilter::Clone() const { diff --git a/engine/src/flutter/impeller/aiks/paint.cc b/engine/src/flutter/impeller/aiks/paint.cc index 5c2b808c69..9950661705 100644 --- a/engine/src/flutter/impeller/aiks/paint.cc +++ b/engine/src/flutter/impeller/aiks/paint.cc @@ -58,7 +58,7 @@ std::shared_ptr Paint::CreateContentsForGeometry( std::shared_ptr Paint::WithFilters( std::shared_ptr input) const { - input = WithColorFilter(input, /*absorb_opacity=*/true); + input = WithColorFilter(input, ColorFilterContents::AbsorbOpacity::kYes); input = WithInvertFilter(input); auto image_filter = WithImageFilter(input, Matrix(), /*is_subpass=*/false); if (image_filter) { @@ -75,7 +75,7 @@ std::shared_ptr Paint::WithFiltersForSubpassTarget( if (image_filter) { input = image_filter; } - input = WithColorFilter(input, /*absorb_opacity=*/true); + input = WithColorFilter(input, ColorFilterContents::AbsorbOpacity::kYes); return input; } @@ -103,7 +103,7 @@ std::shared_ptr Paint::WithImageFilter( std::shared_ptr Paint::WithColorFilter( std::shared_ptr input, - bool absorb_opacity) const { + ColorFilterContents::AbsorbOpacity absorb_opacity) const { // Image input types will directly set their color filter, // if any. See `TiledTextureContents.SetColorFilter`. if (color_source.GetType() == ColorSource::Type::kImage) { @@ -186,7 +186,8 @@ std::shared_ptr Paint::MaskBlurDescriptor::CreateMaskBlur( if (color_filter) { color_contents = color_filter->WrapWithGPUColorFilter( - FilterInput::Make(color_source_contents), true); + FilterInput::Make(color_source_contents), + ColorFilterContents::AbsorbOpacity::kYes); } /// 5. Composite the color source with the blurred mask. diff --git a/engine/src/flutter/impeller/aiks/paint.h b/engine/src/flutter/impeller/aiks/paint.h index 384b4bdb1f..e13fd9122f 100644 --- a/engine/src/flutter/impeller/aiks/paint.h +++ b/engine/src/flutter/impeller/aiks/paint.h @@ -104,8 +104,10 @@ struct Paint { bool is_subpass) const; private: - std::shared_ptr WithColorFilter(std::shared_ptr input, - bool absorb_opacity = false) const; + std::shared_ptr WithColorFilter( + std::shared_ptr input, + ColorFilterContents::AbsorbOpacity absorb_opacity = + ColorFilterContents::AbsorbOpacity::kNo) const; std::shared_ptr WithInvertFilter( std::shared_ptr input) const; diff --git a/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.cc b/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.cc index 3c1b861761..7e50634e4d 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.cc @@ -13,6 +13,7 @@ #include "impeller/entity/contents/anonymous_contents.h" #include "impeller/entity/contents/content_context.h" #include "impeller/entity/contents/contents.h" +#include "impeller/entity/contents/filters/color_filter_contents.h" #include "impeller/entity/contents/filters/inputs/filter_input.h" #include "impeller/entity/contents/solid_color_contents.h" #include "impeller/entity/entity.h" @@ -76,7 +77,7 @@ static std::optional AdvancedBlend( const Rect& coverage, BlendMode blend_mode, std::optional foreground_color, - bool absorb_opacity, + ColorFilterContents::AbsorbOpacity absorb_opacity, PipelineProc pipeline_proc, std::optional alpha) { using VS = typename TPipeline::VertexShader; @@ -184,7 +185,10 @@ static std::optional AdvancedBlend( dst_sampler_descriptor); FS::BindTextureSamplerDst(cmd, dst_snapshot->texture, dst_sampler); frame_info.dst_y_coord_scale = dst_snapshot->texture->GetYCoordScale(); - blend_info.dst_input_alpha = absorb_opacity ? dst_snapshot->opacity : 1.0; + blend_info.dst_input_alpha = + absorb_opacity == ColorFilterContents::AbsorbOpacity::kYes + ? dst_snapshot->opacity + : 1.0; if (foreground_color.has_value()) { blend_info.color_factor = 1; @@ -227,14 +231,17 @@ static std::optional AdvancedBlend( } return Entity::FromSnapshot( - Snapshot{.texture = out_texture, - .transform = Matrix::MakeTranslation(subpass_coverage.origin), - // Since we absorbed the transform of the inputs and used the - // respective snapshot sampling modes when blending, pass on - // the default NN clamp sampler. - .sampler_descriptor = {}, - .opacity = (absorb_opacity ? 1.0f : dst_snapshot->opacity) * - alpha.value_or(1.0)}, + Snapshot{ + .texture = out_texture, + .transform = Matrix::MakeTranslation(subpass_coverage.origin), + // Since we absorbed the transform of the inputs and used the + // respective snapshot sampling modes when blending, pass on + // the default NN clamp sampler. + .sampler_descriptor = {}, + .opacity = (absorb_opacity == ColorFilterContents::AbsorbOpacity::kYes + ? 1.0f + : dst_snapshot->opacity) * + alpha.value_or(1.0)}, entity.GetBlendMode(), entity.GetStencilDepth()); } @@ -246,7 +253,7 @@ std::optional BlendFilterContents::CreateForegroundAdvancedBlend( Color foreground_color, BlendMode blend_mode, std::optional alpha, - bool absorb_opacity) const { + ColorFilterContents::AbsorbOpacity absorb_opacity) const { auto dst_snapshot = input->GetSnapshot("ForegroundAdvancedBlend", renderer, entity); if (!dst_snapshot.has_value()) { @@ -353,7 +360,9 @@ std::optional BlendFilterContents::CreateForegroundAdvancedBlend( FS::BindTextureSamplerDst(cmd, dst_snapshot->texture, dst_sampler); frame_info.dst_y_coord_scale = dst_snapshot->texture->GetYCoordScale(); blend_info.dst_input_alpha = - absorb_opacity ? dst_snapshot->opacity * alpha.value_or(1.0) : 1.0; + absorb_opacity == ColorFilterContents::AbsorbOpacity::kYes + ? dst_snapshot->opacity * alpha.value_or(1.0) + : 1.0; blend_info.color_factor = 1; blend_info.color = foreground_color; @@ -395,7 +404,7 @@ std::optional BlendFilterContents::CreateForegroundPorterDuffBlend( Color foreground_color, BlendMode blend_mode, std::optional alpha, - bool absorb_opacity) const { + ColorFilterContents::AbsorbOpacity absorb_opacity) const { if (blend_mode == BlendMode::kClear) { return std::nullopt; } @@ -477,7 +486,9 @@ std::optional BlendFilterContents::CreateForegroundPorterDuffBlend( dst_snapshot->texture->GetYCoordScale(); frag_info.input_alpha = - absorb_opacity ? dst_snapshot->opacity * alpha.value_or(1.0) : 1.0; + absorb_opacity == ColorFilterContents::AbsorbOpacity::kYes + ? dst_snapshot->opacity * alpha.value_or(1.0) + : 1.0; frag_info.output_alpha = 1.0; auto blend_coefficients = @@ -520,7 +531,7 @@ static std::optional PipelineBlend( const Rect& coverage, BlendMode blend_mode, std::optional foreground_color, - bool absorb_opacity, + ColorFilterContents::AbsorbOpacity absorb_opacity, std::optional alpha) { using VS = BlendPipeline::VertexShader; using FS = BlendPipeline::FragmentShader; @@ -589,7 +600,10 @@ static std::optional PipelineBlend( input->texture->GetYCoordScale(); FS::FragInfo frag_info; - frag_info.input_alpha = absorb_opacity ? input->opacity : 1.0; + frag_info.input_alpha = + absorb_opacity == ColorFilterContents::AbsorbOpacity::kYes + ? input->opacity + : 1.0; FS::BindFragInfo(cmd, host_buffer.EmplaceUniform(frag_info)); VS::BindFrameInfo(cmd, host_buffer.EmplaceUniform(frame_info)); @@ -647,14 +661,17 @@ static std::optional PipelineBlend( } return Entity::FromSnapshot( - Snapshot{.texture = out_texture, - .transform = Matrix::MakeTranslation(subpass_coverage.origin), - // Since we absorbed the transform of the inputs and used the - // respective snapshot sampling modes when blending, pass on - // the default NN clamp sampler. - .sampler_descriptor = {}, - .opacity = (absorb_opacity ? 1.0f : dst_snapshot->opacity) * - alpha.value_or(1.0)}, + Snapshot{ + .texture = out_texture, + .transform = Matrix::MakeTranslation(subpass_coverage.origin), + // Since we absorbed the transform of the inputs and used the + // respective snapshot sampling modes when blending, pass on + // the default NN clamp sampler. + .sampler_descriptor = {}, + .opacity = (absorb_opacity == ColorFilterContents::AbsorbOpacity::kYes + ? 1.0f + : dst_snapshot->opacity) * + alpha.value_or(1.0)}, entity.GetBlendMode(), entity.GetStencilDepth()); } @@ -663,7 +680,8 @@ static std::optional PipelineBlend( advanced_blend_proc_ = \ [](const FilterInput::Vector& inputs, const ContentContext& renderer, \ const Entity& entity, const Rect& coverage, BlendMode blend_mode, \ - std::optional fg_color, bool absorb_opacity, \ + std::optional fg_color, \ + ColorFilterContents::AbsorbOpacity absorb_opacity, \ std::optional alpha) { \ PipelineProc p = &ContentContext::GetBlend##mode##Pipeline; \ return AdvancedBlend( \ @@ -726,7 +744,7 @@ std::optional BlendFilterContents::RenderFilter( if (blend_mode_ <= Entity::kLastPipelineBlendMode) { if (inputs.size() == 1 && foreground_color_.has_value() && - GetAbsorbOpacity()) { + GetAbsorbOpacity() == ColorFilterContents::AbsorbOpacity::kYes) { return CreateForegroundPorterDuffBlend( inputs[0], renderer, entity, coverage, foreground_color_.value(), blend_mode_, GetAlpha(), GetAbsorbOpacity()); @@ -737,7 +755,7 @@ std::optional BlendFilterContents::RenderFilter( if (blend_mode_ <= Entity::kLastAdvancedBlendMode) { if (inputs.size() == 1 && foreground_color_.has_value() && - GetAbsorbOpacity()) { + GetAbsorbOpacity() == ColorFilterContents::AbsorbOpacity::kYes) { return CreateForegroundAdvancedBlend( inputs[0], renderer, entity, coverage, foreground_color_.value(), blend_mode_, GetAlpha(), GetAbsorbOpacity()); diff --git a/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.h b/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.h index f279f7f926..a0e49d2ada 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.h +++ b/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.h @@ -33,15 +33,15 @@ std::optional InvertPorterDuffBlend(BlendMode blend_mode); class BlendFilterContents : public ColorFilterContents { public: - using AdvancedBlendProc = - std::function(const FilterInput::Vector& inputs, - const ContentContext& renderer, - const Entity& entity, - const Rect& coverage, - BlendMode blend_mode, - std::optional foreground_color, - bool absorb_opacity, - std::optional alpha)>; + using AdvancedBlendProc = std::function( + const FilterInput::Vector& inputs, + const ContentContext& renderer, + const Entity& entity, + const Rect& coverage, + BlendMode blend_mode, + std::optional foreground_color, + ColorFilterContents::AbsorbOpacity absorb_opacity, + std::optional alpha)>; BlendFilterContents(); @@ -75,7 +75,7 @@ class BlendFilterContents : public ColorFilterContents { Color foreground_color, BlendMode blend_mode, std::optional alpha, - bool absorb_opacity) const; + ColorFilterContents::AbsorbOpacity absorb_opacity) const; /// @brief Optimized porter-duff blend that avoids a second subpass when there /// is only a single input and a foreground color. @@ -89,7 +89,7 @@ class BlendFilterContents : public ColorFilterContents { Color foreground_color, BlendMode blend_mode, std::optional alpha, - bool absorb_opacity) const; + ColorFilterContents::AbsorbOpacity absorb_opacity) const; BlendMode blend_mode_ = BlendMode::kSourceOver; AdvancedBlendProc advanced_blend_proc_; diff --git a/engine/src/flutter/impeller/entity/contents/filters/color_filter_contents.cc b/engine/src/flutter/impeller/entity/contents/filters/color_filter_contents.cc index 51de176698..f5a36456a4 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/color_filter_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/color_filter_contents.cc @@ -82,11 +82,12 @@ ColorFilterContents::ColorFilterContents() = default; ColorFilterContents::~ColorFilterContents() = default; -void ColorFilterContents::SetAbsorbOpacity(bool absorb_opacity) { +void ColorFilterContents::SetAbsorbOpacity(AbsorbOpacity absorb_opacity) { absorb_opacity_ = absorb_opacity; } -bool ColorFilterContents::GetAbsorbOpacity() const { +ColorFilterContents::AbsorbOpacity ColorFilterContents::GetAbsorbOpacity() + const { return absorb_opacity_; } diff --git a/engine/src/flutter/impeller/entity/contents/filters/color_filter_contents.h b/engine/src/flutter/impeller/entity/contents/filters/color_filter_contents.h index 0099c16a6c..f09b2d7287 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/color_filter_contents.h +++ b/engine/src/flutter/impeller/entity/contents/filters/color_filter_contents.h @@ -10,6 +10,11 @@ namespace impeller { class ColorFilterContents : public FilterContents { public: + enum class AbsorbOpacity { + kYes, + kNo, + }; + /// @brief the [inputs] are expected to be in the order of dst, src. static std::shared_ptr MakeBlend( BlendMode blend_mode, @@ -30,9 +35,9 @@ class ColorFilterContents : public FilterContents { ~ColorFilterContents() override; - void SetAbsorbOpacity(bool absorb_opacity); + void SetAbsorbOpacity(AbsorbOpacity absorb_opacity); - bool GetAbsorbOpacity() const; + AbsorbOpacity GetAbsorbOpacity() const; /// @brief Sets an alpha that is applied to the final blended result. void SetAlpha(Scalar alpha); @@ -40,7 +45,7 @@ class ColorFilterContents : public FilterContents { std::optional GetAlpha() const; private: - bool absorb_opacity_ = false; + AbsorbOpacity absorb_opacity_ = AbsorbOpacity::kNo; std::optional alpha_; FML_DISALLOW_COPY_AND_ASSIGN(ColorFilterContents); diff --git a/engine/src/flutter/impeller/entity/contents/filters/color_matrix_filter_contents.cc b/engine/src/flutter/impeller/entity/contents/filters/color_matrix_filter_contents.cc index 24d0389bb0..98024afa53 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/color_matrix_filter_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/color_matrix_filter_contents.cc @@ -9,6 +9,7 @@ #include "impeller/entity/contents/anonymous_contents.h" #include "impeller/entity/contents/content_context.h" #include "impeller/entity/contents/contents.h" +#include "impeller/entity/contents/filters/color_filter_contents.h" #include "impeller/geometry/point.h" #include "impeller/geometry/vector.h" #include "impeller/renderer/render_pass.h" @@ -94,7 +95,10 @@ std::optional ColorMatrixFilterContents::RenderFilter( matrix[3], matrix[8], matrix[13], matrix[18] ); // clang-format on - frag_info.input_alpha = absorb_opacity ? input_snapshot->opacity : 1.0f; + frag_info.input_alpha = + absorb_opacity == ColorFilterContents::AbsorbOpacity::kYes + ? input_snapshot->opacity + : 1.0f; auto sampler = renderer.GetContext()->GetSamplerLibrary()->GetSampler({}); FS::BindInputTexture(cmd, input_snapshot->texture, sampler); FS::BindFragInfo(cmd, host_buffer.EmplaceUniform(frag_info)); diff --git a/engine/src/flutter/impeller/entity/contents/filters/linear_to_srgb_filter_contents.cc b/engine/src/flutter/impeller/entity/contents/filters/linear_to_srgb_filter_contents.cc index e75c269105..df6f5e0c0e 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/linear_to_srgb_filter_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/linear_to_srgb_filter_contents.cc @@ -76,7 +76,10 @@ std::optional LinearToSrgbFilterContents::RenderFilter( input_snapshot->texture->GetYCoordScale(); FS::FragInfo frag_info; - frag_info.input_alpha = absorb_opacity ? input_snapshot->opacity : 1.0f; + frag_info.input_alpha = + absorb_opacity == ColorFilterContents::AbsorbOpacity::kYes + ? input_snapshot->opacity + : 1.0f; auto sampler = renderer.GetContext()->GetSamplerLibrary()->GetSampler({}); FS::BindInputTexture(cmd, input_snapshot->texture, sampler); diff --git a/engine/src/flutter/impeller/entity/contents/filters/srgb_to_linear_filter_contents.cc b/engine/src/flutter/impeller/entity/contents/filters/srgb_to_linear_filter_contents.cc index 84568a0a2f..253089a85a 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/srgb_to_linear_filter_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/srgb_to_linear_filter_contents.cc @@ -76,7 +76,10 @@ std::optional SrgbToLinearFilterContents::RenderFilter( input_snapshot->texture->GetYCoordScale(); FS::FragInfo frag_info; - frag_info.input_alpha = absorb_opacity ? input_snapshot->opacity : 1.0f; + frag_info.input_alpha = + absorb_opacity == ColorFilterContents::AbsorbOpacity::kYes + ? input_snapshot->opacity + : 1.0f; auto sampler = renderer.GetContext()->GetSamplerLibrary()->GetSampler({}); FS::BindInputTexture(cmd, input_snapshot->texture, sampler);