OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * 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 |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkCoreBlitters.h" | 8 #include "SkCoreBlitters.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkShader.h" | 10 #include "SkShader.h" |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 } | 356 } |
357 if (info.isSRGB()) { | 357 if (info.isSRGB()) { |
358 fFlags |= SkXfermode::kDstIsSRGB_D32Flag; | 358 fFlags |= SkXfermode::kDstIsSRGB_D32Flag; |
359 } | 359 } |
360 fProc1 = SkXfermode::GetD32Proc(fXfer, fFlags | SkXfermode::kSrcIsSingle
_D32Flag); | 360 fProc1 = SkXfermode::GetD32Proc(fXfer, fFlags | SkXfermode::kSrcIsSingle
_D32Flag); |
361 fProcN = SkXfermode::GetD32Proc(fXfer, fFlags); | 361 fProcN = SkXfermode::GetD32Proc(fXfer, fFlags); |
362 } | 362 } |
363 | 363 |
364 SkXfermode::LCD32Proc getLCDProc(uint32_t oneOrManyFlag) const { | 364 SkXfermode::LCD32Proc getLCDProc(uint32_t oneOrManyFlag) const { |
365 uint32_t flags = fFlags & 1; | 365 uint32_t flags = fFlags & 1; |
366 if (!(fFlags & SkXfermode::kDstIsSRGB_D32Flag)) { | 366 if (fFlags & SkXfermode::kDstIsSRGB_D32Flag) { |
367 flags |= SkXfermode::kDstIsLinearInt_LCDFlag; | 367 flags |= SkXfermode::kDstIsSRGB_LCDFlag; |
368 } | 368 } |
369 return SkXfermode::GetLCD32Proc(flags | oneOrManyFlag); | 369 return SkXfermode::GetLCD32Proc(flags | oneOrManyFlag); |
370 } | 370 } |
371 | 371 |
372 static DstType* WritableAddr(const SkPixmap& device, int x, int y) { | 372 static DstType* WritableAddr(const SkPixmap& device, int x, int y) { |
373 return device.writable_addr32(x, y); | 373 return device.writable_addr32(x, y); |
374 } | 374 } |
375 }; | 375 }; |
376 | 376 |
377 struct State64 : State4f { | 377 struct StateF16 : State4f { |
378 typedef uint64_t DstType; | 378 typedef uint64_t DstType; |
379 | 379 |
380 SkXfermode::D64Proc fProc1; | 380 SkXfermode::F16Proc fProc1; |
381 SkXfermode::D64Proc fProcN; | 381 SkXfermode::F16Proc fProcN; |
382 | 382 |
383 State64(const SkImageInfo& info, const SkPaint& paint, const SkShader::Conte
xt* shaderContext) | 383 StateF16(const SkImageInfo& info, const SkPaint& paint, const SkShader::Cont
ext* shaderContext) |
384 : State4f(info, paint, shaderContext) | 384 : State4f(info, paint, shaderContext) |
385 { | 385 { |
386 if (is_opaque(paint, shaderContext)) { | 386 if (is_opaque(paint, shaderContext)) { |
387 fFlags |= SkXfermode::kSrcIsOpaque_D64Flag; | 387 fFlags |= SkXfermode::kSrcIsOpaque_F16Flag; |
388 } | 388 } |
389 if (kRGBA_F16_SkColorType == info.colorType()) { | 389 SkASSERT(kRGBA_F16_SkColorType == info.colorType()); |
390 fFlags |= SkXfermode::kDstIsFloat16_D64Flag; | 390 fProc1 = SkXfermode::GetF16Proc(fXfer, fFlags | SkXfermode::kSrcIsSingle
_F16Flag); |
391 } | 391 fProcN = SkXfermode::GetF16Proc(fXfer, fFlags); |
392 fProc1 = SkXfermode::GetD64Proc(fXfer, fFlags | SkXfermode::kSrcIsSingle
_D64Flag); | |
393 fProcN = SkXfermode::GetD64Proc(fXfer, fFlags); | |
394 } | 392 } |
395 | 393 |
396 SkXfermode::LCD64Proc getLCDProc(uint32_t oneOrManyFlag) const { | 394 SkXfermode::LCDF16Proc getLCDProc(uint32_t oneOrManyFlag) const { |
397 uint32_t flags = fFlags & 1; | 395 uint32_t flags = fFlags & 1; |
398 if (!(fFlags & SkXfermode::kDstIsFloat16_D64Flag)) { | 396 return SkXfermode::GetLCDF16Proc(flags | oneOrManyFlag); |
399 flags |= SkXfermode::kDstIsLinearInt_LCDFlag; | |
400 } | |
401 return SkXfermode::GetLCD64Proc(flags | oneOrManyFlag); | |
402 } | 397 } |
403 | 398 |
404 static DstType* WritableAddr(const SkPixmap& device, int x, int y) { | 399 static DstType* WritableAddr(const SkPixmap& device, int x, int y) { |
405 return device.writable_addr64(x, y); | 400 return device.writable_addr64(x, y); |
406 } | 401 } |
407 }; | 402 }; |
408 | 403 |
409 template <typename State> SkBlitter* create(const SkPixmap& device, const SkPain
t& paint, | 404 template <typename State> SkBlitter* create(const SkPixmap& device, const SkPain
t& paint, |
410 SkShader::Context* shaderContext, | 405 SkShader::Context* shaderContext, |
411 SkTBlitterAllocator* allocator) { | 406 SkTBlitterAllocator* allocator) { |
(...skipping 15 matching lines...) Expand all Loading... |
427 return allocator->createT<SkState_Blitter<State>>(device, paint); | 422 return allocator->createT<SkState_Blitter<State>>(device, paint); |
428 } | 423 } |
429 } | 424 } |
430 | 425 |
431 SkBlitter* SkBlitter_ARGB32_Create(const SkPixmap& device, const SkPaint& paint, | 426 SkBlitter* SkBlitter_ARGB32_Create(const SkPixmap& device, const SkPaint& paint, |
432 SkShader::Context* shaderContext, | 427 SkShader::Context* shaderContext, |
433 SkTBlitterAllocator* allocator) { | 428 SkTBlitterAllocator* allocator) { |
434 return create<State32>(device, paint, shaderContext, allocator); | 429 return create<State32>(device, paint, shaderContext, allocator); |
435 } | 430 } |
436 | 431 |
437 SkBlitter* SkBlitter_ARGB64_Create(const SkPixmap& device, const SkPaint& paint, | 432 SkBlitter* SkBlitter_F16_Create(const SkPixmap& device, const SkPaint& paint, |
438 SkShader::Context* shaderContext, | 433 SkShader::Context* shaderContext, |
439 SkTBlitterAllocator* allocator) { | 434 SkTBlitterAllocator* allocator) { |
440 return create<State64>(device, paint, shaderContext, allocator); | 435 return create<StateF16>(device, paint, shaderContext, allocator); |
441 } | 436 } |
OLD | NEW |