From 50e9efe482d0716595db8f31dc1166a40606abdc Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Fri, 17 Aug 2018 15:28:53 -0400 Subject: [PATCH] try to help res-scaling in perspective Perspective is really hard. Perhaps if we could change the API to pass in the bounds of the shape in question, we could do a better job. As it is we are just looking at the gradient around the origin. Bug: skia: Change-Id: I0542dfef8dfcc9b598048729b5fc65b745f800ed Reviewed-on: https://skia-review.googlesource.com/147818 Reviewed-by: Cary Clark Commit-Queue: Mike Reed --- src/core/SkDraw.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index f5e4a1c35b..c8eb78d9ba 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -944,14 +944,13 @@ DRAW_PATH: } SkScalar SkDraw::ComputeResScaleForStroking(const SkMatrix& matrix) { - if (!matrix.hasPerspective()) { - SkScalar sx = SkPoint::Length(matrix[SkMatrix::kMScaleX], matrix[SkMatrix::kMSkewY]); - SkScalar sy = SkPoint::Length(matrix[SkMatrix::kMSkewX], matrix[SkMatrix::kMScaleY]); - if (SkScalarsAreFinite(sx, sy)) { - SkScalar scale = SkTMax(sx, sy); - if (scale > 0) { - return scale; - } + // Not sure how to handle perspective differently, so we just don't try (yet) + SkScalar sx = SkPoint::Length(matrix[SkMatrix::kMScaleX], matrix[SkMatrix::kMSkewY]); + SkScalar sy = SkPoint::Length(matrix[SkMatrix::kMSkewX], matrix[SkMatrix::kMScaleY]); + if (SkScalarsAreFinite(sx, sy)) { + SkScalar scale = SkTMax(sx, sy); + if (scale > 0) { + return scale; } } return 1;