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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 The xfermode will return a factory for which the caller will get a ref.
It is up | 213 The xfermode will return a factory for which the caller will get a ref.
It is up |
214 to the caller to install it. XferProcessors cannot use a background text
ure. | 214 to the caller to install it. XferProcessors cannot use a background text
ure. |
215 */ | 215 */ |
216 virtual GrXPFactory* asXPFactory() const; | 216 virtual GrXPFactory* asXPFactory() const; |
217 #endif | 217 #endif |
218 | 218 |
219 SK_TO_STRING_PUREVIRT() | 219 SK_TO_STRING_PUREVIRT() |
220 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() | 220 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
221 SK_DEFINE_FLATTENABLE_TYPE(SkXfermode) | 221 SK_DEFINE_FLATTENABLE_TYPE(SkXfermode) |
222 | 222 |
223 enum PM4fFlags { | 223 enum D32Flags { |
224 kSrcIsOpaque_PM4fFlag = 1 << 0, | 224 kSrcIsOpaque_D32Flag = 1 << 0, |
225 kDstIsSRGB_PM4fFlag = 1 << 1, | 225 kSrcIsSingle_D32Flag = 1 << 1, |
| 226 kDstIsSRGB_D32Flag = 1 << 2, |
226 }; | 227 }; |
227 struct PM4fState { | 228 typedef void (*D32Proc)(const SkXfermode*, uint32_t dst[], const SkPM4f src[
], |
228 const SkXfermode* fXfer; | 229 int count, const SkAlpha coverage[]); |
229 uint32_t fFlags; | 230 static D32Proc GetD32Proc(SkXfermode*, uint32_t flags); |
| 231 |
| 232 enum D64Flags { |
| 233 kSrcIsOpaque_D64Flag = 1 << 0, |
| 234 kSrcIsSingle_D64Flag = 1 << 1, |
| 235 kDstIsFloat16_D64Flag = 1 << 2, // else U16 bit components |
230 }; | 236 }; |
231 typedef void (*PM4fProc1)(const PM4fState&, uint32_t dst[], const SkPM4f& sr
c, | 237 typedef void (*D64Proc)(const SkXfermode*, uint64_t dst[], const SkPM4f src[
], int count, |
232 int count, const SkAlpha coverage[]); | 238 const SkAlpha coverage[]); |
233 typedef void (*PM4fProcN)(const PM4fState&, uint32_t dst[], const SkPM4f src
[], | 239 static D64Proc GetD64Proc(SkXfermode*, uint32_t flags); |
234 int count, const SkAlpha coverage[]); | |
235 | |
236 static PM4fProc1 GetPM4fProc1(Mode, uint32_t flags); | |
237 static PM4fProcN GetPM4fProcN(Mode, uint32_t flags); | |
238 virtual PM4fProc1 getPM4fProc1(uint32_t flags) const; | |
239 virtual PM4fProcN getPM4fProcN(uint32_t flags) const; | |
240 | |
241 enum U64Flags { | |
242 kSrcIsOpaque_U64Flag = 1 << 0, | |
243 kDstIsFloat16_U64Flag = 1 << 1, // else U16 bit components | |
244 }; | |
245 struct U64State { | |
246 const SkXfermode* fXfer; | |
247 uint32_t fFlags; | |
248 }; | |
249 typedef void (*U64Proc1)(const U64State&, uint64_t dst[], const SkPM4f& src,
int count, | |
250 const SkAlpha coverage[]); | |
251 typedef void (*U64ProcN)(const U64State&, uint64_t dst[], const SkPM4f src[]
, int count, | |
252 const SkAlpha coverage[]); | |
253 static U64Proc1 GetU64Proc1(Mode, uint32_t flags); | |
254 static U64ProcN GetU64ProcN(Mode, uint32_t flags); | |
255 | 240 |
256 enum LCDFlags { | 241 enum LCDFlags { |
257 kSrcIsOpaque_LCDFlag = 1 << 0, // else src(s) may have alpha < 1 | 242 kSrcIsOpaque_LCDFlag = 1 << 0, // else src(s) may have alpha < 1 |
258 kSrcIsSingle_LCDFlag = 1 << 1, // else src[count] | 243 kSrcIsSingle_LCDFlag = 1 << 1, // else src[count] |
259 kDstIsLinearInt_LCDFlag = 1 << 2, // else srgb/half-float | 244 kDstIsLinearInt_LCDFlag = 1 << 2, // else srgb/half-float |
260 }; | 245 }; |
261 typedef void (*LCD32Proc)(uint32_t* dst, const SkPM4f* src, int count, const
uint16_t lcd[]); | 246 typedef void (*LCD32Proc)(uint32_t* dst, const SkPM4f* src, int count, const
uint16_t lcd[]); |
262 typedef void (*LCD64Proc)(uint64_t* dst, const SkPM4f* src, int count, const
uint16_t lcd[]); | 247 typedef void (*LCD64Proc)(uint64_t* dst, const SkPM4f* src, int count, const
uint16_t lcd[]); |
263 static LCD32Proc GetLCD32Proc(uint32_t flags); | 248 static LCD32Proc GetLCD32Proc(uint32_t flags); |
264 static LCD64Proc GetLCD64Proc(uint32_t) { return nullptr; } | 249 static LCD64Proc GetLCD64Proc(uint32_t) { return nullptr; } |
265 | 250 |
266 protected: | 251 protected: |
267 SkXfermode() {} | 252 SkXfermode() {} |
268 /** The default implementation of xfer32/xfer16/xferA8 in turn call this | 253 /** The default implementation of xfer32/xfer16/xferA8 in turn call this |
269 method, 1 color at a time (upscaled to a SkPMColor). The default | 254 method, 1 color at a time (upscaled to a SkPMColor). The default |
270 implementation of this method just returns dst. If performance is | 255 implementation of this method just returns dst. If performance is |
271 important, your subclass should override xfer32/xfer16/xferA8 directly. | 256 important, your subclass should override xfer32/xfer16/xferA8 directly. |
272 | 257 |
273 This method will not be called directly by the client, so it need not | 258 This method will not be called directly by the client, so it need not |
274 be implemented if your subclass has overridden xfer32/xfer16/xferA8 | 259 be implemented if your subclass has overridden xfer32/xfer16/xferA8 |
275 */ | 260 */ |
276 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const; | 261 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const; |
277 | 262 |
| 263 virtual D32Proc onGetD32Proc(uint32_t flags) const; |
| 264 virtual D64Proc onGetD64Proc(uint32_t flags) const; |
| 265 |
278 private: | 266 private: |
279 enum { | 267 enum { |
280 kModeCount = kLastMode + 1 | 268 kModeCount = kLastMode + 1 |
281 }; | 269 }; |
282 | 270 |
283 typedef SkFlattenable INHERITED; | 271 typedef SkFlattenable INHERITED; |
284 }; | 272 }; |
285 | 273 |
286 #endif | 274 #endif |
OLD | NEW |