OLD | NEW |
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 GrEffectRef; | 16 class GrEffectRef; |
17 class GrTexture; | 17 class GrTexture; |
18 class SkString; | 18 class SkString; |
19 | 19 |
20 //#define SK_SUPPORT_LEGACY_PROCXFERMODE | |
21 | |
22 /** \class SkXfermode | 20 /** \class SkXfermode |
23 * | 21 * |
24 * SkXfermode is the base class for objects that are called to implement custom | 22 * SkXfermode is the base class for objects that are called to implement custom |
25 * "transfer-modes" in the drawing pipeline. The static function Create(Modes) | 23 * "transfer-modes" in the drawing pipeline. The static function Create(Modes) |
26 * can be called to return an instance of any of the predefined subclasses as | 24 * can be called to return an instance of any of the predefined subclasses as |
27 * 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, |
28 * then objects drawn with that paint have the xfermode applied. | 26 * then objects drawn with that paint have the xfermode applied. |
29 * | 27 * |
30 * 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 |
31 * the same instance between several threads. | 29 * the same instance between several threads. |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 enum { | 237 enum { |
240 kModeCount = kLastMode + 1 | 238 kModeCount = kLastMode + 1 |
241 }; | 239 }; |
242 | 240 |
243 friend class SkGraphics; | 241 friend class SkGraphics; |
244 static void Term(); | 242 static void Term(); |
245 | 243 |
246 typedef SkFlattenable INHERITED; | 244 typedef SkFlattenable INHERITED; |
247 }; | 245 }; |
248 | 246 |
249 /////////////////////////////////////////////////////////////////////////////// | |
250 | |
251 #ifdef SK_SUPPORT_LEGACY_PROCXFERMODE | |
252 /** \class SkProcXfermode | |
253 | |
254 SkProcXfermode is a xfermode that applies the specified proc to its colors. | |
255 This class is not exported to java. | |
256 */ | |
257 class SK_API SkProcXfermode : public SkXfermode { | |
258 public: | |
259 static SkProcXfermode* Create(SkXfermodeProc proc) { | |
260 return SkNEW_ARGS(SkProcXfermode, (proc)); | |
261 } | |
262 | |
263 // overrides from SkXfermode | |
264 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, | |
265 const SkAlpha aa[]) const SK_OVERRIDE; | |
266 virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, | |
267 const SkAlpha aa[]) const SK_OVERRIDE; | |
268 virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, | |
269 const SkAlpha aa[]) const SK_OVERRIDE; | |
270 | |
271 SK_TO_STRING_OVERRIDE() | |
272 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcXfermode) | |
273 | |
274 protected: | |
275 SkProcXfermode(SkReadBuffer&); | |
276 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | |
277 | |
278 // allow subclasses to update this after we unflatten | |
279 void setProc(SkXfermodeProc proc) { | |
280 fProc = proc; | |
281 } | |
282 | |
283 SkXfermodeProc getProc() const { | |
284 return fProc; | |
285 } | |
286 | |
287 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS | |
288 public: | |
289 #endif | 247 #endif |
290 SkProcXfermode(SkXfermodeProc proc) : fProc(proc) {} | |
291 | |
292 private: | |
293 SkXfermodeProc fProc; | |
294 | |
295 typedef SkXfermode INHERITED; | |
296 }; | |
297 #endif | |
298 | |
299 #endif | |
OLD | NEW |