Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: include/core/SkPathEffect.h

Issue 166583002: Factory methods for heap-allocated SkPathEffect and SkXfermode objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: guard constructors by SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS if used by Chrome. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkPathEffect_DEFINED 10 #ifndef SkPathEffect_DEFINED
(...skipping 13 matching lines...) Expand all
24 SkPathEffect is the base class for objects in the SkPaint that affect 24 SkPathEffect is the base class for objects in the SkPaint that affect
25 the geometry of a drawing primitive before it is transformed by the 25 the geometry of a drawing primitive before it is transformed by the
26 canvas' matrix and drawn. 26 canvas' matrix and drawn.
27 27
28 Dashing is implemented as a subclass of SkPathEffect. 28 Dashing is implemented as a subclass of SkPathEffect.
29 */ 29 */
30 class SK_API SkPathEffect : public SkFlattenable { 30 class SK_API SkPathEffect : public SkFlattenable {
31 public: 31 public:
32 SK_DECLARE_INST_COUNT(SkPathEffect) 32 SK_DECLARE_INST_COUNT(SkPathEffect)
33 33
34 SkPathEffect() {}
35
36 /** 34 /**
37 * Given a src path (input) and a stroke-rec (input and output), apply 35 * Given a src path (input) and a stroke-rec (input and output), apply
38 * this effect to the src path, returning the new path in dst, and return 36 * this effect to the src path, returning the new path in dst, and return
39 * true. If this effect cannot be applied, return false and ignore dst 37 * true. If this effect cannot be applied, return false and ignore dst
40 * and stroke-rec. 38 * and stroke-rec.
41 * 39 *
42 * The stroke-rec specifies the initial request for stroking (if any). 40 * The stroke-rec specifies the initial request for stroking (if any).
43 * The effect can treat this as input only, or it can choose to change 41 * The effect can treat this as input only, or it can choose to change
44 * the rec as well. For example, the effect can decide to change the 42 * the rec as well. For example, the effect can decide to change the
45 * stroke's width or join, or the effect can change the rec from stroke 43 * stroke's width or join, or the effect can change the rec from stroke
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 * Does applying this path effect to 'src' yield a set of points? If so, 100 * Does applying this path effect to 'src' yield a set of points? If so,
103 * optionally return the points in 'results'. 101 * optionally return the points in 'results'.
104 */ 102 */
105 virtual bool asPoints(PointData* results, const SkPath& src, 103 virtual bool asPoints(PointData* results, const SkPath& src,
106 const SkStrokeRec&, const SkMatrix&, 104 const SkStrokeRec&, const SkMatrix&,
107 const SkRect* cullR) const; 105 const SkRect* cullR) const;
108 106
109 SK_DEFINE_FLATTENABLE_TYPE(SkPathEffect) 107 SK_DEFINE_FLATTENABLE_TYPE(SkPathEffect)
110 108
111 protected: 109 protected:
110 SkPathEffect() {}
scroggo 2014/02/18 16:53:11 I guess the constructors that aren't public behind
Dominik Grewe 2014/02/18 17:05:30 Yes. I've patched this into Chrome and it's workin
112 SkPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {} 111 SkPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
113 112
114 private: 113 private:
115 // illegal 114 // illegal
116 SkPathEffect(const SkPathEffect&); 115 SkPathEffect(const SkPathEffect&);
117 SkPathEffect& operator=(const SkPathEffect&); 116 SkPathEffect& operator=(const SkPathEffect&);
118 117
119 typedef SkFlattenable INHERITED; 118 typedef SkFlattenable INHERITED;
120 }; 119 };
121 120
122 /** \class SkPairPathEffect 121 /** \class SkPairPathEffect
123 122
124 Common baseclass for Compose and Sum. This subclass manages two pathEffects, 123 Common baseclass for Compose and Sum. This subclass manages two pathEffects,
125 including flattening them. It does nothing in filterPath, and is only useful 124 including flattening them. It does nothing in filterPath, and is only useful
126 for managing the lifetimes of its two arguments. 125 for managing the lifetimes of its two arguments.
127 */ 126 */
128 class SkPairPathEffect : public SkPathEffect { 127 class SkPairPathEffect : public SkPathEffect {
129 public: 128 public:
130 SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1);
131 virtual ~SkPairPathEffect(); 129 virtual ~SkPairPathEffect();
132 130
133 protected: 131 protected:
132 SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1);
134 SkPairPathEffect(SkReadBuffer&); 133 SkPairPathEffect(SkReadBuffer&);
135 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 134 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
136 135
137 // these are visible to our subclasses 136 // these are visible to our subclasses
138 SkPathEffect* fPE0, *fPE1; 137 SkPathEffect* fPE0, *fPE1;
139 138
140 private: 139 private:
141 typedef SkPathEffect INHERITED; 140 typedef SkPathEffect INHERITED;
142 }; 141 };
143 142
144 /** \class SkComposePathEffect 143 /** \class SkComposePathEffect
145 144
146 This subclass of SkPathEffect composes its two arguments, to create 145 This subclass of SkPathEffect composes its two arguments, to create
147 a compound pathEffect. 146 a compound pathEffect.
148 */ 147 */
149 class SkComposePathEffect : public SkPairPathEffect { 148 class SkComposePathEffect : public SkPairPathEffect {
150 public: 149 public:
151 /** Construct a pathEffect whose effect is to apply first the inner pathEffe ct 150 /** Construct a pathEffect whose effect is to apply first the inner pathEffe ct
152 and the the outer pathEffect (e.g. outer(inner(path))) 151 and the the outer pathEffect (e.g. outer(inner(path)))
153 The reference counts for outer and inner are both incremented in the con structor, 152 The reference counts for outer and inner are both incremented in the con structor,
154 and decremented in the destructor. 153 and decremented in the destructor.
155 */ 154 */
156 SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner) 155 static SkComposePathEffect* Create(SkPathEffect* outer, SkPathEffect* inner) {
157 : INHERITED(outer, inner) {} 156 return SkNEW_ARGS(SkComposePathEffect, (outer, inner));
157 }
158 158
159 virtual bool filterPath(SkPath* dst, const SkPath& src, 159 virtual bool filterPath(SkPath* dst, const SkPath& src,
160 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; 160 SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
161 161
162 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect) 162 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect)
163 163
164 protected: 164 protected:
165 SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner)
166 : INHERITED(outer, inner) {}
165 SkComposePathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {} 167 SkComposePathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
166 168
167 private: 169 private:
168 // illegal 170 // illegal
169 SkComposePathEffect(const SkComposePathEffect&); 171 SkComposePathEffect(const SkComposePathEffect&);
170 SkComposePathEffect& operator=(const SkComposePathEffect&); 172 SkComposePathEffect& operator=(const SkComposePathEffect&);
171 173
172 typedef SkPairPathEffect INHERITED; 174 typedef SkPairPathEffect INHERITED;
173 }; 175 };
174 176
175 /** \class SkSumPathEffect 177 /** \class SkSumPathEffect
176 178
177 This subclass of SkPathEffect applies two pathEffects, one after the other. 179 This subclass of SkPathEffect applies two pathEffects, one after the other.
178 Its filterPath() returns true if either of the effects succeeded. 180 Its filterPath() returns true if either of the effects succeeded.
179 */ 181 */
180 class SkSumPathEffect : public SkPairPathEffect { 182 class SkSumPathEffect : public SkPairPathEffect {
181 public: 183 public:
182 /** Construct a pathEffect whose effect is to apply two effects, in sequence . 184 /** Construct a pathEffect whose effect is to apply two effects, in sequence .
183 (e.g. first(path) + second(path)) 185 (e.g. first(path) + second(path))
184 The reference counts for first and second are both incremented in the co nstructor, 186 The reference counts for first and second are both incremented in the co nstructor,
185 and decremented in the destructor. 187 and decremented in the destructor.
186 */ 188 */
187 SkSumPathEffect(SkPathEffect* first, SkPathEffect* second) 189 static SkSumPathEffect* Create(SkPathEffect* first, SkPathEffect* second) {
188 : INHERITED(first, second) {} 190 return SkNEW_ARGS(SkSumPathEffect, (first, second));
191 }
189 192
190 virtual bool filterPath(SkPath* dst, const SkPath& src, 193 virtual bool filterPath(SkPath* dst, const SkPath& src,
191 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; 194 SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
192 195
193 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect) 196 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect)
194 197
195 protected: 198 protected:
199 SkSumPathEffect(SkPathEffect* first, SkPathEffect* second)
200 : INHERITED(first, second) {}
196 SkSumPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {} 201 SkSumPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
197 202
198 private: 203 private:
199 // illegal 204 // illegal
200 SkSumPathEffect(const SkSumPathEffect&); 205 SkSumPathEffect(const SkSumPathEffect&);
201 SkSumPathEffect& operator=(const SkSumPathEffect&); 206 SkSumPathEffect& operator=(const SkSumPathEffect&);
202 207
203 typedef SkPairPathEffect INHERITED; 208 typedef SkPairPathEffect INHERITED;
204 }; 209 };
205 210
206 #endif 211 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698