From 53a0d03e310e4ee2ae008e51dcffcf7b009873c0 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Mon, 25 Sep 2023 14:31:06 -0700 Subject: [PATCH 1/8] added test --- impeller/aiks/aiks_unittests.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index caa3372e93780..bb2f1f246be60 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -3581,5 +3581,24 @@ TEST_P(AiksTest, VerticesGeometryUVPositionData) { ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } +TEST_P(AiksTest, ClearBlendWithBlur) { + Canvas canvas; + Paint white; + white.color = Color::White(); + canvas.DrawRect(Rect::MakeXYWH(0, 0, 600.0, 600.0), white); + + Paint clear; + clear.color = Color::White(); + clear.blend_mode = BlendMode::kClear; + clear.mask_blur_descriptor = Paint::MaskBlurDescriptor{ + .style = FilterContents::BlurStyle::kNormal, + .sigma = Sigma(20), + }; + + canvas.DrawCircle(Point::MakeXY(300.0, 300.0), 200.0, clear); + + ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); +} + } // namespace testing } // namespace impeller From 12872e170f51d856c041fa36996d5e91fb6ebcfe Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Mon, 25 Sep 2023 14:49:07 -0700 Subject: [PATCH 2/8] removed hack from test --- impeller/aiks/aiks_unittests.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index bb2f1f246be60..976761c45c916 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -3588,7 +3588,6 @@ TEST_P(AiksTest, ClearBlendWithBlur) { canvas.DrawRect(Rect::MakeXYWH(0, 0, 600.0, 600.0), white); Paint clear; - clear.color = Color::White(); clear.blend_mode = BlendMode::kClear; clear.mask_blur_descriptor = Paint::MaskBlurDescriptor{ .style = FilterContents::BlurStyle::kNormal, From e5b52cf506985b102189a5da71045814e494a111 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Mon, 25 Sep 2023 15:42:55 -0700 Subject: [PATCH 3/8] added other test --- impeller/aiks/aiks_unittests.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index 976761c45c916..a41c56140ebae 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -3599,5 +3599,19 @@ TEST_P(AiksTest, ClearBlendWithBlur) { ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } +TEST_P(AiksTest, ClearBlend) { + Canvas canvas; + Paint white; + white.color = Color::White(); + canvas.DrawRect(Rect::MakeXYWH(0, 0, 600.0, 600.0), white); + + Paint clear; + clear.blend_mode = BlendMode::kClear; + + canvas.DrawCircle(Point::MakeXY(300.0, 300.0), 200.0, clear); + + ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); +} + } // namespace testing } // namespace impeller From dbfe2e17267d2b3e179bb4f5200e9b425625aef9 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Mon, 25 Sep 2023 15:53:57 -0700 Subject: [PATCH 4/8] added image test --- impeller/aiks/aiks_unittests.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index a41c56140ebae..30f7474fd8b42 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -3613,5 +3613,17 @@ TEST_P(AiksTest, ClearBlend) { ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } +TEST_P(AiksTest, ClearBlendImage) { + Canvas canvas; + Paint paint; + auto dst = std::make_shared(CreateTextureForFixture("blend_mode_dst.png")); + auto src = std::make_shared(CreateTextureForFixture("blend_mode_src.png")); + canvas.DrawImage(dst, Point::MakeXY(100.0, 100.0), paint); + Paint clear; + clear.blend_mode = BlendMode::kClear; + canvas.DrawImage(src, Point::MakeXY(100.0, 100.0), clear); + ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); +} + } // namespace testing } // namespace impeller From b87acb6257c61b8dbc0eda1e194dbe8a99fc61dc Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Mon, 25 Sep 2023 16:10:05 -0700 Subject: [PATCH 5/8] format --- impeller/aiks/aiks_unittests.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index 30f7474fd8b42..b06135f1aabdd 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -3616,8 +3616,10 @@ TEST_P(AiksTest, ClearBlend) { TEST_P(AiksTest, ClearBlendImage) { Canvas canvas; Paint paint; - auto dst = std::make_shared(CreateTextureForFixture("blend_mode_dst.png")); - auto src = std::make_shared(CreateTextureForFixture("blend_mode_src.png")); + auto dst = + std::make_shared(CreateTextureForFixture("blend_mode_dst.png")); + auto src = + std::make_shared(CreateTextureForFixture("blend_mode_src.png")); canvas.DrawImage(dst, Point::MakeXY(100.0, 100.0), paint); Paint clear; clear.blend_mode = BlendMode::kClear; From 98cec738eb342d39ad9a99fd7441bd9cec596f96 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 21 Sep 2023 15:38:45 -0700 Subject: [PATCH 6/8] [Impeller] fixed the behavior for clear --- impeller/entity/contents/content_context.cc | 17 +++++++++++++---- impeller/entity/contents/content_context.h | 12 +++++++----- .../contents/solid_rrect_blur_contents.cc | 9 +++++++-- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/impeller/entity/contents/content_context.cc b/impeller/entity/contents/content_context.cc index 1a4985db5a07e..1461e1b9cd9cf 100644 --- a/impeller/entity/contents/content_context.cc +++ b/impeller/entity/contents/content_context.cc @@ -38,10 +38,19 @@ void ContentContextOptions::ApplyToPipelineDescriptor( switch (pipeline_blend) { case BlendMode::kClear: - color0.dst_alpha_blend_factor = BlendFactor::kZero; - color0.dst_color_blend_factor = BlendFactor::kZero; - color0.src_alpha_blend_factor = BlendFactor::kZero; - color0.src_color_blend_factor = BlendFactor::kZero; + if (is_for_rrect_blur_clear) { + color0.alpha_blend_op = BlendOperation::kReverseSubtract; + color0.color_blend_op = BlendOperation::kReverseSubtract; + color0.dst_alpha_blend_factor = BlendFactor::kOne; + color0.dst_color_blend_factor = BlendFactor::kOne; + color0.src_alpha_blend_factor = BlendFactor::kDestinationColor; + color0.src_color_blend_factor = BlendFactor::kDestinationColor; + } else { + color0.dst_alpha_blend_factor = BlendFactor::kZero; + color0.dst_color_blend_factor = BlendFactor::kZero; + color0.src_alpha_blend_factor = BlendFactor::kZero; + color0.src_color_blend_factor = BlendFactor::kZero; + } break; case BlendMode::kSource: color0.blending_enabled = false; diff --git a/impeller/entity/contents/content_context.h b/impeller/entity/contents/content_context.h index 2778fec4f72c2..4c4c17c43b194 100644 --- a/impeller/entity/contents/content_context.h +++ b/impeller/entity/contents/content_context.h @@ -308,13 +308,14 @@ struct ContentContextOptions { PixelFormat color_attachment_pixel_format = PixelFormat::kUnknown; bool has_stencil_attachment = true; bool wireframe = false; + bool is_for_rrect_blur_clear = false; struct Hash { constexpr std::size_t operator()(const ContentContextOptions& o) const { - return fml::HashCombine(o.sample_count, o.blend_mode, o.stencil_compare, - o.stencil_operation, o.primitive_type, - o.color_attachment_pixel_format, - o.has_stencil_attachment, o.wireframe); + return fml::HashCombine( + o.sample_count, o.blend_mode, o.stencil_compare, o.stencil_operation, + o.primitive_type, o.color_attachment_pixel_format, + o.has_stencil_attachment, o.wireframe, o.is_for_rrect_blur_clear); } }; @@ -329,7 +330,8 @@ struct ContentContextOptions { lhs.color_attachment_pixel_format == rhs.color_attachment_pixel_format && lhs.has_stencil_attachment == rhs.has_stencil_attachment && - lhs.wireframe == rhs.wireframe; + lhs.wireframe == rhs.wireframe && + lhs.is_for_rrect_blur_clear == rhs.is_for_rrect_blur_clear; } }; diff --git a/impeller/entity/contents/solid_rrect_blur_contents.cc b/impeller/entity/contents/solid_rrect_blur_contents.cc index ec8bc3e61d9ce..5e7c90c127563 100644 --- a/impeller/entity/contents/solid_rrect_blur_contents.cc +++ b/impeller/entity/contents/solid_rrect_blur_contents.cc @@ -88,8 +88,13 @@ bool SolidRRectBlurContents::Render(const ContentContext& renderer, Command cmd; DEBUG_COMMAND_INFO(cmd, "RRect Shadow"); - auto opts = OptionsFromPassAndEntity(pass, entity); + ContentContextOptions opts = OptionsFromPassAndEntity(pass, entity); opts.primitive_type = PrimitiveType::kTriangle; + Color color = color_; + if (entity.GetBlendMode() == BlendMode::kClear) { + opts.is_for_rrect_blur_clear = true; + color = Color::White(); + } cmd.pipeline = renderer.GetRRectBlurPipeline(opts); cmd.stencil_reference = entity.GetStencilDepth(); @@ -102,7 +107,7 @@ bool SolidRRectBlurContents::Render(const ContentContext& renderer, VS::BindFrameInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frame_info)); FS::FragInfo frag_info; - frag_info.color = color_; + frag_info.color = color; frag_info.blur_sigma = blur_sigma; frag_info.rect_size = Point(positive_rect.size); frag_info.corner_radius = From 2a31a30b1980cdf9cd6d2aa8fe25f275962735b4 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Tue, 26 Sep 2023 09:16:32 -0700 Subject: [PATCH 7/8] removed clearblendimage --- impeller/aiks/aiks_unittests.cc | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index b06135f1aabdd..a41c56140ebae 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -3613,19 +3613,5 @@ TEST_P(AiksTest, ClearBlend) { ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } -TEST_P(AiksTest, ClearBlendImage) { - Canvas canvas; - Paint paint; - auto dst = - std::make_shared(CreateTextureForFixture("blend_mode_dst.png")); - auto src = - std::make_shared(CreateTextureForFixture("blend_mode_src.png")); - canvas.DrawImage(dst, Point::MakeXY(100.0, 100.0), paint); - Paint clear; - clear.blend_mode = BlendMode::kClear; - canvas.DrawImage(src, Point::MakeXY(100.0, 100.0), clear); - ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); -} - } // namespace testing } // namespace impeller From fc1adcb8a5bd3c2d156f198346c625ed8012bec2 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Tue, 26 Sep 2023 10:00:26 -0700 Subject: [PATCH 8/8] switched tests to use a blue square to account for clear color in skiagold tests --- impeller/aiks/aiks_unittests.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index a41c56140ebae..07bad5fd82c18 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -3584,7 +3584,7 @@ TEST_P(AiksTest, VerticesGeometryUVPositionData) { TEST_P(AiksTest, ClearBlendWithBlur) { Canvas canvas; Paint white; - white.color = Color::White(); + white.color = Color::Blue(); canvas.DrawRect(Rect::MakeXYWH(0, 0, 600.0, 600.0), white); Paint clear; @@ -3602,7 +3602,7 @@ TEST_P(AiksTest, ClearBlendWithBlur) { TEST_P(AiksTest, ClearBlend) { Canvas canvas; Paint white; - white.color = Color::White(); + white.color = Color::Blue(); canvas.DrawRect(Rect::MakeXYWH(0, 0, 600.0, 600.0), white); Paint clear;