OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
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 GrStrokeInfo_DEFINED | 8 #ifndef GrStrokeInfo_DEFINED |
9 #define GrStrokeInfo_DEFINED | 9 #define GrStrokeInfo_DEFINED |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... | |
37 fStroke(paint, styleOverride), fDashType(SkPathEffect::kNone_DashType) { | 37 fStroke(paint, styleOverride), fDashType(SkPathEffect::kNone_DashType) { |
38 this->init(paint); | 38 this->init(paint); |
39 } | 39 } |
40 | 40 |
41 | 41 |
42 explicit GrStrokeInfo(const SkPaint& paint) : | 42 explicit GrStrokeInfo(const SkPaint& paint) : |
43 fStroke(paint), fDashType(SkPathEffect::kNone_DashType) { | 43 fStroke(paint), fDashType(SkPathEffect::kNone_DashType) { |
44 this->init(paint); | 44 this->init(paint); |
45 } | 45 } |
46 | 46 |
47 GrStrokeInfo& operator=(const GrStrokeInfo& other) { | |
48 fStroke = other.fStroke; | |
49 fDashInfo = other.fDashInfo; | |
50 fDashType = other.fDashType; | |
51 fIntervals.reset(other.dashCount()); | |
52 memcpy(fIntervals.get(), other.fIntervals.get(), other.dashCount() * siz eof(SkScalar)); | |
53 return *this; | |
54 } | |
55 | |
47 const SkStrokeRec& getStrokeRec() const { return fStroke; } | 56 const SkStrokeRec& getStrokeRec() const { return fStroke; } |
48 | 57 |
49 SkStrokeRec* getStrokeRecPtr() { return &fStroke; } | 58 SkStrokeRec* getStrokeRecPtr() { return &fStroke; } |
50 | 59 |
51 void setFillStyle() { fStroke.setFillStyle(); } | 60 void setFillStyle() { fStroke.setFillStyle(); } |
52 | 61 |
53 /* | 62 /* |
54 * This functions takes in a patheffect and fills in fDashInfo with the vari ous dashing | 63 * This functions takes in a patheffect and fills in fDashInfo with the vari ous dashing |
55 * information if the path effect is a Dash type. Returns true if the path e ffect is a | 64 * information if the path effect is a Dash type. Returns true if the path e ffect is a |
56 * dashed effect and we are stroking, otherwise it retruns false. | 65 * dashed effect and we are stroking, otherwise it retruns false. |
57 */ | 66 */ |
58 bool setDashInfo(const SkPathEffect* pe) { | 67 bool setDashInfo(const SkPathEffect* pe) { |
59 if (pe && !fStroke.isFillStyle()) { | 68 if (pe && !fStroke.isFillStyle()) { |
60 fDashInfo.fIntervals = NULL; | 69 fDashInfo.fIntervals = NULL; |
61 fDashType = pe->asADash(&fDashInfo); | 70 fDashType = pe->asADash(&fDashInfo); |
62 if (SkPathEffect::kDash_DashType == fDashType) { | 71 if (SkPathEffect::kDash_DashType == fDashType) { |
63 fIntervals.reset(fDashInfo.fCount); | 72 fIntervals.reset(fDashInfo.fCount); |
64 fDashInfo.fIntervals = fIntervals.get(); | 73 fDashInfo.fIntervals = fIntervals.get(); |
65 pe->asADash(&fDashInfo); | 74 pe->asADash(&fDashInfo); |
66 return true; | 75 return true; |
67 } | 76 } |
68 } | 77 } |
69 return false; | 78 return false; |
70 } | 79 } |
71 | 80 |
72 bool isDashed() const { | 81 bool isDashed() const { |
73 return (!fStroke.isFillStyle() && SkPathEffect::kDash_DashType == fDashT ype); | 82 return (!fStroke.isFillStyle() && SkPathEffect::kDash_DashType == fDashT ype); |
74 } | 83 } |
75 | 84 |
85 bool isFillStyle() const { return fStroke.isFillStyle(); } | |
86 | |
76 int32_t dashCount() const { | 87 int32_t dashCount() const { |
77 return fDashInfo.fCount; | 88 return fDashInfo.fCount; |
78 } | 89 } |
79 | 90 |
80 void removeDash() { | 91 void removeDash() { |
81 fDashType = SkPathEffect::kNone_DashType; | 92 fDashType = SkPathEffect::kNone_DashType; |
82 } | 93 } |
83 | 94 |
84 const SkPathEffect::DashInfo& getDashInfo() const { return fDashInfo; } | 95 const SkPathEffect::DashInfo& getDashInfo() const { return fDashInfo; } |
85 | 96 |
97 bool applyDash(SkPath* dst, GrStrokeInfo* dstStrokeInfo, const SkPath& src) const; | |
bsalomon
2015/04/24 15:56:46
Maybe a comment that if this returns false, then t
Kimmo Kinnunen
2015/04/27 06:12:25
Done.
| |
98 | |
86 private: | 99 private: |
87 | 100 |
88 void init(const SkPaint& paint) { | 101 void init(const SkPaint& paint) { |
89 const SkPathEffect* pe = paint.getPathEffect(); | 102 const SkPathEffect* pe = paint.getPathEffect(); |
90 this->setDashInfo(pe); | 103 this->setDashInfo(pe); |
91 } | 104 } |
92 | 105 |
93 SkStrokeRec fStroke; | 106 SkStrokeRec fStroke; |
94 SkPathEffect::DashType fDashType; | 107 SkPathEffect::DashType fDashType; |
95 SkPathEffect::DashInfo fDashInfo; | 108 SkPathEffect::DashInfo fDashInfo; |
96 SkAutoSTArray<2, SkScalar> fIntervals; | 109 SkAutoSTArray<2, SkScalar> fIntervals; |
97 }; | 110 }; |
98 | 111 |
99 #endif | 112 #endif |
OLD | NEW |