diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkDraw.cpp | 25 | ||||
-rw-r--r-- | src/core/SkDrawProcs.h | 22 |
2 files changed, 28 insertions, 19 deletions
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; diff --git a/src/core/SkDrawProcs.h b/src/core/SkDrawProcs.h index cc2f3ed073..6911e5b017 100644 --- a/src/core/SkDrawProcs.h +++ b/src/core/SkDrawProcs.h @@ -75,12 +75,32 @@ struct SkDrawProcs { #endif }; +bool SkDrawTreatAAStrokeAsHairline(SkScalar strokeWidth, const SkMatrix&, + SkScalar* coverage); + /** * If the current paint is set to stroke and the stroke-width when applied to * the matrix is <= 1.0, then this returns true, and sets coverage (simulating * a stroke by drawing a hairline with partial coverage). If any of these * conditions are false, then this returns false and coverage is ignored. */ -bool SkDrawTreatAsHairline(const SkPaint&, const SkMatrix&, SkScalar* coverage); +inline bool SkDrawTreatAsHairline(const SkPaint& paint, const SkMatrix& matrix, + SkScalar* coverage) { + if (SkPaint::kStroke_Style != paint.getStyle()) { + return false; + } + + SkScalar strokeWidth = paint.getStrokeWidth(); + if (0 == strokeWidth) { + *coverage = SK_Scalar1; + return true; + } + + if (!paint.isAntiAlias()) { + return false; + } + + return SkDrawTreatAAStrokeAsHairline(strokeWidth, matrix, coverage); +} #endif |