michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #include "SkCoreBlitters.h" michael@0: #include "SkColorPriv.h" michael@0: #include "SkShader.h" michael@0: #include "SkUtils.h" michael@0: #include "SkXfermode.h" michael@0: #include "SkBlitMask.h" michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: static void SkARGB32_Blit32(const SkBitmap& device, const SkMask& mask, michael@0: const SkIRect& clip, SkPMColor srcColor) { michael@0: U8CPU alpha = SkGetPackedA32(srcColor); michael@0: unsigned flags = SkBlitRow::kSrcPixelAlpha_Flag32; michael@0: if (alpha != 255) { michael@0: flags |= SkBlitRow::kGlobalAlpha_Flag32; michael@0: } michael@0: SkBlitRow::Proc32 proc = SkBlitRow::Factory32(flags); michael@0: michael@0: int x = clip.fLeft; michael@0: int y = clip.fTop; michael@0: int width = clip.width(); michael@0: int height = clip.height(); michael@0: michael@0: SkPMColor* dstRow = device.getAddr32(x, y); michael@0: const SkPMColor* srcRow = reinterpret_cast(mask.getAddr8(x, y)); michael@0: michael@0: do { michael@0: proc(dstRow, srcRow, width, alpha); michael@0: dstRow = (SkPMColor*)((char*)dstRow + device.rowBytes()); michael@0: srcRow = (const SkPMColor*)((const char*)srcRow + mask.fRowBytes); michael@0: } while (--height != 0); michael@0: } michael@0: michael@0: ////////////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: SkARGB32_Blitter::SkARGB32_Blitter(const SkBitmap& device, const SkPaint& paint) michael@0: : INHERITED(device) { michael@0: SkColor color = paint.getColor(); michael@0: fColor = color; michael@0: michael@0: fSrcA = SkColorGetA(color); michael@0: unsigned scale = SkAlpha255To256(fSrcA); michael@0: fSrcR = SkAlphaMul(SkColorGetR(color), scale); michael@0: fSrcG = SkAlphaMul(SkColorGetG(color), scale); michael@0: fSrcB = SkAlphaMul(SkColorGetB(color), scale); michael@0: michael@0: fPMColor = SkPackARGB32(fSrcA, fSrcR, fSrcG, fSrcB); michael@0: fColor32Proc = SkBlitRow::ColorProcFactory(); michael@0: fColorRect32Proc = SkBlitRow::ColorRectProcFactory(); michael@0: } michael@0: michael@0: const SkBitmap* SkARGB32_Blitter::justAnOpaqueColor(uint32_t* value) { michael@0: if (255 == fSrcA) { michael@0: *value = fPMColor; michael@0: return &fDevice; michael@0: } michael@0: return NULL; michael@0: } michael@0: michael@0: #if defined _WIN32 && _MSC_VER >= 1300 // disable warning : local variable used without having been initialized michael@0: #pragma warning ( push ) michael@0: #pragma warning ( disable : 4701 ) michael@0: #endif michael@0: michael@0: void SkARGB32_Blitter::blitH(int x, int y, int width) { michael@0: SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width()); michael@0: michael@0: uint32_t* device = fDevice.getAddr32(x, y); michael@0: fColor32Proc(device, device, width, fPMColor); michael@0: } michael@0: michael@0: void SkARGB32_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], michael@0: const int16_t runs[]) { michael@0: if (fSrcA == 0) { michael@0: return; michael@0: } michael@0: michael@0: uint32_t color = fPMColor; michael@0: uint32_t* device = fDevice.getAddr32(x, y); michael@0: unsigned opaqueMask = fSrcA; // if fSrcA is 0xFF, then we will catch the fast opaque case michael@0: michael@0: for (;;) { michael@0: int count = runs[0]; michael@0: SkASSERT(count >= 0); michael@0: if (count <= 0) { michael@0: return; michael@0: } michael@0: unsigned aa = antialias[0]; michael@0: if (aa) { michael@0: if ((opaqueMask & aa) == 255) { michael@0: sk_memset32(device, color, count); michael@0: } else { michael@0: uint32_t sc = SkAlphaMulQ(color, SkAlpha255To256(aa)); michael@0: fColor32Proc(device, device, count, sc); michael@0: } michael@0: } michael@0: runs += count; michael@0: antialias += count; michael@0: device += count; michael@0: } michael@0: } michael@0: michael@0: ////////////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: #define solid_8_pixels(mask, dst, color) \ michael@0: do { \ michael@0: if (mask & 0x80) dst[0] = color; \ michael@0: if (mask & 0x40) dst[1] = color; \ michael@0: if (mask & 0x20) dst[2] = color; \ michael@0: if (mask & 0x10) dst[3] = color; \ michael@0: if (mask & 0x08) dst[4] = color; \ michael@0: if (mask & 0x04) dst[5] = color; \ michael@0: if (mask & 0x02) dst[6] = color; \ michael@0: if (mask & 0x01) dst[7] = color; \ michael@0: } while (0) michael@0: michael@0: #define SK_BLITBWMASK_NAME SkARGB32_BlitBW michael@0: #define SK_BLITBWMASK_ARGS , SkPMColor color michael@0: #define SK_BLITBWMASK_BLIT8(mask, dst) solid_8_pixels(mask, dst, color) michael@0: #define SK_BLITBWMASK_GETADDR getAddr32 michael@0: #define SK_BLITBWMASK_DEVTYPE uint32_t michael@0: #include "SkBlitBWMaskTemplate.h" michael@0: michael@0: #define blend_8_pixels(mask, dst, sc, dst_scale) \ michael@0: do { \ michael@0: if (mask & 0x80) { dst[0] = sc + SkAlphaMulQ(dst[0], dst_scale); } \ michael@0: if (mask & 0x40) { dst[1] = sc + SkAlphaMulQ(dst[1], dst_scale); } \ michael@0: if (mask & 0x20) { dst[2] = sc + SkAlphaMulQ(dst[2], dst_scale); } \ michael@0: if (mask & 0x10) { dst[3] = sc + SkAlphaMulQ(dst[3], dst_scale); } \ michael@0: if (mask & 0x08) { dst[4] = sc + SkAlphaMulQ(dst[4], dst_scale); } \ michael@0: if (mask & 0x04) { dst[5] = sc + SkAlphaMulQ(dst[5], dst_scale); } \ michael@0: if (mask & 0x02) { dst[6] = sc + SkAlphaMulQ(dst[6], dst_scale); } \ michael@0: if (mask & 0x01) { dst[7] = sc + SkAlphaMulQ(dst[7], dst_scale); } \ michael@0: } while (0) michael@0: michael@0: #define SK_BLITBWMASK_NAME SkARGB32_BlendBW michael@0: #define SK_BLITBWMASK_ARGS , uint32_t sc, unsigned dst_scale michael@0: #define SK_BLITBWMASK_BLIT8(mask, dst) blend_8_pixels(mask, dst, sc, dst_scale) michael@0: #define SK_BLITBWMASK_GETADDR getAddr32 michael@0: #define SK_BLITBWMASK_DEVTYPE uint32_t michael@0: #include "SkBlitBWMaskTemplate.h" michael@0: michael@0: void SkARGB32_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) { michael@0: SkASSERT(mask.fBounds.contains(clip)); michael@0: SkASSERT(fSrcA != 0xFF); michael@0: michael@0: if (fSrcA == 0) { michael@0: return; michael@0: } michael@0: michael@0: if (SkBlitMask::BlitColor(fDevice, mask, clip, fColor)) { michael@0: return; michael@0: } michael@0: michael@0: if (mask.fFormat == SkMask::kBW_Format) { michael@0: SkARGB32_BlendBW(fDevice, mask, clip, fPMColor, SkAlpha255To256(255 - fSrcA)); michael@0: } else if (SkMask::kARGB32_Format == mask.fFormat) { michael@0: SkARGB32_Blit32(fDevice, mask, clip, fPMColor); michael@0: } michael@0: } michael@0: michael@0: void SkARGB32_Opaque_Blitter::blitMask(const SkMask& mask, michael@0: const SkIRect& clip) { michael@0: SkASSERT(mask.fBounds.contains(clip)); michael@0: michael@0: if (SkBlitMask::BlitColor(fDevice, mask, clip, fColor)) { michael@0: return; michael@0: } michael@0: michael@0: if (mask.fFormat == SkMask::kBW_Format) { michael@0: SkARGB32_BlitBW(fDevice, mask, clip, fPMColor); michael@0: } else if (SkMask::kARGB32_Format == mask.fFormat) { michael@0: SkARGB32_Blit32(fDevice, mask, clip, fPMColor); michael@0: } michael@0: } michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: void SkARGB32_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { michael@0: if (alpha == 0 || fSrcA == 0) { michael@0: return; michael@0: } michael@0: michael@0: uint32_t* device = fDevice.getAddr32(x, y); michael@0: uint32_t color = fPMColor; michael@0: michael@0: if (alpha != 255) { michael@0: color = SkAlphaMulQ(color, SkAlpha255To256(alpha)); michael@0: } michael@0: michael@0: unsigned dst_scale = 255 - SkGetPackedA32(color); michael@0: size_t rowBytes = fDevice.rowBytes(); michael@0: while (--height >= 0) { michael@0: device[0] = color + SkAlphaMulQ(device[0], dst_scale); michael@0: device = (uint32_t*)((char*)device + rowBytes); michael@0: } michael@0: } michael@0: michael@0: void SkARGB32_Blitter::blitRect(int x, int y, int width, int height) { michael@0: SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width() && y + height <= fDevice.height()); michael@0: michael@0: if (fSrcA == 0) { michael@0: return; michael@0: } michael@0: michael@0: uint32_t* device = fDevice.getAddr32(x, y); michael@0: uint32_t color = fPMColor; michael@0: size_t rowBytes = fDevice.rowBytes(); michael@0: michael@0: if (255 == SkGetPackedA32(color)) { michael@0: fColorRect32Proc(device, width, height, rowBytes, color); michael@0: } else { michael@0: while (--height >= 0) { michael@0: fColor32Proc(device, device, width, color); michael@0: device = (uint32_t*)((char*)device + rowBytes); michael@0: } michael@0: } michael@0: } michael@0: michael@0: #if defined _WIN32 && _MSC_VER >= 1300 michael@0: #pragma warning ( pop ) michael@0: #endif michael@0: michael@0: /////////////////////////////////////////////////////////////////////// michael@0: michael@0: void SkARGB32_Black_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], michael@0: const int16_t runs[]) { michael@0: uint32_t* device = fDevice.getAddr32(x, y); michael@0: SkPMColor black = (SkPMColor)(SK_A32_MASK << SK_A32_SHIFT); michael@0: michael@0: for (;;) { michael@0: int count = runs[0]; michael@0: SkASSERT(count >= 0); michael@0: if (count <= 0) { michael@0: return; michael@0: } michael@0: unsigned aa = antialias[0]; michael@0: if (aa) { michael@0: if (aa == 255) { michael@0: sk_memset32(device, black, count); michael@0: } else { michael@0: SkPMColor src = aa << SK_A32_SHIFT; michael@0: unsigned dst_scale = 256 - aa; michael@0: int n = count; michael@0: do { michael@0: --n; michael@0: device[n] = src + SkAlphaMulQ(device[n], dst_scale); michael@0: } while (n > 0); michael@0: } michael@0: } michael@0: runs += count; michael@0: antialias += count; michael@0: device += count; michael@0: } michael@0: } michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: // Special version of SkBlitRow::Factory32 that knows we're in kSrc_Mode, michael@0: // instead of kSrcOver_Mode michael@0: static void blend_srcmode(SkPMColor* SK_RESTRICT device, michael@0: const SkPMColor* SK_RESTRICT span, michael@0: int count, U8CPU aa) { michael@0: int aa256 = SkAlpha255To256(aa); michael@0: for (int i = 0; i < count; ++i) { michael@0: device[i] = SkFourByteInterp256(span[i], device[i], aa256); michael@0: } michael@0: } michael@0: michael@0: SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter(const SkBitmap& device, michael@0: const SkPaint& paint) : INHERITED(device, paint) { michael@0: fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * (sizeof(SkPMColor))); michael@0: michael@0: fXfermode = paint.getXfermode(); michael@0: SkSafeRef(fXfermode); michael@0: michael@0: int flags = 0; michael@0: if (!(fShader->getFlags() & SkShader::kOpaqueAlpha_Flag)) { michael@0: flags |= SkBlitRow::kSrcPixelAlpha_Flag32; michael@0: } michael@0: // we call this on the output from the shader michael@0: fProc32 = SkBlitRow::Factory32(flags); michael@0: // we call this on the output from the shader + alpha from the aa buffer michael@0: fProc32Blend = SkBlitRow::Factory32(flags | SkBlitRow::kGlobalAlpha_Flag32); michael@0: michael@0: fShadeDirectlyIntoDevice = false; michael@0: if (fXfermode == NULL) { michael@0: if (fShader->getFlags() & SkShader::kOpaqueAlpha_Flag) { michael@0: fShadeDirectlyIntoDevice = true; michael@0: } michael@0: } else { michael@0: SkXfermode::Mode mode; michael@0: if (fXfermode->asMode(&mode)) { michael@0: if (SkXfermode::kSrc_Mode == mode) { michael@0: fShadeDirectlyIntoDevice = true; michael@0: fProc32Blend = blend_srcmode; michael@0: } michael@0: } michael@0: } michael@0: michael@0: fConstInY = SkToBool(fShader->getFlags() & SkShader::kConstInY32_Flag); michael@0: } michael@0: michael@0: SkARGB32_Shader_Blitter::~SkARGB32_Shader_Blitter() { michael@0: SkSafeUnref(fXfermode); michael@0: sk_free(fBuffer); michael@0: } michael@0: michael@0: void SkARGB32_Shader_Blitter::blitH(int x, int y, int width) { michael@0: SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width()); michael@0: michael@0: uint32_t* device = fDevice.getAddr32(x, y); michael@0: michael@0: if (fShadeDirectlyIntoDevice) { michael@0: fShader->shadeSpan(x, y, device, width); michael@0: } else { michael@0: SkPMColor* span = fBuffer; michael@0: fShader->shadeSpan(x, y, span, width); michael@0: if (fXfermode) { michael@0: fXfermode->xfer32(device, span, width, NULL); michael@0: } else { michael@0: fProc32(device, span, width, 255); michael@0: } michael@0: } michael@0: } michael@0: michael@0: void SkARGB32_Shader_Blitter::blitRect(int x, int y, int width, int height) { michael@0: SkASSERT(x >= 0 && y >= 0 && michael@0: x + width <= fDevice.width() && y + height <= fDevice.height()); michael@0: michael@0: uint32_t* device = fDevice.getAddr32(x, y); michael@0: size_t deviceRB = fDevice.rowBytes(); michael@0: SkShader* shader = fShader; michael@0: SkPMColor* span = fBuffer; michael@0: michael@0: if (fConstInY) { michael@0: if (fShadeDirectlyIntoDevice) { michael@0: // shade the first row directly into the device michael@0: fShader->shadeSpan(x, y, device, width); michael@0: span = device; michael@0: while (--height > 0) { michael@0: device = (uint32_t*)((char*)device + deviceRB); michael@0: memcpy(device, span, width << 2); michael@0: } michael@0: } else { michael@0: fShader->shadeSpan(x, y, span, width); michael@0: SkXfermode* xfer = fXfermode; michael@0: if (xfer) { michael@0: do { michael@0: xfer->xfer32(device, span, width, NULL); michael@0: y += 1; michael@0: device = (uint32_t*)((char*)device + deviceRB); michael@0: } while (--height > 0); michael@0: } else { michael@0: SkBlitRow::Proc32 proc = fProc32; michael@0: do { michael@0: proc(device, span, width, 255); michael@0: y += 1; michael@0: device = (uint32_t*)((char*)device + deviceRB); michael@0: } while (--height > 0); michael@0: } michael@0: } michael@0: return; michael@0: } michael@0: michael@0: if (fShadeDirectlyIntoDevice) { michael@0: void* ctx; michael@0: SkShader::ShadeProc shadeProc = fShader->asAShadeProc(&ctx); michael@0: if (shadeProc) { michael@0: do { michael@0: shadeProc(ctx, x, y, device, width); michael@0: y += 1; michael@0: device = (uint32_t*)((char*)device + deviceRB); michael@0: } while (--height > 0); michael@0: } else { michael@0: do { michael@0: shader->shadeSpan(x, y, device, width); michael@0: y += 1; michael@0: device = (uint32_t*)((char*)device + deviceRB); michael@0: } while (--height > 0); michael@0: } michael@0: } else { michael@0: SkXfermode* xfer = fXfermode; michael@0: if (xfer) { michael@0: do { michael@0: shader->shadeSpan(x, y, span, width); michael@0: xfer->xfer32(device, span, width, NULL); michael@0: y += 1; michael@0: device = (uint32_t*)((char*)device + deviceRB); michael@0: } while (--height > 0); michael@0: } else { michael@0: SkBlitRow::Proc32 proc = fProc32; michael@0: do { michael@0: shader->shadeSpan(x, y, span, width); michael@0: proc(device, span, width, 255); michael@0: y += 1; michael@0: device = (uint32_t*)((char*)device + deviceRB); michael@0: } while (--height > 0); michael@0: } michael@0: } michael@0: } michael@0: michael@0: void SkARGB32_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], michael@0: const int16_t runs[]) { michael@0: SkPMColor* span = fBuffer; michael@0: uint32_t* device = fDevice.getAddr32(x, y); michael@0: SkShader* shader = fShader; michael@0: michael@0: if (fXfermode && !fShadeDirectlyIntoDevice) { michael@0: for (;;) { michael@0: SkXfermode* xfer = fXfermode; michael@0: michael@0: int count = *runs; michael@0: if (count <= 0) michael@0: break; michael@0: int aa = *antialias; michael@0: if (aa) { michael@0: shader->shadeSpan(x, y, span, count); michael@0: if (aa == 255) { michael@0: xfer->xfer32(device, span, count, NULL); michael@0: } else { michael@0: // count is almost always 1 michael@0: for (int i = count - 1; i >= 0; --i) { michael@0: xfer->xfer32(&device[i], &span[i], 1, antialias); michael@0: } michael@0: } michael@0: } michael@0: device += count; michael@0: runs += count; michael@0: antialias += count; michael@0: x += count; michael@0: } michael@0: } else if (fShadeDirectlyIntoDevice || michael@0: (fShader->getFlags() & SkShader::kOpaqueAlpha_Flag)) { michael@0: for (;;) { michael@0: int count = *runs; michael@0: if (count <= 0) { michael@0: break; michael@0: } michael@0: int aa = *antialias; michael@0: if (aa) { michael@0: if (aa == 255) { michael@0: // cool, have the shader draw right into the device michael@0: shader->shadeSpan(x, y, device, count); michael@0: } else { michael@0: shader->shadeSpan(x, y, span, count); michael@0: fProc32Blend(device, span, count, aa); michael@0: } michael@0: } michael@0: device += count; michael@0: runs += count; michael@0: antialias += count; michael@0: x += count; michael@0: } michael@0: } else { michael@0: for (;;) { michael@0: int count = *runs; michael@0: if (count <= 0) { michael@0: break; michael@0: } michael@0: int aa = *antialias; michael@0: if (aa) { michael@0: fShader->shadeSpan(x, y, span, count); michael@0: if (aa == 255) { michael@0: fProc32(device, span, count, 255); michael@0: } else { michael@0: fProc32Blend(device, span, count, aa); michael@0: } michael@0: } michael@0: device += count; michael@0: runs += count; michael@0: antialias += count; michael@0: x += count; michael@0: } michael@0: } michael@0: } michael@0: michael@0: void SkARGB32_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) { michael@0: // we only handle kA8 with an xfermode michael@0: if (fXfermode && (SkMask::kA8_Format != mask.fFormat)) { michael@0: this->INHERITED::blitMask(mask, clip); michael@0: return; michael@0: } michael@0: michael@0: SkASSERT(mask.fBounds.contains(clip)); michael@0: michael@0: SkBlitMask::RowProc proc = NULL; michael@0: if (!fXfermode) { michael@0: unsigned flags = 0; michael@0: if (fShader->getFlags() & SkShader::kOpaqueAlpha_Flag) { michael@0: flags |= SkBlitMask::kSrcIsOpaque_RowFlag; michael@0: } michael@0: proc = SkBlitMask::RowFactory(SkBitmap::kARGB_8888_Config, mask.fFormat, michael@0: (SkBlitMask::RowFlags)flags); michael@0: if (NULL == proc) { michael@0: this->INHERITED::blitMask(mask, clip); michael@0: return; michael@0: } michael@0: } michael@0: michael@0: const int x = clip.fLeft; michael@0: const int width = clip.width(); michael@0: int y = clip.fTop; michael@0: int height = clip.height(); michael@0: michael@0: char* dstRow = (char*)fDevice.getAddr32(x, y); michael@0: const size_t dstRB = fDevice.rowBytes(); michael@0: const uint8_t* maskRow = (const uint8_t*)mask.getAddr(x, y); michael@0: const size_t maskRB = mask.fRowBytes; michael@0: michael@0: SkShader* shader = fShader; michael@0: SkPMColor* span = fBuffer; michael@0: michael@0: if (fXfermode) { michael@0: SkASSERT(SkMask::kA8_Format == mask.fFormat); michael@0: SkXfermode* xfer = fXfermode; michael@0: do { michael@0: shader->shadeSpan(x, y, span, width); michael@0: xfer->xfer32((SkPMColor*)dstRow, span, width, maskRow); michael@0: dstRow += dstRB; michael@0: maskRow += maskRB; michael@0: y += 1; michael@0: } while (--height > 0); michael@0: } else { michael@0: do { michael@0: shader->shadeSpan(x, y, span, width); michael@0: proc(dstRow, maskRow, span, width); michael@0: dstRow += dstRB; michael@0: maskRow += maskRB; michael@0: y += 1; michael@0: } while (--height > 0); michael@0: } michael@0: } michael@0: michael@0: void SkARGB32_Shader_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { michael@0: SkASSERT(x >= 0 && y >= 0 && y + height <= fDevice.height()); michael@0: michael@0: uint32_t* device = fDevice.getAddr32(x, y); michael@0: size_t deviceRB = fDevice.rowBytes(); michael@0: SkShader* shader = fShader; michael@0: michael@0: if (fConstInY) { michael@0: SkPMColor c; michael@0: fShader->shadeSpan(x, y, &c, 1); michael@0: michael@0: if (fShadeDirectlyIntoDevice) { michael@0: if (255 == alpha) { michael@0: do { michael@0: *device = c; michael@0: device = (uint32_t*)((char*)device + deviceRB); michael@0: } while (--height > 0); michael@0: } else { michael@0: do { michael@0: *device = SkFourByteInterp(c, *device, alpha); michael@0: device = (uint32_t*)((char*)device + deviceRB); michael@0: } while (--height > 0); michael@0: } michael@0: } else { michael@0: SkXfermode* xfer = fXfermode; michael@0: if (xfer) { michael@0: do { michael@0: xfer->xfer32(device, &c, 1, &alpha); michael@0: device = (uint32_t*)((char*)device + deviceRB); michael@0: } while (--height > 0); michael@0: } else { michael@0: SkBlitRow::Proc32 proc = (255 == alpha) ? fProc32 : fProc32Blend; michael@0: do { michael@0: proc(device, &c, 1, alpha); michael@0: device = (uint32_t*)((char*)device + deviceRB); michael@0: } while (--height > 0); michael@0: } michael@0: } michael@0: return; michael@0: } michael@0: michael@0: if (fShadeDirectlyIntoDevice) { michael@0: void* ctx; michael@0: SkShader::ShadeProc shadeProc = fShader->asAShadeProc(&ctx); michael@0: if (255 == alpha) { michael@0: if (shadeProc) { michael@0: do { michael@0: shadeProc(ctx, x, y, device, 1); michael@0: y += 1; michael@0: device = (uint32_t*)((char*)device + deviceRB); michael@0: } while (--height > 0); michael@0: } else { michael@0: do { michael@0: shader->shadeSpan(x, y, device, 1); michael@0: y += 1; michael@0: device = (uint32_t*)((char*)device + deviceRB); michael@0: } while (--height > 0); michael@0: } michael@0: } else { // alpha < 255 michael@0: SkPMColor c; michael@0: if (shadeProc) { michael@0: do { michael@0: shadeProc(ctx, x, y, &c, 1); michael@0: *device = SkFourByteInterp(c, *device, alpha); michael@0: y += 1; michael@0: device = (uint32_t*)((char*)device + deviceRB); michael@0: } while (--height > 0); michael@0: } else { michael@0: do { michael@0: shader->shadeSpan(x, y, &c, 1); michael@0: *device = SkFourByteInterp(c, *device, alpha); michael@0: y += 1; michael@0: device = (uint32_t*)((char*)device + deviceRB); michael@0: } while (--height > 0); michael@0: } michael@0: } michael@0: } else { michael@0: SkPMColor* span = fBuffer; michael@0: SkXfermode* xfer = fXfermode; michael@0: if (xfer) { michael@0: do { michael@0: shader->shadeSpan(x, y, span, 1); michael@0: xfer->xfer32(device, span, 1, &alpha); michael@0: y += 1; michael@0: device = (uint32_t*)((char*)device + deviceRB); michael@0: } while (--height > 0); michael@0: } else { michael@0: SkBlitRow::Proc32 proc = (255 == alpha) ? fProc32 : fProc32Blend; michael@0: do { michael@0: shader->shadeSpan(x, y, span, 1); michael@0: proc(device, span, 1, alpha); michael@0: y += 1; michael@0: device = (uint32_t*)((char*)device + deviceRB); michael@0: } while (--height > 0); michael@0: } michael@0: } michael@0: }