1 2 /* 3 * Copyright 2006 The Android Open Source Project 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9 10 #ifndef SkStroke_DEFINED 11 #define SkStroke_DEFINED 12 13 #include "SkPoint.h" 14 #include "SkPaint.h" 15 16 struct SkRect; 17 class SkPath; 18 19 /** \class SkStroke 20 SkStroke is the utility class that constructs paths by stroking 21 geometries (lines, rects, ovals, roundrects, paths). This is 22 invoked when a geometry or text is drawn in a canvas with the 23 kStroke_Mask bit set in the paint. 24 */ 25 class SkStroke { 26 public: 27 SkStroke(); 28 SkStroke(const SkPaint&); 29 SkStroke(const SkPaint&, SkScalar width); // width overrides paint.getStrokeWidth() 30 getCap()31 SkPaint::Cap getCap() const { return (SkPaint::Cap)fCap; } 32 void setCap(SkPaint::Cap); 33 getJoin()34 SkPaint::Join getJoin() const { return (SkPaint::Join)fJoin; } 35 void setJoin(SkPaint::Join); 36 37 void setMiterLimit(SkScalar); 38 void setWidth(SkScalar); 39 getDoFill()40 bool getDoFill() const { return SkToBool(fDoFill); } setDoFill(bool doFill)41 void setDoFill(bool doFill) { fDoFill = SkToU8(doFill); } 42 43 void strokeLine(const SkPoint& start, const SkPoint& end, SkPath*) const; 44 void strokeRect(const SkRect& rect, SkPath*) const; 45 void strokeOval(const SkRect& oval, SkPath*) const; 46 void strokeRRect(const SkRect& rect, SkScalar rx, SkScalar ry, SkPath*) const; 47 void strokePath(const SkPath& path, SkPath*) const; 48 49 //////////////////////////////////////////////////////////////// 50 51 private: 52 SkScalar fWidth, fMiterLimit; 53 uint8_t fCap, fJoin; 54 SkBool8 fDoFill; 55 56 friend class SkPaint; 57 }; 58 59 #endif 60 61