1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/core/SkBlitter_ARGB32.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,638 @@ 1.4 +/* 1.5 + * Copyright 2006 The Android Open Source Project 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license that can be 1.8 + * found in the LICENSE file. 1.9 + */ 1.10 + 1.11 +#include "SkCoreBlitters.h" 1.12 +#include "SkColorPriv.h" 1.13 +#include "SkShader.h" 1.14 +#include "SkUtils.h" 1.15 +#include "SkXfermode.h" 1.16 +#include "SkBlitMask.h" 1.17 + 1.18 +/////////////////////////////////////////////////////////////////////////////// 1.19 + 1.20 +static void SkARGB32_Blit32(const SkBitmap& device, const SkMask& mask, 1.21 + const SkIRect& clip, SkPMColor srcColor) { 1.22 + U8CPU alpha = SkGetPackedA32(srcColor); 1.23 + unsigned flags = SkBlitRow::kSrcPixelAlpha_Flag32; 1.24 + if (alpha != 255) { 1.25 + flags |= SkBlitRow::kGlobalAlpha_Flag32; 1.26 + } 1.27 + SkBlitRow::Proc32 proc = SkBlitRow::Factory32(flags); 1.28 + 1.29 + int x = clip.fLeft; 1.30 + int y = clip.fTop; 1.31 + int width = clip.width(); 1.32 + int height = clip.height(); 1.33 + 1.34 + SkPMColor* dstRow = device.getAddr32(x, y); 1.35 + const SkPMColor* srcRow = reinterpret_cast<const SkPMColor*>(mask.getAddr8(x, y)); 1.36 + 1.37 + do { 1.38 + proc(dstRow, srcRow, width, alpha); 1.39 + dstRow = (SkPMColor*)((char*)dstRow + device.rowBytes()); 1.40 + srcRow = (const SkPMColor*)((const char*)srcRow + mask.fRowBytes); 1.41 + } while (--height != 0); 1.42 +} 1.43 + 1.44 +////////////////////////////////////////////////////////////////////////////////////// 1.45 + 1.46 +SkARGB32_Blitter::SkARGB32_Blitter(const SkBitmap& device, const SkPaint& paint) 1.47 + : INHERITED(device) { 1.48 + SkColor color = paint.getColor(); 1.49 + fColor = color; 1.50 + 1.51 + fSrcA = SkColorGetA(color); 1.52 + unsigned scale = SkAlpha255To256(fSrcA); 1.53 + fSrcR = SkAlphaMul(SkColorGetR(color), scale); 1.54 + fSrcG = SkAlphaMul(SkColorGetG(color), scale); 1.55 + fSrcB = SkAlphaMul(SkColorGetB(color), scale); 1.56 + 1.57 + fPMColor = SkPackARGB32(fSrcA, fSrcR, fSrcG, fSrcB); 1.58 + fColor32Proc = SkBlitRow::ColorProcFactory(); 1.59 + fColorRect32Proc = SkBlitRow::ColorRectProcFactory(); 1.60 +} 1.61 + 1.62 +const SkBitmap* SkARGB32_Blitter::justAnOpaqueColor(uint32_t* value) { 1.63 + if (255 == fSrcA) { 1.64 + *value = fPMColor; 1.65 + return &fDevice; 1.66 + } 1.67 + return NULL; 1.68 +} 1.69 + 1.70 +#if defined _WIN32 && _MSC_VER >= 1300 // disable warning : local variable used without having been initialized 1.71 +#pragma warning ( push ) 1.72 +#pragma warning ( disable : 4701 ) 1.73 +#endif 1.74 + 1.75 +void SkARGB32_Blitter::blitH(int x, int y, int width) { 1.76 + SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width()); 1.77 + 1.78 + uint32_t* device = fDevice.getAddr32(x, y); 1.79 + fColor32Proc(device, device, width, fPMColor); 1.80 +} 1.81 + 1.82 +void SkARGB32_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], 1.83 + const int16_t runs[]) { 1.84 + if (fSrcA == 0) { 1.85 + return; 1.86 + } 1.87 + 1.88 + uint32_t color = fPMColor; 1.89 + uint32_t* device = fDevice.getAddr32(x, y); 1.90 + unsigned opaqueMask = fSrcA; // if fSrcA is 0xFF, then we will catch the fast opaque case 1.91 + 1.92 + for (;;) { 1.93 + int count = runs[0]; 1.94 + SkASSERT(count >= 0); 1.95 + if (count <= 0) { 1.96 + return; 1.97 + } 1.98 + unsigned aa = antialias[0]; 1.99 + if (aa) { 1.100 + if ((opaqueMask & aa) == 255) { 1.101 + sk_memset32(device, color, count); 1.102 + } else { 1.103 + uint32_t sc = SkAlphaMulQ(color, SkAlpha255To256(aa)); 1.104 + fColor32Proc(device, device, count, sc); 1.105 + } 1.106 + } 1.107 + runs += count; 1.108 + antialias += count; 1.109 + device += count; 1.110 + } 1.111 +} 1.112 + 1.113 +////////////////////////////////////////////////////////////////////////////////////// 1.114 + 1.115 +#define solid_8_pixels(mask, dst, color) \ 1.116 + do { \ 1.117 + if (mask & 0x80) dst[0] = color; \ 1.118 + if (mask & 0x40) dst[1] = color; \ 1.119 + if (mask & 0x20) dst[2] = color; \ 1.120 + if (mask & 0x10) dst[3] = color; \ 1.121 + if (mask & 0x08) dst[4] = color; \ 1.122 + if (mask & 0x04) dst[5] = color; \ 1.123 + if (mask & 0x02) dst[6] = color; \ 1.124 + if (mask & 0x01) dst[7] = color; \ 1.125 + } while (0) 1.126 + 1.127 +#define SK_BLITBWMASK_NAME SkARGB32_BlitBW 1.128 +#define SK_BLITBWMASK_ARGS , SkPMColor color 1.129 +#define SK_BLITBWMASK_BLIT8(mask, dst) solid_8_pixels(mask, dst, color) 1.130 +#define SK_BLITBWMASK_GETADDR getAddr32 1.131 +#define SK_BLITBWMASK_DEVTYPE uint32_t 1.132 +#include "SkBlitBWMaskTemplate.h" 1.133 + 1.134 +#define blend_8_pixels(mask, dst, sc, dst_scale) \ 1.135 + do { \ 1.136 + if (mask & 0x80) { dst[0] = sc + SkAlphaMulQ(dst[0], dst_scale); } \ 1.137 + if (mask & 0x40) { dst[1] = sc + SkAlphaMulQ(dst[1], dst_scale); } \ 1.138 + if (mask & 0x20) { dst[2] = sc + SkAlphaMulQ(dst[2], dst_scale); } \ 1.139 + if (mask & 0x10) { dst[3] = sc + SkAlphaMulQ(dst[3], dst_scale); } \ 1.140 + if (mask & 0x08) { dst[4] = sc + SkAlphaMulQ(dst[4], dst_scale); } \ 1.141 + if (mask & 0x04) { dst[5] = sc + SkAlphaMulQ(dst[5], dst_scale); } \ 1.142 + if (mask & 0x02) { dst[6] = sc + SkAlphaMulQ(dst[6], dst_scale); } \ 1.143 + if (mask & 0x01) { dst[7] = sc + SkAlphaMulQ(dst[7], dst_scale); } \ 1.144 + } while (0) 1.145 + 1.146 +#define SK_BLITBWMASK_NAME SkARGB32_BlendBW 1.147 +#define SK_BLITBWMASK_ARGS , uint32_t sc, unsigned dst_scale 1.148 +#define SK_BLITBWMASK_BLIT8(mask, dst) blend_8_pixels(mask, dst, sc, dst_scale) 1.149 +#define SK_BLITBWMASK_GETADDR getAddr32 1.150 +#define SK_BLITBWMASK_DEVTYPE uint32_t 1.151 +#include "SkBlitBWMaskTemplate.h" 1.152 + 1.153 +void SkARGB32_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) { 1.154 + SkASSERT(mask.fBounds.contains(clip)); 1.155 + SkASSERT(fSrcA != 0xFF); 1.156 + 1.157 + if (fSrcA == 0) { 1.158 + return; 1.159 + } 1.160 + 1.161 + if (SkBlitMask::BlitColor(fDevice, mask, clip, fColor)) { 1.162 + return; 1.163 + } 1.164 + 1.165 + if (mask.fFormat == SkMask::kBW_Format) { 1.166 + SkARGB32_BlendBW(fDevice, mask, clip, fPMColor, SkAlpha255To256(255 - fSrcA)); 1.167 + } else if (SkMask::kARGB32_Format == mask.fFormat) { 1.168 + SkARGB32_Blit32(fDevice, mask, clip, fPMColor); 1.169 + } 1.170 +} 1.171 + 1.172 +void SkARGB32_Opaque_Blitter::blitMask(const SkMask& mask, 1.173 + const SkIRect& clip) { 1.174 + SkASSERT(mask.fBounds.contains(clip)); 1.175 + 1.176 + if (SkBlitMask::BlitColor(fDevice, mask, clip, fColor)) { 1.177 + return; 1.178 + } 1.179 + 1.180 + if (mask.fFormat == SkMask::kBW_Format) { 1.181 + SkARGB32_BlitBW(fDevice, mask, clip, fPMColor); 1.182 + } else if (SkMask::kARGB32_Format == mask.fFormat) { 1.183 + SkARGB32_Blit32(fDevice, mask, clip, fPMColor); 1.184 + } 1.185 +} 1.186 + 1.187 +/////////////////////////////////////////////////////////////////////////////// 1.188 + 1.189 +void SkARGB32_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { 1.190 + if (alpha == 0 || fSrcA == 0) { 1.191 + return; 1.192 + } 1.193 + 1.194 + uint32_t* device = fDevice.getAddr32(x, y); 1.195 + uint32_t color = fPMColor; 1.196 + 1.197 + if (alpha != 255) { 1.198 + color = SkAlphaMulQ(color, SkAlpha255To256(alpha)); 1.199 + } 1.200 + 1.201 + unsigned dst_scale = 255 - SkGetPackedA32(color); 1.202 + size_t rowBytes = fDevice.rowBytes(); 1.203 + while (--height >= 0) { 1.204 + device[0] = color + SkAlphaMulQ(device[0], dst_scale); 1.205 + device = (uint32_t*)((char*)device + rowBytes); 1.206 + } 1.207 +} 1.208 + 1.209 +void SkARGB32_Blitter::blitRect(int x, int y, int width, int height) { 1.210 + SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width() && y + height <= fDevice.height()); 1.211 + 1.212 + if (fSrcA == 0) { 1.213 + return; 1.214 + } 1.215 + 1.216 + uint32_t* device = fDevice.getAddr32(x, y); 1.217 + uint32_t color = fPMColor; 1.218 + size_t rowBytes = fDevice.rowBytes(); 1.219 + 1.220 + if (255 == SkGetPackedA32(color)) { 1.221 + fColorRect32Proc(device, width, height, rowBytes, color); 1.222 + } else { 1.223 + while (--height >= 0) { 1.224 + fColor32Proc(device, device, width, color); 1.225 + device = (uint32_t*)((char*)device + rowBytes); 1.226 + } 1.227 + } 1.228 +} 1.229 + 1.230 +#if defined _WIN32 && _MSC_VER >= 1300 1.231 +#pragma warning ( pop ) 1.232 +#endif 1.233 + 1.234 +/////////////////////////////////////////////////////////////////////// 1.235 + 1.236 +void SkARGB32_Black_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], 1.237 + const int16_t runs[]) { 1.238 + uint32_t* device = fDevice.getAddr32(x, y); 1.239 + SkPMColor black = (SkPMColor)(SK_A32_MASK << SK_A32_SHIFT); 1.240 + 1.241 + for (;;) { 1.242 + int count = runs[0]; 1.243 + SkASSERT(count >= 0); 1.244 + if (count <= 0) { 1.245 + return; 1.246 + } 1.247 + unsigned aa = antialias[0]; 1.248 + if (aa) { 1.249 + if (aa == 255) { 1.250 + sk_memset32(device, black, count); 1.251 + } else { 1.252 + SkPMColor src = aa << SK_A32_SHIFT; 1.253 + unsigned dst_scale = 256 - aa; 1.254 + int n = count; 1.255 + do { 1.256 + --n; 1.257 + device[n] = src + SkAlphaMulQ(device[n], dst_scale); 1.258 + } while (n > 0); 1.259 + } 1.260 + } 1.261 + runs += count; 1.262 + antialias += count; 1.263 + device += count; 1.264 + } 1.265 +} 1.266 + 1.267 +/////////////////////////////////////////////////////////////////////////////// 1.268 + 1.269 +// Special version of SkBlitRow::Factory32 that knows we're in kSrc_Mode, 1.270 +// instead of kSrcOver_Mode 1.271 +static void blend_srcmode(SkPMColor* SK_RESTRICT device, 1.272 + const SkPMColor* SK_RESTRICT span, 1.273 + int count, U8CPU aa) { 1.274 + int aa256 = SkAlpha255To256(aa); 1.275 + for (int i = 0; i < count; ++i) { 1.276 + device[i] = SkFourByteInterp256(span[i], device[i], aa256); 1.277 + } 1.278 +} 1.279 + 1.280 +SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter(const SkBitmap& device, 1.281 + const SkPaint& paint) : INHERITED(device, paint) { 1.282 + fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * (sizeof(SkPMColor))); 1.283 + 1.284 + fXfermode = paint.getXfermode(); 1.285 + SkSafeRef(fXfermode); 1.286 + 1.287 + int flags = 0; 1.288 + if (!(fShader->getFlags() & SkShader::kOpaqueAlpha_Flag)) { 1.289 + flags |= SkBlitRow::kSrcPixelAlpha_Flag32; 1.290 + } 1.291 + // we call this on the output from the shader 1.292 + fProc32 = SkBlitRow::Factory32(flags); 1.293 + // we call this on the output from the shader + alpha from the aa buffer 1.294 + fProc32Blend = SkBlitRow::Factory32(flags | SkBlitRow::kGlobalAlpha_Flag32); 1.295 + 1.296 + fShadeDirectlyIntoDevice = false; 1.297 + if (fXfermode == NULL) { 1.298 + if (fShader->getFlags() & SkShader::kOpaqueAlpha_Flag) { 1.299 + fShadeDirectlyIntoDevice = true; 1.300 + } 1.301 + } else { 1.302 + SkXfermode::Mode mode; 1.303 + if (fXfermode->asMode(&mode)) { 1.304 + if (SkXfermode::kSrc_Mode == mode) { 1.305 + fShadeDirectlyIntoDevice = true; 1.306 + fProc32Blend = blend_srcmode; 1.307 + } 1.308 + } 1.309 + } 1.310 + 1.311 + fConstInY = SkToBool(fShader->getFlags() & SkShader::kConstInY32_Flag); 1.312 +} 1.313 + 1.314 +SkARGB32_Shader_Blitter::~SkARGB32_Shader_Blitter() { 1.315 + SkSafeUnref(fXfermode); 1.316 + sk_free(fBuffer); 1.317 +} 1.318 + 1.319 +void SkARGB32_Shader_Blitter::blitH(int x, int y, int width) { 1.320 + SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width()); 1.321 + 1.322 + uint32_t* device = fDevice.getAddr32(x, y); 1.323 + 1.324 + if (fShadeDirectlyIntoDevice) { 1.325 + fShader->shadeSpan(x, y, device, width); 1.326 + } else { 1.327 + SkPMColor* span = fBuffer; 1.328 + fShader->shadeSpan(x, y, span, width); 1.329 + if (fXfermode) { 1.330 + fXfermode->xfer32(device, span, width, NULL); 1.331 + } else { 1.332 + fProc32(device, span, width, 255); 1.333 + } 1.334 + } 1.335 +} 1.336 + 1.337 +void SkARGB32_Shader_Blitter::blitRect(int x, int y, int width, int height) { 1.338 + SkASSERT(x >= 0 && y >= 0 && 1.339 + x + width <= fDevice.width() && y + height <= fDevice.height()); 1.340 + 1.341 + uint32_t* device = fDevice.getAddr32(x, y); 1.342 + size_t deviceRB = fDevice.rowBytes(); 1.343 + SkShader* shader = fShader; 1.344 + SkPMColor* span = fBuffer; 1.345 + 1.346 + if (fConstInY) { 1.347 + if (fShadeDirectlyIntoDevice) { 1.348 + // shade the first row directly into the device 1.349 + fShader->shadeSpan(x, y, device, width); 1.350 + span = device; 1.351 + while (--height > 0) { 1.352 + device = (uint32_t*)((char*)device + deviceRB); 1.353 + memcpy(device, span, width << 2); 1.354 + } 1.355 + } else { 1.356 + fShader->shadeSpan(x, y, span, width); 1.357 + SkXfermode* xfer = fXfermode; 1.358 + if (xfer) { 1.359 + do { 1.360 + xfer->xfer32(device, span, width, NULL); 1.361 + y += 1; 1.362 + device = (uint32_t*)((char*)device + deviceRB); 1.363 + } while (--height > 0); 1.364 + } else { 1.365 + SkBlitRow::Proc32 proc = fProc32; 1.366 + do { 1.367 + proc(device, span, width, 255); 1.368 + y += 1; 1.369 + device = (uint32_t*)((char*)device + deviceRB); 1.370 + } while (--height > 0); 1.371 + } 1.372 + } 1.373 + return; 1.374 + } 1.375 + 1.376 + if (fShadeDirectlyIntoDevice) { 1.377 + void* ctx; 1.378 + SkShader::ShadeProc shadeProc = fShader->asAShadeProc(&ctx); 1.379 + if (shadeProc) { 1.380 + do { 1.381 + shadeProc(ctx, x, y, device, width); 1.382 + y += 1; 1.383 + device = (uint32_t*)((char*)device + deviceRB); 1.384 + } while (--height > 0); 1.385 + } else { 1.386 + do { 1.387 + shader->shadeSpan(x, y, device, width); 1.388 + y += 1; 1.389 + device = (uint32_t*)((char*)device + deviceRB); 1.390 + } while (--height > 0); 1.391 + } 1.392 + } else { 1.393 + SkXfermode* xfer = fXfermode; 1.394 + if (xfer) { 1.395 + do { 1.396 + shader->shadeSpan(x, y, span, width); 1.397 + xfer->xfer32(device, span, width, NULL); 1.398 + y += 1; 1.399 + device = (uint32_t*)((char*)device + deviceRB); 1.400 + } while (--height > 0); 1.401 + } else { 1.402 + SkBlitRow::Proc32 proc = fProc32; 1.403 + do { 1.404 + shader->shadeSpan(x, y, span, width); 1.405 + proc(device, span, width, 255); 1.406 + y += 1; 1.407 + device = (uint32_t*)((char*)device + deviceRB); 1.408 + } while (--height > 0); 1.409 + } 1.410 + } 1.411 +} 1.412 + 1.413 +void SkARGB32_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], 1.414 + const int16_t runs[]) { 1.415 + SkPMColor* span = fBuffer; 1.416 + uint32_t* device = fDevice.getAddr32(x, y); 1.417 + SkShader* shader = fShader; 1.418 + 1.419 + if (fXfermode && !fShadeDirectlyIntoDevice) { 1.420 + for (;;) { 1.421 + SkXfermode* xfer = fXfermode; 1.422 + 1.423 + int count = *runs; 1.424 + if (count <= 0) 1.425 + break; 1.426 + int aa = *antialias; 1.427 + if (aa) { 1.428 + shader->shadeSpan(x, y, span, count); 1.429 + if (aa == 255) { 1.430 + xfer->xfer32(device, span, count, NULL); 1.431 + } else { 1.432 + // count is almost always 1 1.433 + for (int i = count - 1; i >= 0; --i) { 1.434 + xfer->xfer32(&device[i], &span[i], 1, antialias); 1.435 + } 1.436 + } 1.437 + } 1.438 + device += count; 1.439 + runs += count; 1.440 + antialias += count; 1.441 + x += count; 1.442 + } 1.443 + } else if (fShadeDirectlyIntoDevice || 1.444 + (fShader->getFlags() & SkShader::kOpaqueAlpha_Flag)) { 1.445 + for (;;) { 1.446 + int count = *runs; 1.447 + if (count <= 0) { 1.448 + break; 1.449 + } 1.450 + int aa = *antialias; 1.451 + if (aa) { 1.452 + if (aa == 255) { 1.453 + // cool, have the shader draw right into the device 1.454 + shader->shadeSpan(x, y, device, count); 1.455 + } else { 1.456 + shader->shadeSpan(x, y, span, count); 1.457 + fProc32Blend(device, span, count, aa); 1.458 + } 1.459 + } 1.460 + device += count; 1.461 + runs += count; 1.462 + antialias += count; 1.463 + x += count; 1.464 + } 1.465 + } else { 1.466 + for (;;) { 1.467 + int count = *runs; 1.468 + if (count <= 0) { 1.469 + break; 1.470 + } 1.471 + int aa = *antialias; 1.472 + if (aa) { 1.473 + fShader->shadeSpan(x, y, span, count); 1.474 + if (aa == 255) { 1.475 + fProc32(device, span, count, 255); 1.476 + } else { 1.477 + fProc32Blend(device, span, count, aa); 1.478 + } 1.479 + } 1.480 + device += count; 1.481 + runs += count; 1.482 + antialias += count; 1.483 + x += count; 1.484 + } 1.485 + } 1.486 +} 1.487 + 1.488 +void SkARGB32_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) { 1.489 + // we only handle kA8 with an xfermode 1.490 + if (fXfermode && (SkMask::kA8_Format != mask.fFormat)) { 1.491 + this->INHERITED::blitMask(mask, clip); 1.492 + return; 1.493 + } 1.494 + 1.495 + SkASSERT(mask.fBounds.contains(clip)); 1.496 + 1.497 + SkBlitMask::RowProc proc = NULL; 1.498 + if (!fXfermode) { 1.499 + unsigned flags = 0; 1.500 + if (fShader->getFlags() & SkShader::kOpaqueAlpha_Flag) { 1.501 + flags |= SkBlitMask::kSrcIsOpaque_RowFlag; 1.502 + } 1.503 + proc = SkBlitMask::RowFactory(SkBitmap::kARGB_8888_Config, mask.fFormat, 1.504 + (SkBlitMask::RowFlags)flags); 1.505 + if (NULL == proc) { 1.506 + this->INHERITED::blitMask(mask, clip); 1.507 + return; 1.508 + } 1.509 + } 1.510 + 1.511 + const int x = clip.fLeft; 1.512 + const int width = clip.width(); 1.513 + int y = clip.fTop; 1.514 + int height = clip.height(); 1.515 + 1.516 + char* dstRow = (char*)fDevice.getAddr32(x, y); 1.517 + const size_t dstRB = fDevice.rowBytes(); 1.518 + const uint8_t* maskRow = (const uint8_t*)mask.getAddr(x, y); 1.519 + const size_t maskRB = mask.fRowBytes; 1.520 + 1.521 + SkShader* shader = fShader; 1.522 + SkPMColor* span = fBuffer; 1.523 + 1.524 + if (fXfermode) { 1.525 + SkASSERT(SkMask::kA8_Format == mask.fFormat); 1.526 + SkXfermode* xfer = fXfermode; 1.527 + do { 1.528 + shader->shadeSpan(x, y, span, width); 1.529 + xfer->xfer32((SkPMColor*)dstRow, span, width, maskRow); 1.530 + dstRow += dstRB; 1.531 + maskRow += maskRB; 1.532 + y += 1; 1.533 + } while (--height > 0); 1.534 + } else { 1.535 + do { 1.536 + shader->shadeSpan(x, y, span, width); 1.537 + proc(dstRow, maskRow, span, width); 1.538 + dstRow += dstRB; 1.539 + maskRow += maskRB; 1.540 + y += 1; 1.541 + } while (--height > 0); 1.542 + } 1.543 +} 1.544 + 1.545 +void SkARGB32_Shader_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { 1.546 + SkASSERT(x >= 0 && y >= 0 && y + height <= fDevice.height()); 1.547 + 1.548 + uint32_t* device = fDevice.getAddr32(x, y); 1.549 + size_t deviceRB = fDevice.rowBytes(); 1.550 + SkShader* shader = fShader; 1.551 + 1.552 + if (fConstInY) { 1.553 + SkPMColor c; 1.554 + fShader->shadeSpan(x, y, &c, 1); 1.555 + 1.556 + if (fShadeDirectlyIntoDevice) { 1.557 + if (255 == alpha) { 1.558 + do { 1.559 + *device = c; 1.560 + device = (uint32_t*)((char*)device + deviceRB); 1.561 + } while (--height > 0); 1.562 + } else { 1.563 + do { 1.564 + *device = SkFourByteInterp(c, *device, alpha); 1.565 + device = (uint32_t*)((char*)device + deviceRB); 1.566 + } while (--height > 0); 1.567 + } 1.568 + } else { 1.569 + SkXfermode* xfer = fXfermode; 1.570 + if (xfer) { 1.571 + do { 1.572 + xfer->xfer32(device, &c, 1, &alpha); 1.573 + device = (uint32_t*)((char*)device + deviceRB); 1.574 + } while (--height > 0); 1.575 + } else { 1.576 + SkBlitRow::Proc32 proc = (255 == alpha) ? fProc32 : fProc32Blend; 1.577 + do { 1.578 + proc(device, &c, 1, alpha); 1.579 + device = (uint32_t*)((char*)device + deviceRB); 1.580 + } while (--height > 0); 1.581 + } 1.582 + } 1.583 + return; 1.584 + } 1.585 + 1.586 + if (fShadeDirectlyIntoDevice) { 1.587 + void* ctx; 1.588 + SkShader::ShadeProc shadeProc = fShader->asAShadeProc(&ctx); 1.589 + if (255 == alpha) { 1.590 + if (shadeProc) { 1.591 + do { 1.592 + shadeProc(ctx, x, y, device, 1); 1.593 + y += 1; 1.594 + device = (uint32_t*)((char*)device + deviceRB); 1.595 + } while (--height > 0); 1.596 + } else { 1.597 + do { 1.598 + shader->shadeSpan(x, y, device, 1); 1.599 + y += 1; 1.600 + device = (uint32_t*)((char*)device + deviceRB); 1.601 + } while (--height > 0); 1.602 + } 1.603 + } else { // alpha < 255 1.604 + SkPMColor c; 1.605 + if (shadeProc) { 1.606 + do { 1.607 + shadeProc(ctx, x, y, &c, 1); 1.608 + *device = SkFourByteInterp(c, *device, alpha); 1.609 + y += 1; 1.610 + device = (uint32_t*)((char*)device + deviceRB); 1.611 + } while (--height > 0); 1.612 + } else { 1.613 + do { 1.614 + shader->shadeSpan(x, y, &c, 1); 1.615 + *device = SkFourByteInterp(c, *device, alpha); 1.616 + y += 1; 1.617 + device = (uint32_t*)((char*)device + deviceRB); 1.618 + } while (--height > 0); 1.619 + } 1.620 + } 1.621 + } else { 1.622 + SkPMColor* span = fBuffer; 1.623 + SkXfermode* xfer = fXfermode; 1.624 + if (xfer) { 1.625 + do { 1.626 + shader->shadeSpan(x, y, span, 1); 1.627 + xfer->xfer32(device, span, 1, &alpha); 1.628 + y += 1; 1.629 + device = (uint32_t*)((char*)device + deviceRB); 1.630 + } while (--height > 0); 1.631 + } else { 1.632 + SkBlitRow::Proc32 proc = (255 == alpha) ? fProc32 : fProc32Blend; 1.633 + do { 1.634 + shader->shadeSpan(x, y, span, 1); 1.635 + proc(device, span, 1, alpha); 1.636 + y += 1; 1.637 + device = (uint32_t*)((char*)device + deviceRB); 1.638 + } while (--height > 0); 1.639 + } 1.640 + } 1.641 +}