aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrPathUtils.cpp
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-06-20 14:43:58 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-20 19:15:58 +0000
commit49b7b6f38fc9d6cbcfa5865db364ff79c3ed7bfe (patch)
treec4bccaca446ff6b894ba85b42fc4874ce76420ef /src/gpu/GrPathUtils.cpp
parent6081ebb6892e1779678b9d638f4b2a398e412f00 (diff)
Handle too many (or too large) paths in GrDefaultPathRenderer
PathGeoBuilder constructs the geometry with the same basic technique as before, but allows interrupting the process to emit multiple draws. Original test case was 2000 non-AA stroked circles, which created ~66000 vertices. That now renders, as do various tests with a single large path (as well as filled paths). Added a new set of 'AtLeast' allocators for vertex and index data. These take a minimum size and a fallback size. If the minimum size can be satisfied by an existing block, then the caller gets *all* memory in that block, otherwise they get a new block sized for the fallback amount. The previous allocation scheme wasn't a good fit for the new use-case, and because we don't usually need many verts, the flexible approach seems appropriate. TODO: I think that this could be extracted and re-used for MSAA path renderer without too much work? I need to read that code more carefully to make sure it lines up. Re-land of: https://skia-review.googlesource.com/18360 Re-land of: https://skia-review.googlesource.com/18983 Bug: skia:6695 Change-Id: I09ac1273e5af67ed0e3e886de90e2970c3d0b239 Reviewed-on: https://skia-review.googlesource.com/19480 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrPathUtils.cpp')
-rw-r--r--src/gpu/GrPathUtils.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/gpu/GrPathUtils.cpp b/src/gpu/GrPathUtils.cpp
index 6047e60258..b6711a0df4 100644
--- a/src/gpu/GrPathUtils.cpp
+++ b/src/gpu/GrPathUtils.cpp
@@ -10,7 +10,6 @@
#include "GrTypes.h"
#include "SkMathPriv.h"
-static const int MAX_POINTS_PER_CURVE = 1 << 10;
static const SkScalar gMinCurveTol = 0.0001f;
SkScalar GrPathUtils::scaleToleranceToSrc(SkScalar devTol,
@@ -44,7 +43,7 @@ uint32_t GrPathUtils::quadraticPointCount(const SkPoint points[], SkScalar tol)
SkScalar d = points[1].distanceToLineSegmentBetween(points[0], points[2]);
if (!SkScalarIsFinite(d)) {
- return MAX_POINTS_PER_CURVE;
+ return kMaxPointsPerCurve;
} else if (d <= tol) {
return 1;
} else {
@@ -54,7 +53,7 @@ uint32_t GrPathUtils::quadraticPointCount(const SkPoint points[], SkScalar tol)
// 2^(log4(x)) = sqrt(x);
SkScalar divSqrt = SkScalarSqrt(d / tol);
if (((SkScalar)SK_MaxS32) <= divSqrt) {
- return MAX_POINTS_PER_CURVE;
+ return kMaxPointsPerCurve;
} else {
int temp = SkScalarCeilToInt(divSqrt);
int pow2 = GrNextPow2(temp);
@@ -64,7 +63,7 @@ uint32_t GrPathUtils::quadraticPointCount(const SkPoint points[], SkScalar tol)
if (pow2 < 1) {
pow2 = 1;
}
- return SkTMin(pow2, MAX_POINTS_PER_CURVE);
+ return SkTMin(pow2, kMaxPointsPerCurve);
}
}
}
@@ -104,13 +103,13 @@ uint32_t GrPathUtils::cubicPointCount(const SkPoint points[],
points[2].distanceToLineSegmentBetweenSqd(points[0], points[3]));
d = SkScalarSqrt(d);
if (!SkScalarIsFinite(d)) {
- return MAX_POINTS_PER_CURVE;
+ return kMaxPointsPerCurve;
} else if (d <= tol) {
return 1;
} else {
SkScalar divSqrt = SkScalarSqrt(d / tol);
if (((SkScalar)SK_MaxS32) <= divSqrt) {
- return MAX_POINTS_PER_CURVE;
+ return kMaxPointsPerCurve;
} else {
int temp = SkScalarCeilToInt(SkScalarSqrt(d / tol));
int pow2 = GrNextPow2(temp);
@@ -120,7 +119,7 @@ uint32_t GrPathUtils::cubicPointCount(const SkPoint points[],
if (pow2 < 1) {
pow2 = 1;
}
- return SkTMin(pow2, MAX_POINTS_PER_CURVE);
+ return SkTMin(pow2, kMaxPointsPerCurve);
}
}
}