diff --git a/impeller/entity/contents/filters/blend_filter_contents.cc b/impeller/entity/contents/filters/blend_filter_contents.cc index 687d19f4012b5..38f8173e6580b 100644 --- a/impeller/entity/contents/filters/blend_filter_contents.cc +++ b/impeller/entity/contents/filters/blend_filter_contents.cc @@ -159,7 +159,7 @@ static std::optional PipelineBlend( 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 @@ static std::optional PipelineBlend( // 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 @@ static std::optional PipelineBlend( 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 @@ static std::optional PipelineBlend( .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 a4b8db8fc6cce..64ba4e7139c8e 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 ColorFilterContents::MakeBlend( std::shared_ptr new_blend; for (auto in_i = inputs.begin() + 1; in_i < inputs.end(); in_i++) { new_blend = std::make_shared(); - 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 17e54b56039f0..775ad6f4253df 100644 --- a/impeller/entity/contents/filters/color_filter_contents.h +++ b/impeller/entity/contents/filters/color_filter_contents.h @@ -10,6 +10,7 @@ namespace impeller { class ColorFilterContents : public FilterContents { public: + /// @brief the [inputs] are expected to be in the order of dst, src. static std::shared_ptr MakeBlend( BlendMode blend_mode, FilterInput::Vector inputs, diff --git a/impeller/entity/entity_pass.cc b/impeller/entity/entity_pass.cc index 0add3a2264084..346e636eb763d 100644 --- a/impeller/entity/entity_pass.cc +++ b/impeller/entity/entity_pass.cc @@ -531,9 +531,9 @@ bool EntityPass::OnRender( } 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 31bd009a123db..ae0037c595c07 100644 --- a/impeller/entity/entity_unittests.cc +++ b/impeller/entity/entity_unittests.cc @@ -856,7 +856,7 @@ TEST_P(EntityTest, Filters) { 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 4fd47b059c0c8..c63f7ce541abb 100644 --- a/impeller/entity/shaders/blending/advanced_blend.glsl +++ b/impeller/entity/shaders/blending/advanced_blend.glsl @@ -46,5 +46,4 @@ void main() { vec4 blended = vec4(Blend(dst.rgb, src.rgb), 1) * dst.a; frag_color = mix(dst_sample, blended, src.a); - // frag_color = dst_sample; }