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

Commit 288e944

Browse files
committed
got solid working for gradients
1 parent 740cf64 commit 288e944

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

impeller/aiks/aiks_blur_unittests.cc

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -789,38 +789,38 @@ TEST_P(AiksTest, GaussianBlurStyleInnerGradient) {
789789
}
790790

791791
/// TODO(gaaclarke): This still doesn't work with stencil and cover.
792-
// TEST_P(AiksTest, GaussianBlurStyleSolidGradient) {
793-
// Canvas canvas;
794-
// canvas.Scale(GetContentScale());
795-
796-
// canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)});
797-
798-
// std::vector<Color> colors = {Color{0.9568, 0.2627, 0.2118, 1.0},
799-
// Color{0.7568, 0.2627, 0.2118, 1.0}};
800-
// std::vector<Scalar> stops = {0.0, 1.0};
801-
802-
// Paint paint;
803-
// paint.color_source = ColorSource::MakeLinearGradient(
804-
// {0, 0}, {200, 200}, std::move(colors), std::move(stops),
805-
// Entity::TileMode::kMirror, {});
806-
// paint.mask_blur_descriptor = Paint::MaskBlurDescriptor{
807-
// .style = FilterContents::BlurStyle::kSolid,
808-
// .sigma = Sigma(30),
809-
// };
810-
// canvas.DrawPath(PathBuilder()
811-
// .MoveTo({200, 200})
812-
// .LineTo({300, 400})
813-
// .LineTo({100, 400})
814-
// .Close()
815-
// .TakePath(),
816-
// paint);
817-
818-
// // Draw another thing to make sure the clip area is reset.
819-
// Paint red;
820-
// red.color = Color::Red();
821-
// canvas.DrawRect(Rect::MakeXYWH(0, 0, 200, 200), red);
822-
// ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
823-
// }
792+
TEST_P(AiksTest, GaussianBlurStyleSolidGradient) {
793+
Canvas canvas;
794+
canvas.Scale(GetContentScale());
795+
796+
canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)});
797+
798+
std::vector<Color> colors = {Color{0.9568, 0.2627, 0.2118, 1.0},
799+
Color{0.7568, 0.2627, 0.2118, 1.0}};
800+
std::vector<Scalar> stops = {0.0, 1.0};
801+
802+
Paint paint;
803+
paint.color_source = ColorSource::MakeLinearGradient(
804+
{0, 0}, {200, 200}, std::move(colors), std::move(stops),
805+
Entity::TileMode::kMirror, {});
806+
paint.mask_blur_descriptor = Paint::MaskBlurDescriptor{
807+
.style = FilterContents::BlurStyle::kSolid,
808+
.sigma = Sigma(30),
809+
};
810+
canvas.DrawPath(PathBuilder()
811+
.MoveTo({200, 200})
812+
.LineTo({300, 400})
813+
.LineTo({100, 400})
814+
.Close()
815+
.TakePath(),
816+
paint);
817+
818+
// Draw another thing to make sure the clip area is reset.
819+
Paint red;
820+
red.color = Color::Red();
821+
canvas.DrawRect(Rect::MakeXYWH(0, 0, 200, 200), red);
822+
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
823+
}
824824

825825
TEST_P(AiksTest, GaussianBlurStyleOuterGradient) {
826826
Canvas canvas;

impeller/entity/contents/filters/gaussian_blur_filter_contents.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,12 @@ Entity ApplyBlurStyle(FilterContents::BlurStyle blur_style,
280280
const ContentContext& renderer, const Entity& entity,
281281
RenderPass& pass) mutable {
282282
bool result = true;
283-
blurred.SetTransform(entity.GetTransform() * blurred_transform);
284-
result = result && blurred.Render(renderer, pass);
285283
snapshot_entity.SetTransform(entity.GetTransform() *
286284
snapshot_transform);
287285
snapshot_entity.SetNewClipDepth(entity.GetNewClipDepth());
288286
result = result && snapshot_entity.Render(renderer, pass);
287+
blurred.SetTransform(entity.GetTransform() * blurred_transform);
288+
result = result && blurred.Render(renderer, pass);
289289
return result;
290290
}),
291291
fml::MakeCopyable([blurred = blurred.Clone(),

0 commit comments

Comments
 (0)