From 782158a499e6ca54e61e3df98224ad0326d8d0f7 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Fri, 10 May 2024 20:10:10 -0700 Subject: [PATCH 1/2] [Impeller] Create framebuffer blend vertices based on the snapshot's texture size instead of coverage 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. --- impeller/aiks/aiks_blend_unittests.cc | 15 +++++++++++++++ .../entity/contents/framebuffer_blend_contents.cc | 7 +------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/impeller/aiks/aiks_blend_unittests.cc b/impeller/aiks/aiks_blend_unittests.cc index 8b554a0938ee6..ebf129851d298 100644 --- a/impeller/aiks/aiks_blend_unittests.cc +++ b/impeller/aiks/aiks_blend_unittests.cc @@ -576,5 +576,20 @@ TEST_P(AiksTest, ForegroundAdvancedBlendAppliesTransformCorrectly) { 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(texture), {20, 20}, + {.blend_mode = BlendMode::kMultiply}); + + ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); +} + } // namespace testing } // namespace impeller diff --git a/impeller/entity/contents/framebuffer_blend_contents.cc b/impeller/entity/contents/framebuffer_blend_contents.cc index 762a3b7360603..afecf8f25d726 100644 --- a/impeller/entity/contents/framebuffer_blend_contents.cc +++ b/impeller/entity/contents/framebuffer_blend_contents.cc @@ -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 vtx_builder; vtx_builder.AddVertices({ {Point(0, 0), Point(0, 0)}, From f2ef1bcdd80e4facf3d7188c54ee25b8f9db20da Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Mon, 13 May 2024 18:06:47 -0700 Subject: [PATCH 2/2] golden test output --- testing/impeller_golden_tests_output.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/testing/impeller_golden_tests_output.txt b/testing/impeller_golden_tests_output.txt index 99704781e83be..1ec4f8151e373 100644 --- a/testing/impeller_golden_tests_output.txt +++ b/testing/impeller_golden_tests_output.txt @@ -572,6 +572,9 @@ impeller_Play_AiksTest_ForegroundBlendSubpassCollapseOptimization_Vulkan.png impeller_Play_AiksTest_ForegroundPipelineBlendAppliesTransformCorrectly_Metal.png impeller_Play_AiksTest_ForegroundPipelineBlendAppliesTransformCorrectly_OpenGLES.png impeller_Play_AiksTest_ForegroundPipelineBlendAppliesTransformCorrectly_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