/src/skia/src/core/SkStroke.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2006 The Android Open Source Project |
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 SkStroke_DEFINED |
9 | | #define SkStroke_DEFINED |
10 | | |
11 | | #include "include/core/SkPaint.h" |
12 | | #include "include/core/SkPathTypes.h" |
13 | | #include "include/core/SkScalar.h" |
14 | | #include "include/private/base/SkAssert.h" |
15 | | #include "include/private/base/SkDebug.h" |
16 | | #include "include/private/base/SkTo.h" |
17 | | |
18 | | #include <cmath> |
19 | | #include <cstdint> |
20 | | |
21 | | class SkPath; |
22 | | struct SkRect; |
23 | | |
24 | | #ifdef SK_DEBUG |
25 | | extern bool gDebugStrokerErrorSet; |
26 | | extern SkScalar gDebugStrokerError; |
27 | | extern int gMaxRecursion[]; |
28 | | #endif |
29 | | |
30 | | /** \class SkStroke |
31 | | SkStroke is the utility class that constructs paths by stroking |
32 | | geometries (lines, rects, ovals, roundrects, paths). This is |
33 | | invoked when a geometry or text is drawn in a canvas with the |
34 | | kStroke_Mask bit set in the paint. |
35 | | */ |
36 | | class SkStroke { |
37 | | public: |
38 | | SkStroke(); |
39 | | SkStroke(const SkPaint&); |
40 | | SkStroke(const SkPaint&, SkScalar width); // width overrides paint.getStrokeWidth() |
41 | | |
42 | 1.09M | SkPaint::Cap getCap() const { return (SkPaint::Cap)fCap; } |
43 | | void setCap(SkPaint::Cap); |
44 | | |
45 | 345k | SkPaint::Join getJoin() const { return (SkPaint::Join)fJoin; } |
46 | | void setJoin(SkPaint::Join); |
47 | | |
48 | | void setMiterLimit(SkScalar); |
49 | | void setWidth(SkScalar); |
50 | | |
51 | 0 | bool getDoFill() const { return SkToBool(fDoFill); } |
52 | 350k | void setDoFill(bool doFill) { fDoFill = SkToU8(doFill); } |
53 | | |
54 | | /** |
55 | | * ResScale is the "intended" resolution for the output. |
56 | | * Default is 1.0. |
57 | | * Larger values (res > 1) indicate that the result should be more precise, since it will |
58 | | * be zoomed up, and small errors will be magnified. |
59 | | * Smaller values (0 < res < 1) indicate that the result can be less precise, since it will |
60 | | * be zoomed down, and small errors may be invisible. |
61 | | */ |
62 | 0 | SkScalar getResScale() const { return fResScale; } |
63 | 350k | void setResScale(SkScalar rs) { |
64 | 350k | SkASSERT(rs > 0 && std::isfinite(rs)); |
65 | 350k | fResScale = rs; |
66 | 350k | } |
67 | | |
68 | | /** |
69 | | * Stroke the specified rect, winding it in the specified direction.. |
70 | | */ |
71 | | void strokeRect(const SkRect& rect, SkPath* result, |
72 | | SkPathDirection = SkPathDirection::kCW) const; |
73 | | void strokePath(const SkPath& path, SkPath*) const; |
74 | | |
75 | | //////////////////////////////////////////////////////////////// |
76 | | |
77 | | private: |
78 | | SkScalar fWidth, fMiterLimit; |
79 | | SkScalar fResScale; |
80 | | uint8_t fCap, fJoin; |
81 | | bool fDoFill; |
82 | | |
83 | | friend class SkPaint; |
84 | | }; |
85 | | |
86 | | #endif |