blob: c07e181e9c490eb92a5a953c832a7dbd6a94f459 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001/*
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 */
reed868074b2014-06-03 10:53:59 -07007
reed@android.com8a1c16f2008-12-17 15:59:43 +00008#ifndef SkDrawProcs_DEFINED
9#define SkDrawProcs_DEFINED
10
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "src/core/SkDraw.h"
12#include "src/core/SkGlyph.h"
reed@android.com8a1c16f2008-12-17 15:59:43 +000013
commit-bot@chromium.orge0a868c2013-11-22 07:02:11 +000014bool SkDrawTreatAAStrokeAsHairline(SkScalar strokeWidth, const SkMatrix&,
15 SkScalar* coverage);
16
reed@google.comecadf992011-09-19 19:18:18 +000017/**
rmistry@google.comfbfcd562012-08-23 18:09:54 +000018 * If the current paint is set to stroke and the stroke-width when applied to
bsalomon@google.comdd1be602012-01-18 20:34:00 +000019 * the matrix is <= 1.0, then this returns true, and sets coverage (simulating
rmistry@google.comfbfcd562012-08-23 18:09:54 +000020 * a stroke by drawing a hairline with partial coverage). If any of these
bsalomon@google.comdd1be602012-01-18 20:34:00 +000021 * conditions are false, then this returns false and coverage is ignored.
reed@google.comecadf992011-09-19 19:18:18 +000022 */
commit-bot@chromium.orge0a868c2013-11-22 07:02:11 +000023inline 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.comecadf992011-09-19 19:18:18 +000041
reed@android.com8a1c16f2008-12-17 15:59:43 +000042#endif