OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkStroke_DEFINED | 8 #ifndef SkStroke_DEFINED |
9 #define SkStroke_DEFINED | 9 #define SkStroke_DEFINED |
10 | 10 |
11 #include "SkPath.h" | 11 #include "SkPath.h" |
12 #include "SkPoint.h" | 12 #include "SkPoint.h" |
13 #include "SkPaint.h" | 13 #include "SkPaint.h" |
14 #include "SkStrokerPriv.h" | 14 #include "SkStrokerPriv.h" |
15 | 15 |
16 // set to 1 to use experimental outset stroking with quads | 16 #if defined SK_QUAD_STROKE_APPROXIMATION && defined SK_DEBUG |
17 #ifndef QUAD_STROKE_APPROXIMATION | |
18 #define QUAD_STROKE_APPROXIMATION 0 | |
19 #endif | |
20 | |
21 #if QUAD_STROKE_APPROXIMATION && defined(SK_DEBUG) | |
22 extern bool gDebugStrokerErrorSet; | 17 extern bool gDebugStrokerErrorSet; |
23 extern SkScalar gDebugStrokerError; | 18 extern SkScalar gDebugStrokerError; |
24 | |
25 extern int gMaxRecursion[]; | 19 extern int gMaxRecursion[]; |
26 #endif | 20 #endif |
27 | 21 |
28 /** \class SkStroke | 22 /** \class SkStroke |
29 SkStroke is the utility class that constructs paths by stroking | 23 SkStroke is the utility class that constructs paths by stroking |
30 geometries (lines, rects, ovals, roundrects, paths). This is | 24 geometries (lines, rects, ovals, roundrects, paths). This is |
31 invoked when a geometry or text is drawn in a canvas with the | 25 invoked when a geometry or text is drawn in a canvas with the |
32 kStroke_Mask bit set in the paint. | 26 kStroke_Mask bit set in the paint. |
33 */ | 27 */ |
34 class SkStroke { | 28 class SkStroke { |
35 public: | 29 public: |
36 SkStroke(); | 30 SkStroke(); |
37 SkStroke(const SkPaint&); | 31 SkStroke(const SkPaint&); |
38 SkStroke(const SkPaint&, SkScalar width); // width overrides paint.getStro
keWidth() | 32 SkStroke(const SkPaint&, SkScalar width); // width overrides paint.getStro
keWidth() |
39 | 33 |
40 SkPaint::Cap getCap() const { return (SkPaint::Cap)fCap; } | 34 SkPaint::Cap getCap() const { return (SkPaint::Cap)fCap; } |
41 void setCap(SkPaint::Cap); | 35 void setCap(SkPaint::Cap); |
42 | 36 |
43 SkPaint::Join getJoin() const { return (SkPaint::Join)fJoin; } | 37 SkPaint::Join getJoin() const { return (SkPaint::Join)fJoin; } |
44 void setJoin(SkPaint::Join); | 38 void setJoin(SkPaint::Join); |
45 | 39 |
46 #if QUAD_STROKE_APPROXIMATION | |
47 void setError(SkScalar); | |
48 #endif | |
49 void setMiterLimit(SkScalar); | 40 void setMiterLimit(SkScalar); |
50 void setWidth(SkScalar); | 41 void setWidth(SkScalar); |
51 | 42 |
52 bool getDoFill() const { return SkToBool(fDoFill); } | 43 bool getDoFill() const { return SkToBool(fDoFill); } |
53 void setDoFill(bool doFill) { fDoFill = SkToU8(doFill); } | 44 void setDoFill(bool doFill) { fDoFill = SkToU8(doFill); } |
54 | 45 |
55 /** | 46 /** |
56 * ResScale is the "intended" resolution for the output. | 47 * ResScale is the "intended" resolution for the output. |
57 * Default is 1.0. | 48 * Default is 1.0. |
58 * Larger values (res > 1) indicate that the result should be more prec
ise, since it will | 49 * Larger values (res > 1) indicate that the result should be more prec
ise, since it will |
(...skipping 10 matching lines...) Expand all Loading... |
69 /** | 60 /** |
70 * Stroke the specified rect, winding it in the specified direction.. | 61 * Stroke the specified rect, winding it in the specified direction.. |
71 */ | 62 */ |
72 void strokeRect(const SkRect& rect, SkPath* result, | 63 void strokeRect(const SkRect& rect, SkPath* result, |
73 SkPath::Direction = SkPath::kCW_Direction) const; | 64 SkPath::Direction = SkPath::kCW_Direction) const; |
74 void strokePath(const SkPath& path, SkPath*) const; | 65 void strokePath(const SkPath& path, SkPath*) const; |
75 | 66 |
76 //////////////////////////////////////////////////////////////// | 67 //////////////////////////////////////////////////////////////// |
77 | 68 |
78 private: | 69 private: |
79 #if QUAD_STROKE_APPROXIMATION | |
80 SkScalar fError; | |
81 #endif | |
82 SkScalar fWidth, fMiterLimit; | 70 SkScalar fWidth, fMiterLimit; |
83 SkScalar fResScale; | 71 SkScalar fResScale; |
84 uint8_t fCap, fJoin; | 72 uint8_t fCap, fJoin; |
85 SkBool8 fDoFill; | 73 SkBool8 fDoFill; |
86 | 74 |
87 friend class SkPaint; | 75 friend class SkPaint; |
88 }; | 76 }; |
89 | 77 |
90 #endif | 78 #endif |
OLD | NEW |