[impeller] correct input order in ColorFilterContents::MakeBlend (#39038)
diff --git a/impeller/entity/contents/filters/blend_filter_contents.cc b/impeller/entity/contents/filters/blend_filter_contents.cc index 687d19f..38f8173 100644 --- a/impeller/entity/contents/filters/blend_filter_contents.cc +++ b/impeller/entity/contents/filters/blend_filter_contents.cc
@@ -159,7 +159,7 @@ using VS = BlendPipeline::VertexShader; using FS = BlendPipeline::FragmentShader; - auto input_snapshot = inputs[0]->GetSnapshot(renderer, entity); + auto dst_snapshot = inputs[0]->GetSnapshot(renderer, entity); ContentContext::SubpassCallback callback = [&](const ContentContext& renderer, RenderPass& pass) { @@ -213,7 +213,7 @@ // Draw the first texture using kSource. options.blend_mode = BlendMode::kSource; cmd.pipeline = renderer.GetBlendPipeline(options); - if (!add_blend_command(input_snapshot)) { + if (!add_blend_command(dst_snapshot)) { return true; } @@ -225,8 +225,8 @@ for (auto texture_i = inputs.begin() + 1; texture_i < inputs.end(); texture_i++) { - auto input = texture_i->get()->GetSnapshot(renderer, entity); - if (!add_blend_command(input)) { + auto src_input = texture_i->get()->GetSnapshot(renderer, entity); + if (!add_blend_command(src_input)) { return true; } } @@ -264,7 +264,7 @@ .transform = Matrix::MakeTranslation(coverage.origin), .sampler_descriptor = inputs[0]->GetSnapshot(renderer, entity)->sampler_descriptor, - .opacity = absorb_opacity ? 1.0f : input_snapshot->opacity}; + .opacity = absorb_opacity ? 1.0f : dst_snapshot->opacity}; } #define BLEND_CASE(mode) \
diff --git a/impeller/entity/contents/filters/color_filter_contents.cc b/impeller/entity/contents/filters/color_filter_contents.cc index a4b8db8..64ba4e7 100644 --- a/impeller/entity/contents/filters/color_filter_contents.cc +++ b/impeller/entity/contents/filters/color_filter_contents.cc
@@ -37,7 +37,7 @@ std::shared_ptr<BlendFilterContents> new_blend; for (auto in_i = inputs.begin() + 1; in_i < inputs.end(); in_i++) { new_blend = std::make_shared<BlendFilterContents>(); - new_blend->SetInputs({*in_i, blend_input}); + new_blend->SetInputs({blend_input, *in_i}); new_blend->SetBlendMode(blend_mode); if (in_i < inputs.end() - 1 || foreground_color.has_value()) { blend_input = FilterInput::Make(
diff --git a/impeller/entity/contents/filters/color_filter_contents.h b/impeller/entity/contents/filters/color_filter_contents.h index 17e54b5..775ad6f 100644 --- a/impeller/entity/contents/filters/color_filter_contents.h +++ b/impeller/entity/contents/filters/color_filter_contents.h
@@ -10,6 +10,7 @@ class ColorFilterContents : public FilterContents { public: + /// @brief the [inputs] are expected to be in the order of dst, src. static std::shared_ptr<ColorFilterContents> MakeBlend( BlendMode blend_mode, FilterInput::Vector inputs,
diff --git a/impeller/entity/entity_pass.cc b/impeller/entity/entity_pass.cc index 0add3a2..346e636 100644 --- a/impeller/entity/entity_pass.cc +++ b/impeller/entity/entity_pass.cc
@@ -531,9 +531,9 @@ } FilterInput::Vector inputs = { - FilterInput::Make(result.entity.GetContents()), FilterInput::Make(texture, - result.entity.GetTransformation().Invert())}; + result.entity.GetTransformation().Invert()), + FilterInput::Make(result.entity.GetContents())}; auto contents = ColorFilterContents::MakeBlend(result.entity.GetBlendMode(), inputs); contents->SetCoverageCrop(result.entity.GetCoverage());
diff --git a/impeller/entity/entity_unittests.cc b/impeller/entity/entity_unittests.cc index 31bd009..ae0037c 100644 --- a/impeller/entity/entity_unittests.cc +++ b/impeller/entity/entity_unittests.cc
@@ -856,7 +856,7 @@ auto blend1 = ColorFilterContents::MakeBlend( BlendMode::kScreen, - {fi_bridge, FilterInput::Make(blend0), fi_bridge, fi_bridge}); + {FilterInput::Make(blend0), fi_bridge, fi_bridge, fi_bridge}); Entity entity; entity.SetTransformation(Matrix::MakeScale(GetContentScale()) *
diff --git a/impeller/entity/shaders/blending/advanced_blend.glsl b/impeller/entity/shaders/blending/advanced_blend.glsl index 4fd47b0..c63f7ce 100644 --- a/impeller/entity/shaders/blending/advanced_blend.glsl +++ b/impeller/entity/shaders/blending/advanced_blend.glsl
@@ -46,5 +46,4 @@ vec4 blended = vec4(Blend(dst.rgb, src.rgb), 1) * dst.a; frag_color = mix(dst_sample, blended, src.a); - // frag_color = dst_sample; }