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 : #define SK_DefaultStrokeWidth SK_Scalar1
20 : #define SK_DefaultMiterLimit SkIntToScalar(4)
21 :
22 :
23 : /** \class SkStroke
24 : SkStroke is the utility class that constructs paths by stroking
25 : geometries (lines, rects, ovals, roundrects, paths). This is
26 : invoked when a geometry or text is drawn in a canvas with the
27 : kStroke_Mask bit set in the paint.
28 : */
29 : class SkStroke {
30 : public:
31 : SkStroke();
32 : SkStroke(const SkPaint&);
33 : SkStroke(const SkPaint&, SkScalar width); // width overrides paint.getStrokeWidth()
34 :
35 0 : SkPaint::Cap getCap() const { return (SkPaint::Cap)fCap; }
36 : void setCap(SkPaint::Cap);
37 :
38 0 : SkPaint::Join getJoin() const { return (SkPaint::Join)fJoin; }
39 : void setJoin(SkPaint::Join);
40 :
41 : void setMiterLimit(SkScalar);
42 : void setWidth(SkScalar);
43 :
44 : bool getDoFill() const { return SkToBool(fDoFill); }
45 0 : void setDoFill(bool doFill) { fDoFill = SkToU8(doFill); }
46 :
47 : void strokeLine(const SkPoint& start, const SkPoint& end, SkPath*) const;
48 : void strokeRect(const SkRect& rect, SkPath*) const;
49 : void strokeOval(const SkRect& oval, SkPath*) const;
50 : void strokeRRect(const SkRect& rect, SkScalar rx, SkScalar ry, SkPath*) const;
51 : void strokePath(const SkPath& path, SkPath*) const;
52 :
53 : ////////////////////////////////////////////////////////////////
54 :
55 : private:
56 : SkScalar fWidth, fMiterLimit;
57 : uint8_t fCap, fJoin;
58 : SkBool8 fDoFill;
59 :
60 : friend class SkPaint;
61 : };
62 :
63 : #endif
64 :
|