Fix DistanceFieldPathRenderer assert.
authorJim Van Verth <jvanverth@google.com>
Thu, 16 Feb 2017 15:01:46 +0000 (10:01 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Thu, 16 Feb 2017 15:37:53 +0000 (15:37 +0000)
If there's a reflection in the matrix, the scales
could be negative.

BUG=chromium:682918

Change-Id: Ifde42c3bc8b1f2938009b47d3a8380cf871448e9
Reviewed-on: https://skia-review.googlesource.com/8541
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>

src/gpu/ops/GrAADistanceFieldPathRenderer.cpp

index 7131e18..17cd244 100644 (file)
@@ -119,8 +119,8 @@ bool GrAADistanceFieldPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) c
     SkRect bounds = args.fShape->styledBounds();
     SkScalar minDim = SkMinScalar(bounds.width(), bounds.height());
     SkScalar maxDim = SkMaxScalar(bounds.width(), bounds.height());
-    SkScalar minSize = minDim * scaleFactors[0];
-    SkScalar maxSize = maxDim * scaleFactors[1];
+    SkScalar minSize = minDim * SkScalarAbs(scaleFactors[0]);
+    SkScalar maxSize = maxDim * SkScalarAbs(scaleFactors[1]);
 
     return maxDim <= kMaxDim && kMinSize <= minSize && maxSize <= kMaxSize;
 }
@@ -245,7 +245,7 @@ private:
             const Entry& args = fShapes[i];
 
             // get mip level
-            SkScalar maxScale = this->viewMatrix().getMaxScale();
+            SkScalar maxScale = SkScalarAbs(this->viewMatrix().getMaxScale());
             const SkRect& bounds = args.fShape.bounds();
             SkScalar maxDim = SkMaxScalar(bounds.width(), bounds.height());
             // We try to create the DF at a power of two scaled path resolution (1/2, 1, 2, 4, etc)