OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 device[i] = SkFourByteInterp256(span[i], device[i], aa256); | 332 device[i] = SkFourByteInterp256(span[i], device[i], aa256); |
333 } | 333 } |
334 } | 334 } |
335 | 335 |
336 SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter(const SkPixmap& device, | 336 SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter(const SkPixmap& device, |
337 const SkPaint& paint, SkShader::Context* shaderContext) | 337 const SkPaint& paint, SkShader::Context* shaderContext) |
338 : INHERITED(device, paint, shaderContext) | 338 : INHERITED(device, paint, shaderContext) |
339 { | 339 { |
340 fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * (sizeof(SkPMColor))); | 340 fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * (sizeof(SkPMColor))); |
341 | 341 |
342 fXfermode = paint.getXfermode(); | 342 fXfermode = SkXfermode::Peek(paint.getBlendMode()); |
343 SkSafeRef(fXfermode); | |
344 | 343 |
345 int flags = 0; | 344 int flags = 0; |
346 if (!(shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag)) { | 345 if (!(shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag)) { |
347 flags |= SkBlitRow::kSrcPixelAlpha_Flag32; | 346 flags |= SkBlitRow::kSrcPixelAlpha_Flag32; |
348 } | 347 } |
349 // we call this on the output from the shader | 348 // we call this on the output from the shader |
350 fProc32 = SkBlitRow::Factory32(flags); | 349 fProc32 = SkBlitRow::Factory32(flags); |
351 // we call this on the output from the shader + alpha from the aa buffer | 350 // we call this on the output from the shader + alpha from the aa buffer |
352 fProc32Blend = SkBlitRow::Factory32(flags | SkBlitRow::kGlobalAlpha_Flag32); | 351 fProc32Blend = SkBlitRow::Factory32(flags | SkBlitRow::kGlobalAlpha_Flag32); |
353 | 352 |
354 fShadeDirectlyIntoDevice = false; | 353 fShadeDirectlyIntoDevice = false; |
355 if (fXfermode == nullptr) { | 354 if (fXfermode == nullptr) { |
356 if (shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag) { | 355 if (shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag) { |
357 fShadeDirectlyIntoDevice = true; | 356 fShadeDirectlyIntoDevice = true; |
358 } | 357 } |
359 } else { | 358 } else { |
360 SkXfermode::Mode mode; | 359 SkXfermode::Mode mode; |
361 if (fXfermode->asMode(&mode)) { | 360 if (fXfermode->asMode(&mode)) { |
362 if (SkXfermode::kSrc_Mode == mode) { | 361 if (SkXfermode::kSrc_Mode == mode) { |
363 fShadeDirectlyIntoDevice = true; | 362 fShadeDirectlyIntoDevice = true; |
364 fProc32Blend = blend_srcmode; | 363 fProc32Blend = blend_srcmode; |
365 } | 364 } |
366 } | 365 } |
367 } | 366 } |
368 | 367 |
369 fConstInY = SkToBool(shaderContext->getFlags() & SkShader::kConstInY32_Flag)
; | 368 fConstInY = SkToBool(shaderContext->getFlags() & SkShader::kConstInY32_Flag)
; |
370 } | 369 } |
371 | 370 |
372 SkARGB32_Shader_Blitter::~SkARGB32_Shader_Blitter() { | 371 SkARGB32_Shader_Blitter::~SkARGB32_Shader_Blitter() { |
373 SkSafeUnref(fXfermode); | |
374 sk_free(fBuffer); | 372 sk_free(fBuffer); |
375 } | 373 } |
376 | 374 |
377 void SkARGB32_Shader_Blitter::blitH(int x, int y, int width) { | 375 void SkARGB32_Shader_Blitter::blitH(int x, int y, int width) { |
378 SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width()); | 376 SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width()); |
379 | 377 |
380 uint32_t* device = fDevice.writable_addr32(x, y); | 378 uint32_t* device = fDevice.writable_addr32(x, y); |
381 | 379 |
382 if (fShadeDirectlyIntoDevice) { | 380 if (fShadeDirectlyIntoDevice) { |
383 fShaderContext->shadeSpan(x, y, device, width); | 381 fShaderContext->shadeSpan(x, y, device, width); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 SkBlitRow::Proc32 proc = (255 == alpha) ? fProc32 : fProc32Blend; | 688 SkBlitRow::Proc32 proc = (255 == alpha) ? fProc32 : fProc32Blend; |
691 do { | 689 do { |
692 shaderContext->shadeSpan(x, y, span, 1); | 690 shaderContext->shadeSpan(x, y, span, 1); |
693 proc(device, span, 1, alpha); | 691 proc(device, span, 1, alpha); |
694 y += 1; | 692 y += 1; |
695 device = (uint32_t*)((char*)device + deviceRB); | 693 device = (uint32_t*)((char*)device + deviceRB); |
696 } while (--height > 0); | 694 } while (--height > 0); |
697 } | 695 } |
698 } | 696 } |
699 } | 697 } |
OLD | NEW |