Skip to content

Commit

Permalink
[CP][Impeller] Create framebuffer blend vertices based on the snapsho…
Browse files Browse the repository at this point in the history
…t's texture size instead of coverage (#52790) (#53235)

The snapshot's transform is provided to the pipeline.  If the vertices are based on the coverage rectangle, then that will apply the snapshot's transform twice.

Fixes flutter/flutter#148213
  • Loading branch information
jonahwilliams authored Jul 1, 2024
1 parent 6934bb5 commit a43ee36
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
15 changes: 15 additions & 0 deletions impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3458,6 +3458,21 @@ TEST_P(AiksTest, CanRenderClippedBackdropFilter) {
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, FramebufferAdvancedBlendCoverage) {
auto texture = CreateTextureForFixture("airplane.jpg",
/*enable_mipmapping=*/true);

// Draw with an advanced blend that can use FramebufferBlendContents and
// verify that the scale transform is correctly applied to the image.
Canvas canvas;
canvas.DrawPaint({.color = Color::DarkGray()});
canvas.Scale(Vector2(0.4, 0.4));
canvas.DrawImage(std::make_shared<Image>(texture), {20, 20},
{.blend_mode = BlendMode::kMultiply});

ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

} // namespace testing
} // namespace impeller

Expand Down
7 changes: 1 addition & 6 deletions impeller/entity/contents/framebuffer_blend_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,8 @@ bool FramebufferBlendContents::Render(const ContentContext& renderer,
if (!src_snapshot.has_value()) {
return true;
}
auto coverage = src_snapshot->GetCoverage();
if (!coverage.has_value()) {
return true;
}
Rect src_coverage = coverage.value();

auto size = src_coverage.GetSize();
auto size = src_snapshot->texture->GetSize();
VertexBufferBuilder<VS::PerVertexData> vtx_builder;
vtx_builder.AddVertices({
{Point(0, 0), Point(0, 0)},
Expand Down
3 changes: 3 additions & 0 deletions testing/impeller_golden_tests_output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,9 @@ impeller_Play_AiksTest_FilledRoundRectsRenderCorrectly_Vulkan.png
impeller_Play_AiksTest_ForegroundBlendSubpassCollapseOptimization_Metal.png
impeller_Play_AiksTest_ForegroundBlendSubpassCollapseOptimization_OpenGLES.png
impeller_Play_AiksTest_ForegroundBlendSubpassCollapseOptimization_Vulkan.png
impeller_Play_AiksTest_FramebufferAdvancedBlendCoverage_Metal.png
impeller_Play_AiksTest_FramebufferAdvancedBlendCoverage_OpenGLES.png
impeller_Play_AiksTest_FramebufferAdvancedBlendCoverage_Vulkan.png
impeller_Play_AiksTest_GaussianBlurAnimatedBackdrop_Metal.png
impeller_Play_AiksTest_GaussianBlurAnimatedBackdrop_OpenGLES.png
impeller_Play_AiksTest_GaussianBlurAnimatedBackdrop_Vulkan.png
Expand Down

0 comments on commit a43ee36

Please sign in to comment.