From e0a868c84ebc34c5a16b5faa1546016abb9ca0ac Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Fri, 22 Nov 2013 07:02:11 +0000 Subject: Apply hairline optimization only if the path renderer wants it Make the decision to convert thin, non-hairline paths to hairline paths at the renderer level. The current nv_path_rendering implementation does not render hairlines. Rendering the hairlines with normal renderers cause unneccessary gl program changes, which is quite slow. Changes the behavior of non-nv_path_rendering paths to always perform the optimization if the shape ends up being painted by a renderer that wants the optimization. Previously the optimization was applied only when callgraph started with SkCanvas::drawPath. Applies the optimization for GrAAHairLineRenderer and GrDefaultPathRenderer. This changes gm results for dashing3_{msaa4,gpu} and drawlooper_msaa4. R=bsalomon@google.com, jvanverth@google.com, rmistry@google.com Author: kkinnunen@nvidia.com Review URL: https://codereview.chromium.org/38573007 git-svn-id: http://skia.googlecode.com/svn/trunk@12357 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/core/SkDraw.cpp | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) (limited to 'src/core/SkDraw.cpp') diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index 0288dee409..52891ea521 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -988,24 +988,11 @@ static bool xfermodeSupportsCoverageAsAlpha(SkXfermode* xfer) { } } -bool SkDrawTreatAsHairline(const SkPaint& paint, const SkMatrix& matrix, - SkScalar* coverage) { - SkASSERT(coverage); - if (SkPaint::kStroke_Style != paint.getStyle()) { - return false; - } - SkScalar strokeWidth = paint.getStrokeWidth(); - if (0 == strokeWidth) { - *coverage = SK_Scalar1; - return true; - } +bool SkDrawTreatAAStrokeAsHairline(SkScalar strokeWidth, const SkMatrix& matrix, + SkScalar* coverage) { + SkASSERT(strokeWidth > 0); + // We need to try to fake a thick-stroke with a modulated hairline. - // if we get here, we need to try to fake a thick-stroke with a modulated - // hairline - - if (!paint.isAntiAlias()) { - return false; - } if (matrix.hasPerspective()) { return false; } @@ -1017,7 +1004,9 @@ bool SkDrawTreatAsHairline(const SkPaint& paint, const SkMatrix& matrix, SkScalar len0 = fast_len(dst[0]); SkScalar len1 = fast_len(dst[1]); if (len0 <= SK_Scalar1 && len1 <= SK_Scalar1) { - *coverage = SkScalarAve(len0, len1); + if (NULL != coverage) { + *coverage = SkScalarAve(len0, len1); + } return true; } return false; -- cgit v1.2.3