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

Commit 1ce6a7b

Browse files
committed
tessellation adjustments.
1 parent c174ab2 commit 1ce6a7b

File tree

6 files changed

+22
-8
lines changed

6 files changed

+22
-8
lines changed

impeller/display_list/aiks_dl_unittests.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ TEST_P(AiksTest, CanDrawPointsWithTextureMap) {
467467
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
468468
}
469469

470+
// Regression test for flutter/flutter#152780
470471
TEST_P(AiksTest, CanDrawScaledPointsLargeScaleSmallRadius) {
471472
std::vector<SkPoint> point = {
472473
{0, 0}, //
@@ -487,6 +488,7 @@ TEST_P(AiksTest, CanDrawScaledPointsLargeScaleSmallRadius) {
487488
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
488489
}
489490

491+
// Regression test for flutter/flutter#152780
490492
TEST_P(AiksTest, CanDrawScaledPointsSmallScaleLargeRadius) {
491493
std::vector<SkPoint> point = {
492494
{0, 0}, //

impeller/entity/geometry/point_field_geometry.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ GeometryResult PointFieldGeometry::GetPositionBuffer(
3838
// point in turn. Note: we intentionally used the original radius here
3939
// to capture any scaling < 1.0.
4040
auto generator =
41-
renderer.GetTessellator()->FilledCircle(transform, {}, radius_);
41+
renderer.GetTessellator()->FilledCircle(transform, {}, radius_, radius);
4242
FML_DCHECK(generator.GetTriangleType() == PrimitiveType::kTriangleStrip);
4343
std::vector<Point> circle_vertices;
4444
circle_vertices.reserve(generator.GetVertexCount());

impeller/tessellator/tessellator.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,10 @@ EllipticalVertexGenerator::EllipticalVertexGenerator(
237237
EllipticalVertexGenerator Tessellator::FilledCircle(
238238
const Matrix& view_transform,
239239
const Point& center,
240+
Scalar raw_radius,
240241
Scalar radius) {
241-
size_t divisions =
242-
ComputeQuadrantDivisions(view_transform.GetMaxBasisLengthXY() * radius);
242+
size_t divisions = ComputeQuadrantDivisions(
243+
view_transform.GetMaxBasisLengthXY() * raw_radius);
243244
return EllipticalVertexGenerator(Tessellator::GenerateFilledCircle,
244245
GetTrigsForDivisions(divisions),
245246
PrimitiveType::kTriangleStrip, 4,
@@ -267,7 +268,7 @@ EllipticalVertexGenerator Tessellator::StrokedCircle(
267268
.half_width = half_width,
268269
});
269270
} else {
270-
return FilledCircle(view_transform, center, radius);
271+
return FilledCircle(view_transform, center, radius, radius);
271272
}
272273
}
273274

@@ -290,7 +291,7 @@ EllipticalVertexGenerator Tessellator::RoundCapLine(
290291
.half_width = -1.0f,
291292
});
292293
} else {
293-
return FilledCircle(view_transform, p0, radius);
294+
return FilledCircle(view_transform, p0, radius, radius);
294295
}
295296
}
296297

@@ -299,7 +300,7 @@ EllipticalVertexGenerator Tessellator::FilledEllipse(
299300
const Rect& bounds) {
300301
if (bounds.IsSquare()) {
301302
return FilledCircle(view_transform, bounds.GetCenter(),
302-
bounds.GetWidth() * 0.5f);
303+
bounds.GetWidth() * 0.5f, bounds.GetWidth() * 0.5f);
303304
}
304305
auto max_radius = bounds.GetSize().MaxDimension();
305306
auto divisions = ComputeQuadrantDivisions(

impeller/tessellator/tessellator.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,12 @@ class Tessellator {
222222
/// number of sample points to use per quarter circle and the
223223
/// returned points are not transformed by it, instead they are
224224
/// relative to the coordinate space of the center point.
225+
///
226+
/// The `raw_radius` should be untransformed and unclamped, while
227+
/// `radius` may be rounded up to a minimal pixel size.
225228
EllipticalVertexGenerator FilledCircle(const Matrix& view_transform,
226229
const Point& center,
230+
Scalar raw_radius,
227231
Scalar radius);
228232

229233
/// @brief Create a |VertexGenerator| that can produce vertices for

impeller/tessellator/tessellator_unittests.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ TEST(TessellatorTest, CircleVertexCounts) {
140140
auto tessellator = std::make_shared<Tessellator>();
141141

142142
auto test = [&tessellator](const Matrix& transform, Scalar radius) {
143-
auto generator = tessellator->FilledCircle(transform, {}, radius);
143+
auto generator = tessellator->FilledCircle(transform, {}, radius, radius);
144144
size_t quadrant_divisions = generator.GetVertexCount() / 4;
145145

146146
// Confirm the approximation error is within the currently accepted
@@ -177,7 +177,8 @@ TEST(TessellatorTest, FilledCircleTessellationVertices) {
177177

178178
auto test = [&tessellator](const Matrix& transform, const Point& center,
179179
Scalar radius) {
180-
auto generator = tessellator->FilledCircle(transform, center, radius);
180+
auto generator =
181+
tessellator->FilledCircle(transform, center, radius, radius);
181182
EXPECT_EQ(generator.GetTriangleType(), PrimitiveType::kTriangleStrip);
182183

183184
auto vertex_count = generator.GetVertexCount();

testing/impeller_golden_tests_output.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ impeller_Play_AiksTest_CanDrawPointsWithTextureMap_Vulkan.png
218218
impeller_Play_AiksTest_CanDrawPoints_Metal.png
219219
impeller_Play_AiksTest_CanDrawPoints_OpenGLES.png
220220
impeller_Play_AiksTest_CanDrawPoints_Vulkan.png
221+
impeller_Play_AiksTest_CanDrawScaledPointsLargeScaleSmallRadius_Metal.png
222+
impeller_Play_AiksTest_CanDrawScaledPointsLargeScaleSmallRadius_OpenGLES.png
223+
impeller_Play_AiksTest_CanDrawScaledPointsLargeScaleSmallRadius_Vulkan.png
224+
impeller_Play_AiksTest_CanDrawScaledPointsSmallScaleLargeRadius_Metal.png
225+
impeller_Play_AiksTest_CanDrawScaledPointsSmallScaleLargeRadius_OpenGLES.png
226+
impeller_Play_AiksTest_CanDrawScaledPointsSmallScaleLargeRadius_Vulkan.png
221227
impeller_Play_AiksTest_CanEmptyPictureConvertToImage_Metal.png
222228
impeller_Play_AiksTest_CanEmptyPictureConvertToImage_OpenGLES.png
223229
impeller_Play_AiksTest_CanEmptyPictureConvertToImage_Vulkan.png

0 commit comments

Comments
 (0)