mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Impeller] Use the stroke width in the coverage calculation for CircleGeometry (#168030)
This commit is contained in:
parent
32d8182490
commit
c3e02128c3
@ -1076,5 +1076,18 @@ TEST_P(AiksTest, StrokeCapsAndJoins) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, BlurredCircleWithStrokeWidth) {
|
||||
DisplayListBuilder builder;
|
||||
DlPaint paint;
|
||||
paint.setColor(DlColor::kGreen());
|
||||
paint.setDrawStyle(DlDrawStyle::kStroke);
|
||||
paint.setStrokeWidth(30);
|
||||
paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kNormal, 5));
|
||||
|
||||
builder.DrawCircle(DlPoint(200, 200), 100, paint);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace impeller
|
||||
|
||||
@ -55,11 +55,13 @@ GeometryResult CircleGeometry::GetPositionBuffer(const ContentContext& renderer,
|
||||
}
|
||||
|
||||
std::optional<Rect> CircleGeometry::GetCoverage(const Matrix& transform) const {
|
||||
Scalar half_width = stroke_width_ < 0 ? 0.0 : stroke_width_ * 0.5f;
|
||||
Scalar outer_radius = radius_ + half_width;
|
||||
Point corners[4]{
|
||||
{center_.x, center_.y - radius_},
|
||||
{center_.x + radius_, center_.y},
|
||||
{center_.x, center_.y + radius_},
|
||||
{center_.x - radius_, center_.y},
|
||||
{center_.x, center_.y - outer_radius},
|
||||
{center_.x + outer_radius, center_.y},
|
||||
{center_.x, center_.y + outer_radius},
|
||||
{center_.x - outer_radius, center_.y},
|
||||
};
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user