SkDrawProcs.h (1301B)
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 "include/core/SkPaint.h" 12 #include "include/core/SkScalar.h" 13 #include "include/core/SkTypes.h" 14 class SkMatrix; 15 16 namespace skcpu { 17 bool DrawTreatAAStrokeAsHairline(SkScalar strokeWidth, const SkMatrix&, SkScalar* coverage); 18 19 /** 20 * If the current paint is set to stroke and the stroke-width when applied to 21 * the matrix is <= 1.0, then this returns true, and sets coverage (simulating 22 * a stroke by drawing a hairline with partial coverage). If any of these 23 * conditions are false, then this returns false and coverage is ignored. 24 */ 25 inline bool DrawTreatAsHairline(const SkPaint& paint, 26 const SkMatrix& matrix, 27 SkScalar* coverage) { 28 if (SkPaint::kStroke_Style != paint.getStyle()) { 29 return false; 30 } 31 32 SkScalar strokeWidth = paint.getStrokeWidth(); 33 if (0 == strokeWidth) { 34 *coverage = SK_Scalar1; 35 return true; 36 } 37 38 if (!paint.isAntiAlias()) { 39 return false; 40 } 41 42 return DrawTreatAAStrokeAsHairline(strokeWidth, matrix, coverage); 43 } 44 } // namespace skcpu 45 46 #endif