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" |
| 15 |
| 16 // set to 1 to use experimental outset stroking with quads |
| 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; |
| 23 extern SkScalar gDebugStrokerError; |
| 24 |
| 25 extern int gMaxRecursion[]; |
| 26 #endif |
14 | 27 |
15 /** \class SkStroke | 28 /** \class SkStroke |
16 SkStroke is the utility class that constructs paths by stroking | 29 SkStroke is the utility class that constructs paths by stroking |
17 geometries (lines, rects, ovals, roundrects, paths). This is | 30 geometries (lines, rects, ovals, roundrects, paths). This is |
18 invoked when a geometry or text is drawn in a canvas with the | 31 invoked when a geometry or text is drawn in a canvas with the |
19 kStroke_Mask bit set in the paint. | 32 kStroke_Mask bit set in the paint. |
20 */ | 33 */ |
21 class SkStroke { | 34 class SkStroke { |
22 public: | 35 public: |
23 SkStroke(); | 36 SkStroke(); |
24 SkStroke(const SkPaint&); | 37 SkStroke(const SkPaint&); |
25 SkStroke(const SkPaint&, SkScalar width); // width overrides paint.getStro
keWidth() | 38 SkStroke(const SkPaint&, SkScalar width); // width overrides paint.getStro
keWidth() |
26 | 39 |
27 SkPaint::Cap getCap() const { return (SkPaint::Cap)fCap; } | 40 SkPaint::Cap getCap() const { return (SkPaint::Cap)fCap; } |
28 void setCap(SkPaint::Cap); | 41 void setCap(SkPaint::Cap); |
29 | 42 |
30 SkPaint::Join getJoin() const { return (SkPaint::Join)fJoin; } | 43 SkPaint::Join getJoin() const { return (SkPaint::Join)fJoin; } |
31 void setJoin(SkPaint::Join); | 44 void setJoin(SkPaint::Join); |
32 | 45 |
| 46 #if QUAD_STROKE_APPROXIMATION |
| 47 void setError(SkScalar); |
| 48 #endif |
33 void setMiterLimit(SkScalar); | 49 void setMiterLimit(SkScalar); |
34 void setWidth(SkScalar); | 50 void setWidth(SkScalar); |
35 | 51 |
36 bool getDoFill() const { return SkToBool(fDoFill); } | 52 bool getDoFill() const { return SkToBool(fDoFill); } |
37 void setDoFill(bool doFill) { fDoFill = SkToU8(doFill); } | 53 void setDoFill(bool doFill) { fDoFill = SkToU8(doFill); } |
38 | 54 |
39 /** | 55 /** |
40 * Stroke the specified rect, winding it in the specified direction.. | 56 * Stroke the specified rect, winding it in the specified direction.. |
41 */ | 57 */ |
42 void strokeRect(const SkRect& rect, SkPath* result, | 58 void strokeRect(const SkRect& rect, SkPath* result, |
43 SkPath::Direction = SkPath::kCW_Direction) const; | 59 SkPath::Direction = SkPath::kCW_Direction) const; |
44 void strokePath(const SkPath& path, SkPath*) const; | 60 void strokePath(const SkPath& path, SkPath*) const; |
45 | 61 |
46 //////////////////////////////////////////////////////////////// | 62 //////////////////////////////////////////////////////////////// |
47 | 63 |
48 private: | 64 private: |
| 65 #if QUAD_STROKE_APPROXIMATION |
| 66 SkScalar fError; |
| 67 #endif |
49 SkScalar fWidth, fMiterLimit; | 68 SkScalar fWidth, fMiterLimit; |
50 uint8_t fCap, fJoin; | 69 uint8_t fCap, fJoin; |
51 SkBool8 fDoFill; | 70 SkBool8 fDoFill; |
52 | 71 |
53 friend class SkPaint; | 72 friend class SkPaint; |
54 }; | 73 }; |
55 | 74 |
56 #endif | 75 #endif |
OLD | NEW |