• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2011 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkDrawProcs_DEFINED
9 #define SkDrawProcs_DEFINED
10 
11 #include "src/core/SkDraw.h"
12 #include "src/core/SkGlyph.h"
13 
14 bool SkDrawTreatAAStrokeAsHairline(SkScalar strokeWidth, const SkMatrix&,
15                                    SkScalar* coverage);
16 
17 /**
18  *  If the current paint is set to stroke and the stroke-width when applied to
19  *  the matrix is <= 1.0, then this returns true, and sets coverage (simulating
20  *  a stroke by drawing a hairline with partial coverage). If any of these
21  *  conditions are false, then this returns false and coverage is ignored.
22  */
SkDrawTreatAsHairline(const SkPaint & paint,const SkMatrix & matrix,SkScalar * coverage)23 inline bool SkDrawTreatAsHairline(const SkPaint& paint, const SkMatrix& matrix,
24                                   SkScalar* coverage) {
25     if (SkPaint::kStroke_Style != paint.getStyle()) {
26         return false;
27     }
28 
29     SkScalar strokeWidth = paint.getStrokeWidth();
30     if (0 == strokeWidth) {
31         *coverage = SK_Scalar1;
32         return true;
33     }
34 
35     if (!paint.isAntiAlias()) {
36         return false;
37     }
38 
39     return SkDrawTreatAAStrokeAsHairline(strokeWidth, matrix, coverage);
40 }
41 
42 #endif
43