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

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

Issue 166583002: Factory methods for heap-allocated SkPathEffect and SkXfermode objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update experimental/PdfViewer 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
« no previous file with comments | « include/core/SkPathEffect.h ('k') | include/effects/Sk1DPathEffect.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 SkXfermode_DEFINED 10 #ifndef SkXfermode_DEFINED
(...skipping 14 matching lines...) Expand all
25 * specified in the Modes enum. When an SkXfermode is assigned to an SkPaint, 25 * specified in the Modes enum. When an SkXfermode is assigned to an SkPaint,
26 * then objects drawn with that paint have the xfermode applied. 26 * then objects drawn with that paint have the xfermode applied.
27 * 27 *
28 * All subclasses are required to be reentrant-safe : it must be legal to share 28 * All subclasses are required to be reentrant-safe : it must be legal to share
29 * the same instance between several threads. 29 * the same instance between several threads.
30 */ 30 */
31 class SK_API SkXfermode : public SkFlattenable { 31 class SK_API SkXfermode : public SkFlattenable {
32 public: 32 public:
33 SK_DECLARE_INST_COUNT(SkXfermode) 33 SK_DECLARE_INST_COUNT(SkXfermode)
34 34
35 SkXfermode() {}
36
37 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, 35 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
38 const SkAlpha aa[]) const; 36 const SkAlpha aa[]) const;
39 virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, 37 virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count,
40 const SkAlpha aa[]) const; 38 const SkAlpha aa[]) const;
41 virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, 39 virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count,
42 const SkAlpha aa[]) const; 40 const SkAlpha aa[]) const;
43 41
44 /** Enum of possible coefficients to describe some xfermodes 42 /** Enum of possible coefficients to describe some xfermodes
45 */ 43 */
46 enum Coeff { 44 enum Coeff {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 /** The default implementation of xfer32/xfer16/xferA8 in turn call this 221 /** The default implementation of xfer32/xfer16/xferA8 in turn call this
224 method, 1 color at a time (upscaled to a SkPMColor). The default 222 method, 1 color at a time (upscaled to a SkPMColor). The default
225 implmentation of this method just returns dst. If performance is 223 implmentation of this method just returns dst. If performance is
226 important, your subclass should override xfer32/xfer16/xferA8 directly. 224 important, your subclass should override xfer32/xfer16/xferA8 directly.
227 225
228 This method will not be called directly by the client, so it need not 226 This method will not be called directly by the client, so it need not
229 be implemented if your subclass has overridden xfer32/xfer16/xferA8 227 be implemented if your subclass has overridden xfer32/xfer16/xferA8
230 */ 228 */
231 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const; 229 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const;
232 230
231 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
232 public:
233 #endif
234 SkXfermode() {}
235
233 private: 236 private:
234 enum { 237 enum {
235 kModeCount = kLastMode + 1 238 kModeCount = kLastMode + 1
236 }; 239 };
237 240
238 friend class SkGraphics; 241 friend class SkGraphics;
239 static void Term(); 242 static void Term();
240 243
241 typedef SkFlattenable INHERITED; 244 typedef SkFlattenable INHERITED;
242 }; 245 };
243 246
244 /////////////////////////////////////////////////////////////////////////////// 247 ///////////////////////////////////////////////////////////////////////////////
245 248
246 /** \class SkProcXfermode 249 /** \class SkProcXfermode
247 250
248 SkProcXfermode is a xfermode that applies the specified proc to its colors. 251 SkProcXfermode is a xfermode that applies the specified proc to its colors.
249 This class is not exported to java. 252 This class is not exported to java.
250 */ 253 */
251 class SkProcXfermode : public SkXfermode { 254 class SkProcXfermode : public SkXfermode {
252 public: 255 public:
253 SkProcXfermode(SkXfermodeProc proc) : fProc(proc) {} 256 static SkProcXfermode* Create(SkXfermodeProc proc) {
257 return SkNEW_ARGS(SkProcXfermode, (proc));
258 }
254 259
255 // overrides from SkXfermode 260 // overrides from SkXfermode
256 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, 261 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
257 const SkAlpha aa[]) const SK_OVERRIDE; 262 const SkAlpha aa[]) const SK_OVERRIDE;
258 virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, 263 virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count,
259 const SkAlpha aa[]) const SK_OVERRIDE; 264 const SkAlpha aa[]) const SK_OVERRIDE;
260 virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, 265 virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count,
261 const SkAlpha aa[]) const SK_OVERRIDE; 266 const SkAlpha aa[]) const SK_OVERRIDE;
262 267
263 SK_DEVELOPER_TO_STRING() 268 SK_DEVELOPER_TO_STRING()
264 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcXfermode) 269 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcXfermode)
265 270
266 protected: 271 protected:
267 SkProcXfermode(SkReadBuffer&); 272 SkProcXfermode(SkReadBuffer&);
268 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 273 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
269 274
270 // allow subclasses to update this after we unflatten 275 // allow subclasses to update this after we unflatten
271 void setProc(SkXfermodeProc proc) { 276 void setProc(SkXfermodeProc proc) {
272 fProc = proc; 277 fProc = proc;
273 } 278 }
274 279
275 SkXfermodeProc getProc() const { 280 SkXfermodeProc getProc() const {
276 return fProc; 281 return fProc;
277 } 282 }
278 283
284 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
285 public:
286 #endif
287 SkProcXfermode(SkXfermodeProc proc) : fProc(proc) {}
288
279 private: 289 private:
280 SkXfermodeProc fProc; 290 SkXfermodeProc fProc;
281 291
282 typedef SkXfermode INHERITED; 292 typedef SkXfermode INHERITED;
283 }; 293 };
284 294
285 #endif 295 #endif
OLDNEW
« no previous file with comments | « include/core/SkPathEffect.h ('k') | include/effects/Sk1DPathEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698