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 <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2017-03-30 10:22:28 -04:00 committed by Skia Commit-Bot
parent 981108b004
commit 32ebaba7a7
2 changed files with 11 additions and 9 deletions

View File

@ -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,

View File

@ -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);