From 32ebaba7a7331478e9205859a824ee4eaeff6866 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Thu, 30 Mar 2017 10:22:28 -0400 Subject: Use correct tolerance for conic chopping in MSAA and default path renderers Bug: 706581 Change-Id: I16b3037380508316fc73ab7a8cebf960de66938e Reviewed-on: https://skia-review.googlesource.com/10752 Reviewed-by: Robert Phillips Commit-Queue: Brian Salomon --- src/gpu/ops/GrDefaultPathRenderer.cpp | 4 +--- src/gpu/ops/GrMSAAPathRenderer.cpp | 16 ++++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src/gpu/ops') diff --git a/src/gpu/ops/GrDefaultPathRenderer.cpp b/src/gpu/ops/GrDefaultPathRenderer.cpp index f33fc66e08..cf4cdbe937 100644 --- a/src/gpu/ops/GrDefaultPathRenderer.cpp +++ b/src/gpu/ops/GrDefaultPathRenderer.cpp @@ -343,9 +343,7 @@ private: case SkPath::kConic_Verb: { SkScalar weight = iter.conicWeight(); SkAutoConicToQuads converter; - // Converting in src-space, hance the finer tolerance (0.25) - // TODO: find a way to do this in dev-space so the tolerance means something - const SkPoint* quadPts = converter.computeQuads(pts, weight, 0.25f); + const SkPoint* quadPts = converter.computeQuads(pts, weight, srcSpaceTol); for (int i = 0; i < converter.countQuads(); ++i) { add_quad(&vert, base, quadPts + i*2, srcSpaceTolSqd, srcSpaceTol, isIndexed, this->isHairline(), subpathIdxStart, diff --git a/src/gpu/ops/GrMSAAPathRenderer.cpp b/src/gpu/ops/GrMSAAPathRenderer.cpp index 8cbe2a3a7d..047fca6de2 100644 --- a/src/gpu/ops/GrMSAAPathRenderer.cpp +++ b/src/gpu/ops/GrMSAAPathRenderer.cpp @@ -223,7 +223,8 @@ public: int contourCount; int maxLineVertices; int maxQuadVertices; - ComputeWorstCasePointCount(path, &contourCount, &maxLineVertices, &maxQuadVertices); + ComputeWorstCasePointCount(path, viewMatrix, &contourCount, &maxLineVertices, + &maxQuadVertices); bool isIndexed = contourCount > 1; if (isIndexed && (maxLineVertices > kMaxIndexedVertexCnt || maxQuadVertices > kMaxIndexedVertexCnt)) { @@ -269,8 +270,9 @@ private: optimizations.getOverrideColorIfSet(&fPaths[0].fColor); } - static void ComputeWorstCasePointCount(const SkPath& path, int* subpaths, + static void ComputeWorstCasePointCount(const SkPath& path, const SkMatrix& m, int* subpaths, int* outLinePointCount, int* outQuadPointCount) { + SkScalar tolerance = GrPathUtils::scaleToleranceToSrc(kTolerance, m, path.getBounds()); int linePointCount = 0; int quadPointCount = 0; *subpaths = 1; @@ -289,7 +291,7 @@ private: case SkPath::kConic_Verb: { SkScalar weight = iter.conicWeight(); SkAutoConicToQuads converter; - converter.computeQuads(pts, weight, kTolerance); + converter.computeQuads(pts, weight, tolerance); int quadPts = converter.countQuads(); linePointCount += quadPts; quadPointCount += 3 * quadPts; @@ -300,7 +302,7 @@ private: break; case SkPath::kCubic_Verb: { SkSTArray<15, SkPoint, true> quadPts; - GrPathUtils::convertCubicToQuads(pts, kTolerance, &quadPts); + GrPathUtils::convertCubicToQuads(pts, tolerance, &quadPts); int count = quadPts.count(); linePointCount += count / 3; quadPointCount += count; @@ -486,6 +488,8 @@ private: SkColor color, bool isIndexed) const { { + const SkScalar tolerance = GrPathUtils::scaleToleranceToSrc(kTolerance, m, + path.getBounds()); uint16_t subpathIdxStart = (uint16_t) (lines.nextVertex - lines.vertices); SkPoint pts[4]; @@ -518,7 +522,7 @@ private: case SkPath::kConic_Verb: { SkScalar weight = iter.conicWeight(); SkAutoConicToQuads converter; - const SkPoint* quadPts = converter.computeQuads(pts, weight, kTolerance); + const SkPoint* quadPts = converter.computeQuads(pts, weight, tolerance); for (int i = 0; i < converter.countQuads(); ++i) { add_quad(lines, quads, quadPts + i * 2, color, isIndexed, subpathIdxStart); @@ -531,7 +535,7 @@ private: } case SkPath::kCubic_Verb: { SkSTArray<15, SkPoint, true> quadPts; - GrPathUtils::convertCubicToQuads(pts, kTolerance, &quadPts); + GrPathUtils::convertCubicToQuads(pts, tolerance, &quadPts); int count = quadPts.count(); for (int i = 0; i < count; i += 3) { add_quad(lines, quads, &quadPts[i], color, isIndexed, subpathIdxStart); -- cgit v1.2.3