virtual void blitRect(int x, int y, int width, int height) { SkASSERT(width > 0 && height > 0); SK_RESTRICT SkPMColor* dst = fDevice->getAddr32(x, y); const SK_RESTRICT SkPMColor16* src = fSource->getAddr16(x - fLeft, y - fTop); unsigned dstRB = fDevice->rowBytes(); unsigned srcRB = fSource->rowBytes(); SK_RESTRICT SkPMColor* buffer = fBuffer; SkColorFilter* colorFilter = fColorFilter; SkXfermode* xfermode = fXfermode; do { fillbuffer(buffer, src, width); if (NULL != colorFilter) { colorFilter->filterSpan(buffer, width, buffer); } if (NULL != xfermode) { xfermode->xfer32(dst, buffer, width, NULL); } else { fProc32(dst, buffer, width, fAlpha); } dst = (SK_RESTRICT SkPMColor*)((char*)dst + dstRB); src = (const SK_RESTRICT SkPMColor16*)((const char*)src + srcRB); } while (--height != 0); }
void SkARGB32_Shader_Blitter::blitH(int x, int y, int width) { SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width()); uint32_t* device = fDevice.getAddr32(x, y); if (fXfermode == NULL && (fShader->getFlags() & SkShader::kOpaqueAlpha_Flag)) { fShader->shadeSpan(x, y, device, width); } else { SkPMColor* span = fBuffer; fShader->shadeSpan(x, y, span, width); if (fXfermode) { fXfermode->xfer32(device, span, width, NULL); } else { fProc32(device, span, width, 255); } } }
void SkARGB32_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) { SkPMColor* span = fBuffer; uint32_t* device = fDevice.getAddr32(x, y); SkShader* shader = fShader; if (fXfermode) { for (;;) { SkXfermode* xfer = fXfermode; int count = *runs; if (count <= 0) break; int aa = *antialias; if (aa) { shader->shadeSpan(x, y, span, count); if (aa == 255) { xfer->xfer32(device, span, count, NULL); } else { // count is almost always 1 for (int i = count - 1; i >= 0; --i) { xfer->xfer32(&device[i], &span[i], 1, antialias); } } } device += count; runs += count; antialias += count; x += count; } } else if (fShader->getFlags() & SkShader::kOpaqueAlpha_Flag) { for (;;) { int count = *runs; if (count <= 0) { break; } int aa = *antialias; if (aa) { if (aa == 255) { // cool, have the shader draw right into the device shader->shadeSpan(x, y, device, count); } else { shader->shadeSpan(x, y, span, count); fProc32Blend(device, span, count, aa); } } device += count; runs += count; antialias += count; x += count; } } else { // no xfermode but the shader not opaque for (;;) { int count = *runs; if (count <= 0) { break; } int aa = *antialias; if (aa) { fShader->shadeSpan(x, y, span, count); if (aa == 255) { fProc32(device, span, count, 255); } else { fProc32Blend(device, span, count, aa); } } device += count; runs += count; antialias += count; x += count; } } }