epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 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 | */ |
reed | 868074b | 2014-06-03 10:53:59 -0700 | [diff] [blame] | 7 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 8 | #ifndef SkDrawProcs_DEFINED |
| 9 | #define SkDrawProcs_DEFINED |
| 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "src/core/SkDraw.h" |
| 12 | #include "src/core/SkGlyph.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 13 | |
commit-bot@chromium.org | e0a868c | 2013-11-22 07:02:11 +0000 | [diff] [blame] | 14 | bool SkDrawTreatAAStrokeAsHairline(SkScalar strokeWidth, const SkMatrix&, |
| 15 | SkScalar* coverage); |
| 16 | |
reed@google.com | ecadf99 | 2011-09-19 19:18:18 +0000 | [diff] [blame] | 17 | /** |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 18 | * If the current paint is set to stroke and the stroke-width when applied to |
bsalomon@google.com | dd1be60 | 2012-01-18 20:34:00 +0000 | [diff] [blame] | 19 | * the matrix is <= 1.0, then this returns true, and sets coverage (simulating |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 20 | * a stroke by drawing a hairline with partial coverage). If any of these |
bsalomon@google.com | dd1be60 | 2012-01-18 20:34:00 +0000 | [diff] [blame] | 21 | * conditions are false, then this returns false and coverage is ignored. |
reed@google.com | ecadf99 | 2011-09-19 19:18:18 +0000 | [diff] [blame] | 22 | */ |
commit-bot@chromium.org | e0a868c | 2013-11-22 07:02:11 +0000 | [diff] [blame] | 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 | } |
reed@google.com | ecadf99 | 2011-09-19 19:18:18 +0000 | [diff] [blame] | 41 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 42 | #endif |