aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/gpu/GrTessellator.cpp4
-rw-r--r--tests/TessellatingPathRendererTests.cpp12
2 files changed, 14 insertions, 2 deletions
diff --git a/src/gpu/GrTessellator.cpp b/src/gpu/GrTessellator.cpp
index 3eb92a6479..888c7de445 100644
--- a/src/gpu/GrTessellator.cpp
+++ b/src/gpu/GrTessellator.cpp
@@ -711,10 +711,10 @@ void append_quadratic_to_contour(const SkPoint pts[3], SkScalar toleranceSqd, Ve
Sk2s ab = quad.fA * quad.fB;
SkScalar t = denom ? (-ab[0] - ab[1]) / denom : 0.0f;
int nPoints = 1;
- SkScalar u;
+ SkScalar u = 1.0f;
// Test possible subdivision values only at the point of maximum curvature.
// If it passes the flatness metric there, it'll pass everywhere.
- for (;;) {
+ while (nPoints < GrPathUtils::kMaxPointsPerCurve) {
u = 1.0f / nPoints;
if (quad_error_at(pts, t, u) < toleranceSqd) {
break;
diff --git a/tests/TessellatingPathRendererTests.cpp b/tests/TessellatingPathRendererTests.cpp
index 02db8d8a58..dfbb0045a6 100644
--- a/tests/TessellatingPathRendererTests.cpp
+++ b/tests/TessellatingPathRendererTests.cpp
@@ -428,6 +428,17 @@ static SkPath create_path_28() {
path.lineTo(-7.5952312625177475154e+21, -2.6819185100266674911e+24);
return path;
}
+
+// A quad which generates a huge number of points (>2B) when uniformly
+// linearized. This should not hang or OOM.
+static SkPath create_path_29() {
+ SkPath path;
+ path.moveTo(10, 0);
+ path.lineTo(0, 0);
+ path.quadTo(10, 0, 0, 8315084722602508288);
+ return path;
+}
+
static std::unique_ptr<GrFragmentProcessor> create_linear_gradient_processor(GrContext* ctx) {
SkPoint pts[2] = { {0, 0}, {1, 1} };
@@ -519,5 +530,6 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) {
test_path(ctx, rtc.get(), create_path_26(), SkMatrix(), GrAAType::kCoverage);
test_path(ctx, rtc.get(), create_path_27(), SkMatrix(), GrAAType::kCoverage);
test_path(ctx, rtc.get(), create_path_28(), SkMatrix(), GrAAType::kCoverage);
+ test_path(ctx, rtc.get(), create_path_29());
}
#endif