| 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 318 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 319 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 319 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 320 | 320 |
| 321 static bool is_opaque(const SkPaint& paint, const SkShader::Context* shaderConte
xt) { | 321 static bool is_opaque(const SkPaint& paint, const SkShader::Context* shaderConte
xt) { |
| 322 return shaderContext ? SkToBool(shaderContext->getFlags() & SkShader::kOpaqu
eAlpha_Flag) | 322 return shaderContext ? SkToBool(shaderContext->getFlags() & SkShader::kOpaqu
eAlpha_Flag) |
| 323 : 0xFF == paint.getAlpha(); | 323 : 0xFF == paint.getAlpha(); |
| 324 } | 324 } |
| 325 | 325 |
| 326 struct State4f { | 326 struct State4f { |
| 327 State4f(const SkImageInfo& info, const SkPaint& paint, const SkShader::Conte
xt* shaderContext) { | 327 State4f(const SkImageInfo& info, const SkPaint& paint, const SkShader::Conte
xt* shaderContext) { |
| 328 fXfer = paint.getXfermode(); | 328 fXfer = SkXfermode::Peek(paint.getBlendMode()); |
| 329 if (shaderContext) { | 329 if (shaderContext) { |
| 330 fBuffer.reset(info.width()); | 330 fBuffer.reset(info.width()); |
| 331 } else { | 331 } else { |
| 332 fPM4f = SkColor4f::FromColor(paint.getColor()).premul(); | 332 fPM4f = SkColor4f::FromColor(paint.getColor()).premul(); |
| 333 } | 333 } |
| 334 fFlags = 0; | 334 fFlags = 0; |
| 335 } | 335 } |
| 336 | 336 |
| 337 SkXfermode* fXfer; | 337 SkXfermode* fXfer; |
| 338 SkPM4f fPM4f; | 338 SkPM4f fPM4f; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 | 403 |
| 404 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, |
| 405 SkShader::Context* shaderContext, | 405 SkShader::Context* shaderContext, |
| 406 SkTBlitterAllocator* allocator) { | 406 SkTBlitterAllocator* allocator) { |
| 407 SkASSERT(allocator != nullptr); | 407 SkASSERT(allocator != nullptr); |
| 408 | 408 |
| 409 if (shaderContext) { | 409 if (shaderContext) { |
| 410 SkShader::Context::BlitState bstate; | 410 SkShader::Context::BlitState bstate; |
| 411 sk_bzero(&bstate, sizeof(bstate)); | 411 sk_bzero(&bstate, sizeof(bstate)); |
| 412 bstate.fCtx = shaderContext; | 412 bstate.fCtx = shaderContext; |
| 413 bstate.fXfer = paint.getXfermode(); | 413 bstate.fXfer = SkXfermode::Peek(paint.getBlendMode()); |
| 414 | 414 |
| 415 (void)shaderContext->chooseBlitProcs(device.info(), &bstate); | 415 (void)shaderContext->chooseBlitProcs(device.info(), &bstate); |
| 416 return allocator->createT<SkState_Shader_Blitter<State>>(device, paint,
bstate); | 416 return allocator->createT<SkState_Shader_Blitter<State>>(device, paint,
bstate); |
| 417 } else { | 417 } else { |
| 418 SkColor color = paint.getColor(); | 418 SkColor color = paint.getColor(); |
| 419 if (0 == SkColorGetA(color)) { | 419 if (0 == SkColorGetA(color)) { |
| 420 return nullptr; | 420 return nullptr; |
| 421 } | 421 } |
| 422 return allocator->createT<SkState_Blitter<State>>(device, paint); | 422 return allocator->createT<SkState_Blitter<State>>(device, paint); |
| 423 } | 423 } |
| 424 } | 424 } |
| 425 | 425 |
| 426 SkBlitter* SkBlitter_ARGB32_Create(const SkPixmap& device, const SkPaint& paint, | 426 SkBlitter* SkBlitter_ARGB32_Create(const SkPixmap& device, const SkPaint& paint, |
| 427 SkShader::Context* shaderContext, | 427 SkShader::Context* shaderContext, |
| 428 SkTBlitterAllocator* allocator) { | 428 SkTBlitterAllocator* allocator) { |
| 429 return create<State32>(device, paint, shaderContext, allocator); | 429 return create<State32>(device, paint, shaderContext, allocator); |
| 430 } | 430 } |
| 431 | 431 |
| 432 SkBlitter* SkBlitter_F16_Create(const SkPixmap& device, const SkPaint& paint, | 432 SkBlitter* SkBlitter_F16_Create(const SkPixmap& device, const SkPaint& paint, |
| 433 SkShader::Context* shaderContext, | 433 SkShader::Context* shaderContext, |
| 434 SkTBlitterAllocator* allocator) { | 434 SkTBlitterAllocator* allocator) { |
| 435 return create<StateF16>(device, paint, shaderContext, allocator); | 435 return create<StateF16>(device, paint, shaderContext, allocator); |
| 436 } | 436 } |
| OLD | NEW |