• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef SkStroke_DEFINED
18 #define SkStroke_DEFINED
19 
20 #include "SkPoint.h"
21 #include "SkPaint.h"
22 
23 struct SkRect;
24 class SkPath;
25 
26 #define SK_DefaultStrokeWidth       SK_Scalar1
27 #define SK_DefaultMiterLimit        SkIntToScalar(4)
28 
29 
30 /** \class SkStroke
31     SkStroke is the utility class that constructs paths by stroking
32     geometries (lines, rects, ovals, roundrects, paths). This is
33     invoked when a geometry or text is drawn in a canvas with the
34     kStroke_Mask bit set in the paint.
35 */
36 class SkStroke {
37 public:
38     SkStroke();
39     SkStroke(const SkPaint&);
40     SkStroke(const SkPaint&, SkScalar width);   // width overrides paint.getStrokeWidth()
41 
getCap()42     SkPaint::Cap    getCap() const { return (SkPaint::Cap)fCap; }
43     void        setCap(SkPaint::Cap);
44 
getJoin()45     SkPaint::Join   getJoin() const { return (SkPaint::Join)fJoin; }
46     void        setJoin(SkPaint::Join);
47 
48     void    setMiterLimit(SkScalar);
49     void    setWidth(SkScalar);
50 
getDoFill()51     bool    getDoFill() const { return SkToBool(fDoFill); }
setDoFill(bool doFill)52     void    setDoFill(bool doFill) { fDoFill = SkToU8(doFill); }
53 
54     void    strokeLine(const SkPoint& start, const SkPoint& end, SkPath*) const;
55     void    strokeRect(const SkRect& rect, SkPath*) const;
56     void    strokeOval(const SkRect& oval, SkPath*) const;
57     void    strokeRRect(const SkRect& rect, SkScalar rx, SkScalar ry, SkPath*) const;
58     void    strokePath(const SkPath& path, SkPath*) const;
59 
60     ////////////////////////////////////////////////////////////////
61 
62 private:
63     SkScalar    fWidth, fMiterLimit;
64     uint8_t     fCap, fJoin;
65     SkBool8     fDoFill;
66 
67     friend class SkPaint;
68 };
69 
70 #endif
71 
72