reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2006 The Android Open Source Project |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 3 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 8 | #ifndef SkStroke_DEFINED |
| 9 | #define SkStroke_DEFINED |
| 10 | |
reed@google.com | 04fdaa1 | 2012-11-21 15:48:20 +0000 | [diff] [blame] | 11 | #include "SkPath.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 12 | #include "SkPoint.h" |
| 13 | #include "SkPaint.h" |
caryclark | feff7d2 | 2014-10-09 05:36:03 -0700 | [diff] [blame^] | 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 |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 27 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 28 | /** \class SkStroke |
| 29 | SkStroke is the utility class that constructs paths by stroking |
| 30 | geometries (lines, rects, ovals, roundrects, paths). This is |
| 31 | invoked when a geometry or text is drawn in a canvas with the |
| 32 | kStroke_Mask bit set in the paint. |
| 33 | */ |
| 34 | class SkStroke { |
| 35 | public: |
| 36 | SkStroke(); |
| 37 | SkStroke(const SkPaint&); |
| 38 | SkStroke(const SkPaint&, SkScalar width); // width overrides paint.getStrokeWidth() |
| 39 | |
| 40 | SkPaint::Cap getCap() const { return (SkPaint::Cap)fCap; } |
| 41 | void setCap(SkPaint::Cap); |
| 42 | |
| 43 | SkPaint::Join getJoin() const { return (SkPaint::Join)fJoin; } |
| 44 | void setJoin(SkPaint::Join); |
| 45 | |
caryclark | feff7d2 | 2014-10-09 05:36:03 -0700 | [diff] [blame^] | 46 | #if QUAD_STROKE_APPROXIMATION |
| 47 | void setError(SkScalar); |
| 48 | #endif |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 49 | void setMiterLimit(SkScalar); |
| 50 | void setWidth(SkScalar); |
| 51 | |
| 52 | bool getDoFill() const { return SkToBool(fDoFill); } |
| 53 | void setDoFill(bool doFill) { fDoFill = SkToU8(doFill); } |
| 54 | |
reed@google.com | 04fdaa1 | 2012-11-21 15:48:20 +0000 | [diff] [blame] | 55 | /** |
| 56 | * Stroke the specified rect, winding it in the specified direction.. |
| 57 | */ |
| 58 | void strokeRect(const SkRect& rect, SkPath* result, |
| 59 | SkPath::Direction = SkPath::kCW_Direction) const; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 60 | void strokePath(const SkPath& path, SkPath*) const; |
| 61 | |
| 62 | //////////////////////////////////////////////////////////////// |
| 63 | |
| 64 | private: |
caryclark | feff7d2 | 2014-10-09 05:36:03 -0700 | [diff] [blame^] | 65 | #if QUAD_STROKE_APPROXIMATION |
| 66 | SkScalar fError; |
| 67 | #endif |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 68 | SkScalar fWidth, fMiterLimit; |
| 69 | uint8_t fCap, fJoin; |
| 70 | SkBool8 fDoFill; |
| 71 | |
| 72 | friend class SkPaint; |
| 73 | }; |
| 74 | |
| 75 | #endif |