Skip to content

Commit

Permalink
[impeller] correct input order in ColorFilterContents::MakeBlend (#39038
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jonahwilliams authored Jan 20, 2023
1 parent 3fead63 commit e2c2e50
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions impeller/entity/contents/filters/blend_filter_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static std::optional<Snapshot> 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) {
Expand Down Expand Up @@ -213,7 +213,7 @@ static std::optional<Snapshot> 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;
}

Expand All @@ -225,8 +225,8 @@ static std::optional<Snapshot> 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;
}
}
Expand Down Expand Up @@ -264,7 +264,7 @@ static std::optional<Snapshot> 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) \
Expand Down
2 changes: 1 addition & 1 deletion impeller/entity/contents/filters/color_filter_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ std::shared_ptr<ColorFilterContents> ColorFilterContents::MakeBlend(
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(
Expand Down
1 change: 1 addition & 0 deletions impeller/entity/contents/filters/color_filter_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ColorFilterContents> MakeBlend(
BlendMode blend_mode,
FilterInput::Vector inputs,
Expand Down
4 changes: 2 additions & 2 deletions impeller/entity/entity_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion impeller/entity/entity_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) *
Expand Down
1 change: 0 additions & 1 deletion impeller/entity/shaders/blending/advanced_blend.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit e2c2e50

Please sign in to comment.