Don't use small path renderer with high distortion transforms.

The dFdx, dFdy functions appear to become less accurate as the
distortion in a given transform increases. We could possibly counteract
this by passing in the inverse of the transform, but this is taking the
small path renderer well past its original intended use, which is for
rendering small paths, and icons in particular, with similarity
transformations.

Bug: skia:11910
Change-Id: Ib7bf0d02925e9930583adb628501706831e73183
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402579
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
Jim Van Verth 2021-04-30 10:04:51 -04:00 committed by Skia Commit-Bot
parent 14efdd3d50
commit 12935777a6

View File

@ -66,13 +66,18 @@ GrPathRenderer::CanDrawPath GrSmallPathRenderer::onCanDrawPath(const CanDrawPath
return CanDrawPath::kNo;
}
// Only support paths with bounds within kMaxDim by kMaxDim,
// scaled to have bounds within kMaxSize by kMaxSize.
// The goal is to accelerate rendering of lots of small paths that may be scaling.
SkScalar scaleFactors[2] = { 1, 1 };
// TODO: handle perspective distortion
if (!args.fViewMatrix->hasPerspective() && !args.fViewMatrix->getMinMaxScales(scaleFactors)) {
return CanDrawPath::kNo;
}
// For affine transformations, too much shear can produce artifacts.
if (scaleFactors[1]/scaleFactors[0] > 4) {
return CanDrawPath::kNo;
}
// Only support paths with bounds within kMaxDim by kMaxDim,
// scaled to have bounds within kMaxSize by kMaxSize.
// The goal is to accelerate rendering of lots of small paths that may be scaling.
SkRect bounds = args.fShape->styledBounds();
SkScalar minDim = std::min(bounds.width(), bounds.height());
SkScalar maxDim = std::max(bounds.width(), bounds.height());