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

Commit a43ee36

Browse files
author
Jonah Williams
authored
[CP][Impeller] Create framebuffer blend vertices based on the snapshot'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
1 parent 6934bb5 commit a43ee36

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

impeller/aiks/aiks_unittests.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3458,6 +3458,21 @@ TEST_P(AiksTest, CanRenderClippedBackdropFilter) {
34583458
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
34593459
}
34603460

3461+
TEST_P(AiksTest, FramebufferAdvancedBlendCoverage) {
3462+
auto texture = CreateTextureForFixture("airplane.jpg",
3463+
/*enable_mipmapping=*/true);
3464+
3465+
// Draw with an advanced blend that can use FramebufferBlendContents and
3466+
// verify that the scale transform is correctly applied to the image.
3467+
Canvas canvas;
3468+
canvas.DrawPaint({.color = Color::DarkGray()});
3469+
canvas.Scale(Vector2(0.4, 0.4));
3470+
canvas.DrawImage(std::make_shared<Image>(texture), {20, 20},
3471+
{.blend_mode = BlendMode::kMultiply});
3472+
3473+
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
3474+
}
3475+
34613476
} // namespace testing
34623477
} // namespace impeller
34633478

impeller/entity/contents/framebuffer_blend_contents.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,8 @@ bool FramebufferBlendContents::Render(const ContentContext& renderer,
5252
if (!src_snapshot.has_value()) {
5353
return true;
5454
}
55-
auto coverage = src_snapshot->GetCoverage();
56-
if (!coverage.has_value()) {
57-
return true;
58-
}
59-
Rect src_coverage = coverage.value();
6055

61-
auto size = src_coverage.GetSize();
56+
auto size = src_snapshot->texture->GetSize();
6257
VertexBufferBuilder<VS::PerVertexData> vtx_builder;
6358
vtx_builder.AddVertices({
6459
{Point(0, 0), Point(0, 0)},

testing/impeller_golden_tests_output.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,9 @@ impeller_Play_AiksTest_FilledRoundRectsRenderCorrectly_Vulkan.png
476476
impeller_Play_AiksTest_ForegroundBlendSubpassCollapseOptimization_Metal.png
477477
impeller_Play_AiksTest_ForegroundBlendSubpassCollapseOptimization_OpenGLES.png
478478
impeller_Play_AiksTest_ForegroundBlendSubpassCollapseOptimization_Vulkan.png
479+
impeller_Play_AiksTest_FramebufferAdvancedBlendCoverage_Metal.png
480+
impeller_Play_AiksTest_FramebufferAdvancedBlendCoverage_OpenGLES.png
481+
impeller_Play_AiksTest_FramebufferAdvancedBlendCoverage_Vulkan.png
479482
impeller_Play_AiksTest_GaussianBlurAnimatedBackdrop_Metal.png
480483
impeller_Play_AiksTest_GaussianBlurAnimatedBackdrop_OpenGLES.png
481484
impeller_Play_AiksTest_GaussianBlurAnimatedBackdrop_Vulkan.png

0 commit comments

Comments
 (0)