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

[Impeller] Use depth transform in framebuffer blend entities. #53951

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions impeller/display_list/aiks_dl_clip_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,30 @@ TEST_P(AiksTest, ClipsUseCurrentTransform) {
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}

/// If correct, this test should draw a green circle. If any red is visible,
/// there is a depth bug.
TEST_P(AiksTest, FramebufferBlendsRespectClips) {
DisplayListBuilder builder;

// Clear the whole canvas with white.
DlPaint paint;
paint.setColor(DlColor::kWhite());
builder.DrawPaint(paint);

builder.ClipPath(SkPath::Circle(150, 150, 50), DlCanvas::ClipOp::kIntersect);

// Draw a red rectangle that should not show through the circle clip.
paint.setColor(DlColor::kRed());
paint.setBlendMode(DlBlendMode::kMultiply);
builder.DrawRect(SkRect::MakeXYWH(100, 100, 100, 100), paint);

// Draw a green circle that shows through the clip.
paint.setColor(DlColor::kGreen());
paint.setBlendMode(DlBlendMode::kSrcOver);
builder.DrawCircle(SkPoint::Make(150, 150), 50, paint);

ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}

} // namespace testing
} // namespace impeller
6 changes: 4 additions & 2 deletions impeller/entity/contents/filters/blend_filter_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ std::optional<Entity> BlendFilterContents::CreateForegroundAdvancedBlend(
FS::BindTextureSamplerDst(pass, dst_snapshot->texture, dst_sampler);
frame_info.dst_y_coord_scale = dst_snapshot->texture->GetYCoordScale();

frame_info.mvp = pass.GetOrthographicTransform() * dst_snapshot->transform;
frame_info.mvp = Entity::GetShaderTransform(entity.GetShaderClipDepth(),
pass, dst_snapshot->transform);

blend_info.dst_input_alpha =
absorb_opacity == ColorFilterContents::AbsorbOpacity::kYes
Expand Down Expand Up @@ -454,7 +455,8 @@ std::optional<Entity> BlendFilterContents::CreateForegroundPorterDuffBlend(
FS::FragInfo frag_info;
VS::FrameInfo frame_info;

frame_info.mvp = pass.GetOrthographicTransform() * dst_snapshot->transform;
frame_info.mvp = Entity::GetShaderTransform(entity.GetShaderClipDepth(),
pass, dst_snapshot->transform);

auto dst_sampler_descriptor = dst_snapshot->sampler_descriptor;
if (renderer.GetDeviceCapabilities().SupportsDecalSamplerAddressMode()) {
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 @@ -644,6 +644,9 @@ impeller_Play_AiksTest_ForegroundPipelineBlendAppliesTransformCorrectly_Vulkan.p
impeller_Play_AiksTest_FramebufferAdvancedBlendCoverage_Metal.png
impeller_Play_AiksTest_FramebufferAdvancedBlendCoverage_OpenGLES.png
impeller_Play_AiksTest_FramebufferAdvancedBlendCoverage_Vulkan.png
impeller_Play_AiksTest_FramebufferBlendsRespectClips_Metal.png
impeller_Play_AiksTest_FramebufferBlendsRespectClips_OpenGLES.png
impeller_Play_AiksTest_FramebufferBlendsRespectClips_Vulkan.png
impeller_Play_AiksTest_GaussianBlurAnimatedBackdrop_Metal.png
impeller_Play_AiksTest_GaussianBlurAnimatedBackdrop_OpenGLES.png
impeller_Play_AiksTest_GaussianBlurAnimatedBackdrop_Vulkan.png
Expand Down