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 |
(...skipping 14 matching lines...) Expand all Loading... |
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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 GrEffectRef** effect, | 209 GrEffectRef** effect, |
212 Coeff* src, | 210 Coeff* src, |
213 Coeff* dst, | 211 Coeff* dst, |
214 GrTexture* background = NULL); | 212 GrTexture* background = NULL); |
215 | 213 |
216 SkDEVCODE(virtual void toString(SkString* str) const = 0;) | 214 SkDEVCODE(virtual void toString(SkString* str) const = 0;) |
217 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() | 215 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
218 SK_DEFINE_FLATTENABLE_TYPE(SkXfermode) | 216 SK_DEFINE_FLATTENABLE_TYPE(SkXfermode) |
219 | 217 |
220 protected: | 218 protected: |
| 219 SkXfermode() {} |
221 SkXfermode(SkReadBuffer& rb) : SkFlattenable(rb) {} | 220 SkXfermode(SkReadBuffer& rb) : SkFlattenable(rb) {} |
222 | 221 |
223 /** The default implementation of xfer32/xfer16/xferA8 in turn call this | 222 /** The default implementation of xfer32/xfer16/xferA8 in turn call this |
224 method, 1 color at a time (upscaled to a SkPMColor). The default | 223 method, 1 color at a time (upscaled to a SkPMColor). The default |
225 implmentation of this method just returns dst. If performance is | 224 implmentation of this method just returns dst. If performance is |
226 important, your subclass should override xfer32/xfer16/xferA8 directly. | 225 important, your subclass should override xfer32/xfer16/xferA8 directly. |
227 | 226 |
228 This method will not be called directly by the client, so it need not | 227 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 | 228 be implemented if your subclass has overridden xfer32/xfer16/xferA8 |
230 */ | 229 */ |
(...skipping 12 matching lines...) Expand all Loading... |
243 | 242 |
244 /////////////////////////////////////////////////////////////////////////////// | 243 /////////////////////////////////////////////////////////////////////////////// |
245 | 244 |
246 /** \class SkProcXfermode | 245 /** \class SkProcXfermode |
247 | 246 |
248 SkProcXfermode is a xfermode that applies the specified proc to its colors. | 247 SkProcXfermode is a xfermode that applies the specified proc to its colors. |
249 This class is not exported to java. | 248 This class is not exported to java. |
250 */ | 249 */ |
251 class SkProcXfermode : public SkXfermode { | 250 class SkProcXfermode : public SkXfermode { |
252 public: | 251 public: |
253 SkProcXfermode(SkXfermodeProc proc) : fProc(proc) {} | 252 static SkProcXfermode* Create(SkXfermodeProc proc) { |
| 253 return SkNEW_ARGS(SkProcXfermode, (proc)); |
| 254 } |
254 | 255 |
255 // overrides from SkXfermode | 256 // overrides from SkXfermode |
256 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, | 257 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, |
257 const SkAlpha aa[]) const SK_OVERRIDE; | 258 const SkAlpha aa[]) const SK_OVERRIDE; |
258 virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, | 259 virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, |
259 const SkAlpha aa[]) const SK_OVERRIDE; | 260 const SkAlpha aa[]) const SK_OVERRIDE; |
260 virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, | 261 virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, |
261 const SkAlpha aa[]) const SK_OVERRIDE; | 262 const SkAlpha aa[]) const SK_OVERRIDE; |
262 | 263 |
263 SK_DEVELOPER_TO_STRING() | 264 SK_DEVELOPER_TO_STRING() |
264 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcXfermode) | 265 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcXfermode) |
265 | 266 |
266 protected: | 267 protected: |
267 SkProcXfermode(SkReadBuffer&); | 268 SkProcXfermode(SkReadBuffer&); |
268 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 269 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
269 | 270 |
270 // allow subclasses to update this after we unflatten | 271 // allow subclasses to update this after we unflatten |
271 void setProc(SkXfermodeProc proc) { | 272 void setProc(SkXfermodeProc proc) { |
272 fProc = proc; | 273 fProc = proc; |
273 } | 274 } |
274 | 275 |
275 SkXfermodeProc getProc() const { | 276 SkXfermodeProc getProc() const { |
276 return fProc; | 277 return fProc; |
277 } | 278 } |
278 | 279 |
| 280 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS |
| 281 public: |
| 282 #endif |
| 283 SkProcXfermode(SkXfermodeProc proc) : fProc(proc) {} |
| 284 |
279 private: | 285 private: |
280 SkXfermodeProc fProc; | 286 SkXfermodeProc fProc; |
281 | 287 |
282 typedef SkXfermode INHERITED; | 288 typedef SkXfermode INHERITED; |
283 }; | 289 }; |
284 | 290 |
285 #endif | 291 #endif |
OLD | NEW |