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

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

Issue 23021015: Initial error handling code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: New serialization method Created 7 years, 3 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 | Annotate | Revision Log
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
11 #define SkXfermode_DEFINED 11 #define SkXfermode_DEFINED
12 12
13 #include "SkFlattenable.h" 13 #include "SkFlattenable.h"
14 #include "SkColor.h" 14 #include "SkColor.h"
15 15
16 class GrContext; 16 class GrContext;
17 class GrEffectRef; 17 class GrEffectRef;
18 class GrTexture; 18 class GrTexture;
19 class SkString; 19 class SkString;
20 20
21 /** \class SkXfermode 21 /** \class SkXfermode
22 22
23 SkXfermode is the base class for objects that are called to implement custom 23 SkXfermode is the base class for objects that are called to implement custom
24 "transfer-modes" in the drawing pipeline. The static function Create(Modes) 24 "transfer-modes" in the drawing pipeline. The static function Create(Modes)
25 can be called to return an instance of any of the predefined subclasses as 25 can be called to return an instance of any of the predefined subclasses as
26 specified in the Modes enum. When an SkXfermode is assigned to an SkPaint, 26 specified in the Modes enum. When an SkXfermode is assigned to an SkPaint,
27 then objects drawn with that paint have the xfermode applied. 27 then objects drawn with that paint have the xfermode applied.
28 */ 28 */
29 class SK_API SkXfermode : public SkFlattenable { 29 class SK_API SkXfermode : public SkFlattenable {
30 typedef SkFlattenable INHERITED;
31
30 public: 32 public:
31 SK_DECLARE_INST_COUNT(SkXfermode) 33 SK_DECLARE_INST_COUNT(SkXfermode)
32 34
33 SkXfermode() {} 35 SkXfermode() {}
34 36
35 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, 37 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
36 const SkAlpha aa[]) const; 38 const SkAlpha aa[]) const;
37 virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, 39 virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count,
38 const SkAlpha aa[]) const; 40 const SkAlpha aa[]) const;
39 virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, 41 virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count,
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 */ 215 */
214 static bool AsNewEffectOrCoeff(SkXfermode*, 216 static bool AsNewEffectOrCoeff(SkXfermode*,
215 GrContext*, 217 GrContext*,
216 GrEffectRef** effect, 218 GrEffectRef** effect,
217 Coeff* src, 219 Coeff* src,
218 Coeff* dst, 220 Coeff* dst,
219 GrTexture* background = NULL); 221 GrTexture* background = NULL);
220 222
221 SkDEVCODE(virtual void toString(SkString* str) const = 0;) 223 SkDEVCODE(virtual void toString(SkString* str) const = 0;)
222 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() 224 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
225 SK_DEFINE_FLATTENABLE_TYPE(SkXfermode)
223 protected: 226 protected:
224 SkXfermode(SkFlattenableReadBuffer& rb) : SkFlattenable(rb) {} 227 SkXfermode(SkFlattenableReadBuffer& rb) : SkFlattenable(rb) {}
225 228
226 /** The default implementation of xfer32/xfer16/xferA8 in turn call this 229 /** The default implementation of xfer32/xfer16/xferA8 in turn call this
227 method, 1 color at a time (upscaled to a SkPMColor). The default 230 method, 1 color at a time (upscaled to a SkPMColor). The default
228 implmentation of this method just returns dst. If performance is 231 implmentation of this method just returns dst. If performance is
229 important, your subclass should override xfer32/xfer16/xferA8 directly. 232 important, your subclass should override xfer32/xfer16/xferA8 directly.
230 233
231 This method will not be called directly by the client, so it need not 234 This method will not be called directly by the client, so it need not
232 be implemented if your subclass has overridden xfer32/xfer16/xferA8 235 be implemented if your subclass has overridden xfer32/xfer16/xferA8
233 */ 236 */
234 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const; 237 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const;
235 238
236 private: 239 private:
237 enum { 240 enum {
238 kModeCount = kLastMode + 1 241 kModeCount = kLastMode + 1
239 }; 242 };
240 typedef SkFlattenable INHERITED;
241 }; 243 };
242 244
243 /////////////////////////////////////////////////////////////////////////////// 245 ///////////////////////////////////////////////////////////////////////////////
244 246
245 /** \class SkProcXfermode 247 /** \class SkProcXfermode
246 248
247 SkProcXfermode is a xfermode that applies the specified proc to its colors. 249 SkProcXfermode is a xfermode that applies the specified proc to its colors.
248 This class is not exported to java. 250 This class is not exported to java.
249 */ 251 */
250 class SkProcXfermode : public SkXfermode { 252 class SkProcXfermode : public SkXfermode {
253 typedef SkXfermode INHERITED;
254
251 public: 255 public:
252 SkProcXfermode(SkXfermodeProc proc) : fProc(proc) {} 256 SkProcXfermode(SkXfermodeProc proc) : fProc(proc) {}
253 257
254 // overrides from SkXfermode 258 // overrides from SkXfermode
255 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, 259 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
256 const SkAlpha aa[]) const SK_OVERRIDE; 260 const SkAlpha aa[]) const SK_OVERRIDE;
257 virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, 261 virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count,
258 const SkAlpha aa[]) const SK_OVERRIDE; 262 const SkAlpha aa[]) const SK_OVERRIDE;
259 virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, 263 virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count,
260 const SkAlpha aa[]) const SK_OVERRIDE; 264 const SkAlpha aa[]) const SK_OVERRIDE;
261 265
262 SK_DEVELOPER_TO_STRING() 266 SK_DEVELOPER_TO_STRING()
263 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcXfermode) 267 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcXfermode)
268 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_UTILS()
264 269
265 protected: 270 protected:
266 SkProcXfermode(SkFlattenableReadBuffer&); 271 SkProcXfermode(SkFlattenableReadBuffer&);
267 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; 272 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
268 273
269 // allow subclasses to update this after we unflatten 274 // allow subclasses to update this after we unflatten
270 void setProc(SkXfermodeProc proc) { 275 void setProc(SkXfermodeProc proc) {
271 fProc = proc; 276 fProc = proc;
272 } 277 }
273 278
274 private: 279 private:
275 SkXfermodeProc fProc; 280 SkXfermodeProc fProc;
276
277 typedef SkXfermode INHERITED;
278 }; 281 };
279 282
280 #endif 283 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698