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

Commit e2c2e50

Browse files
author
Jonah Williams
authored
[impeller] correct input order in ColorFilterContents::MakeBlend (#39038)
1 parent 3fead63 commit e2c2e50

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

impeller/entity/contents/filters/blend_filter_contents.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static std::optional<Snapshot> PipelineBlend(
159159
using VS = BlendPipeline::VertexShader;
160160
using FS = BlendPipeline::FragmentShader;
161161

162-
auto input_snapshot = inputs[0]->GetSnapshot(renderer, entity);
162+
auto dst_snapshot = inputs[0]->GetSnapshot(renderer, entity);
163163

164164
ContentContext::SubpassCallback callback = [&](const ContentContext& renderer,
165165
RenderPass& pass) {
@@ -213,7 +213,7 @@ static std::optional<Snapshot> PipelineBlend(
213213
// Draw the first texture using kSource.
214214
options.blend_mode = BlendMode::kSource;
215215
cmd.pipeline = renderer.GetBlendPipeline(options);
216-
if (!add_blend_command(input_snapshot)) {
216+
if (!add_blend_command(dst_snapshot)) {
217217
return true;
218218
}
219219

@@ -225,8 +225,8 @@ static std::optional<Snapshot> PipelineBlend(
225225

226226
for (auto texture_i = inputs.begin() + 1; texture_i < inputs.end();
227227
texture_i++) {
228-
auto input = texture_i->get()->GetSnapshot(renderer, entity);
229-
if (!add_blend_command(input)) {
228+
auto src_input = texture_i->get()->GetSnapshot(renderer, entity);
229+
if (!add_blend_command(src_input)) {
230230
return true;
231231
}
232232
}
@@ -264,7 +264,7 @@ static std::optional<Snapshot> PipelineBlend(
264264
.transform = Matrix::MakeTranslation(coverage.origin),
265265
.sampler_descriptor =
266266
inputs[0]->GetSnapshot(renderer, entity)->sampler_descriptor,
267-
.opacity = absorb_opacity ? 1.0f : input_snapshot->opacity};
267+
.opacity = absorb_opacity ? 1.0f : dst_snapshot->opacity};
268268
}
269269

270270
#define BLEND_CASE(mode) \

impeller/entity/contents/filters/color_filter_contents.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ std::shared_ptr<ColorFilterContents> ColorFilterContents::MakeBlend(
3737
std::shared_ptr<BlendFilterContents> new_blend;
3838
for (auto in_i = inputs.begin() + 1; in_i < inputs.end(); in_i++) {
3939
new_blend = std::make_shared<BlendFilterContents>();
40-
new_blend->SetInputs({*in_i, blend_input});
40+
new_blend->SetInputs({blend_input, *in_i});
4141
new_blend->SetBlendMode(blend_mode);
4242
if (in_i < inputs.end() - 1 || foreground_color.has_value()) {
4343
blend_input = FilterInput::Make(

impeller/entity/contents/filters/color_filter_contents.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace impeller {
1010

1111
class ColorFilterContents : public FilterContents {
1212
public:
13+
/// @brief the [inputs] are expected to be in the order of dst, src.
1314
static std::shared_ptr<ColorFilterContents> MakeBlend(
1415
BlendMode blend_mode,
1516
FilterInput::Vector inputs,

impeller/entity/entity_pass.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,9 @@ bool EntityPass::OnRender(
531531
}
532532

533533
FilterInput::Vector inputs = {
534-
FilterInput::Make(result.entity.GetContents()),
535534
FilterInput::Make(texture,
536-
result.entity.GetTransformation().Invert())};
535+
result.entity.GetTransformation().Invert()),
536+
FilterInput::Make(result.entity.GetContents())};
537537
auto contents =
538538
ColorFilterContents::MakeBlend(result.entity.GetBlendMode(), inputs);
539539
contents->SetCoverageCrop(result.entity.GetCoverage());

impeller/entity/entity_unittests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ TEST_P(EntityTest, Filters) {
856856

857857
auto blend1 = ColorFilterContents::MakeBlend(
858858
BlendMode::kScreen,
859-
{fi_bridge, FilterInput::Make(blend0), fi_bridge, fi_bridge});
859+
{FilterInput::Make(blend0), fi_bridge, fi_bridge, fi_bridge});
860860

861861
Entity entity;
862862
entity.SetTransformation(Matrix::MakeScale(GetContentScale()) *

impeller/entity/shaders/blending/advanced_blend.glsl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,4 @@ void main() {
4646
vec4 blended = vec4(Blend(dst.rgb, src.rgb), 1) * dst.a;
4747

4848
frag_color = mix(dst_sample, blended, src.a);
49-
// frag_color = dst_sample;
5049
}

0 commit comments

Comments
 (0)