OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
4 * | 3 * |
5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 | |
10 #ifndef SkXfermode_DEFINED | 8 #ifndef SkXfermode_DEFINED |
11 #define SkXfermode_DEFINED | 9 #define SkXfermode_DEFINED |
12 | 10 |
13 #include "SkFlattenable.h" | 11 #include "SkFlattenable.h" |
14 #include "SkColor.h" | 12 #include "SkColor.h" |
15 | 13 |
16 class GrFragmentProcessor; | 14 class GrFragmentProcessor; |
17 class GrTexture; | 15 class GrTexture; |
18 class GrXPFactory; | 16 class GrXPFactory; |
19 class SkString; | 17 class SkString; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 kSrcIsSingle_D32Flag = 1 << 1, | 239 kSrcIsSingle_D32Flag = 1 << 1, |
242 kDstIsSRGB_D32Flag = 1 << 2, | 240 kDstIsSRGB_D32Flag = 1 << 2, |
243 }; | 241 }; |
244 typedef void (*D32Proc)(const SkXfermode*, uint32_t dst[], const SkPM4f src[
], | 242 typedef void (*D32Proc)(const SkXfermode*, uint32_t dst[], const SkPM4f src[
], |
245 int count, const SkAlpha coverage[]); | 243 int count, const SkAlpha coverage[]); |
246 static D32Proc GetD32Proc(SkXfermode*, uint32_t flags); | 244 static D32Proc GetD32Proc(SkXfermode*, uint32_t flags); |
247 static D32Proc GetD32Proc(const sk_sp<SkXfermode>& xfer, uint32_t flags) { | 245 static D32Proc GetD32Proc(const sk_sp<SkXfermode>& xfer, uint32_t flags) { |
248 return GetD32Proc(xfer.get(), flags); | 246 return GetD32Proc(xfer.get(), flags); |
249 } | 247 } |
250 | 248 |
251 enum D64Flags { | 249 enum F16Flags { |
252 kSrcIsOpaque_D64Flag = 1 << 0, | 250 kSrcIsOpaque_F16Flag = 1 << 0, |
253 kSrcIsSingle_D64Flag = 1 << 1, | 251 kSrcIsSingle_F16Flag = 1 << 1, |
254 kDstIsFloat16_D64Flag = 1 << 2, // else U16 bit components | |
255 }; | 252 }; |
256 typedef void (*D64Proc)(const SkXfermode*, uint64_t dst[], const SkPM4f src[
], int count, | 253 typedef void (*F16Proc)(const SkXfermode*, uint64_t dst[], const SkPM4f src[
], int count, |
257 const SkAlpha coverage[]); | 254 const SkAlpha coverage[]); |
258 static D64Proc GetD64Proc(SkXfermode*, uint32_t flags); | 255 static F16Proc GetF16Proc(SkXfermode*, uint32_t flags); |
259 static D64Proc GetD64Proc(const sk_sp<SkXfermode>& xfer, uint32_t flags) { | 256 static F16Proc GetF16Proc(const sk_sp<SkXfermode>& xfer, uint32_t flags) { |
260 return GetD64Proc(xfer.get(), flags); | 257 return GetF16Proc(xfer.get(), flags); |
261 } | 258 } |
262 | 259 |
263 enum LCDFlags { | 260 enum LCDFlags { |
264 kSrcIsOpaque_LCDFlag = 1 << 0, // else src(s) may have alpha < 1 | 261 kSrcIsOpaque_LCDFlag = 1 << 0, // else src(s) may have alpha < 1 |
265 kSrcIsSingle_LCDFlag = 1 << 1, // else src[count] | 262 kSrcIsSingle_LCDFlag = 1 << 1, // else src[count] |
266 kDstIsLinearInt_LCDFlag = 1 << 2, // else srgb/half-float | 263 kDstIsSRGB_LCDFlag = 1 << 2, // else l32 or f16 |
267 }; | 264 }; |
268 typedef void (*LCD32Proc)(uint32_t* dst, const SkPM4f* src, int count, const
uint16_t lcd[]); | 265 typedef void (*LCD32Proc)(uint32_t* dst, const SkPM4f* src, int count, const
uint16_t lcd[]); |
269 typedef void (*LCD64Proc)(uint64_t* dst, const SkPM4f* src, int count, const
uint16_t lcd[]); | 266 typedef void (*LCDF16Proc)(uint64_t* dst, const SkPM4f* src, int count, cons
t uint16_t lcd[]); |
270 static LCD32Proc GetLCD32Proc(uint32_t flags); | 267 static LCD32Proc GetLCD32Proc(uint32_t flags); |
271 static LCD64Proc GetLCD64Proc(uint32_t) { return nullptr; } | 268 static LCDF16Proc GetLCDF16Proc(uint32_t) { return nullptr; } |
272 | 269 |
273 protected: | 270 protected: |
274 SkXfermode() {} | 271 SkXfermode() {} |
275 /** The default implementation of xfer32/xfer16/xferA8 in turn call this | 272 /** The default implementation of xfer32/xfer16/xferA8 in turn call this |
276 method, 1 color at a time (upscaled to a SkPMColor). The default | 273 method, 1 color at a time (upscaled to a SkPMColor). The default |
277 implementation of this method just returns dst. If performance is | 274 implementation of this method just returns dst. If performance is |
278 important, your subclass should override xfer32/xfer16/xferA8 directly. | 275 important, your subclass should override xfer32/xfer16/xferA8 directly. |
279 | 276 |
280 This method will not be called directly by the client, so it need not | 277 This method will not be called directly by the client, so it need not |
281 be implemented if your subclass has overridden xfer32/xfer16/xferA8 | 278 be implemented if your subclass has overridden xfer32/xfer16/xferA8 |
282 */ | 279 */ |
283 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const; | 280 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const; |
284 | 281 |
285 virtual D32Proc onGetD32Proc(uint32_t flags) const; | 282 virtual D32Proc onGetD32Proc(uint32_t flags) const; |
286 virtual D64Proc onGetD64Proc(uint32_t flags) const; | 283 virtual F16Proc onGetF16Proc(uint32_t flags) const; |
287 | 284 |
288 private: | 285 private: |
289 enum { | 286 enum { |
290 kModeCount = kLastMode + 1 | 287 kModeCount = kLastMode + 1 |
291 }; | 288 }; |
292 | 289 |
293 typedef SkFlattenable INHERITED; | 290 typedef SkFlattenable INHERITED; |
294 }; | 291 }; |
295 | 292 |
296 #endif | 293 #endif |
OLD | NEW |