///////////////////////////////////////////////////////////////////////////////
-static void SkARGB32_BlitMask_portable(void* dst, size_t dstRB,
- SkBitmap::Config dstConfig,
- const uint8_t* mask,
- size_t maskRB, SkColor color,
- int width, int height) {
+static void D32_Mask_Color(void* dst, size_t dstRB, SkBitmap::Config,
+ const uint8_t* mask, size_t maskRB, SkColor color,
+ int width, int height) {
+ SkPMColor pmc = SkPreMultiplyColor(color);
size_t dstOffset = dstRB - (width << 2);
size_t maskOffset = maskRB - width;
SkPMColor *device = (SkPMColor *)dst;
int w = width;
do {
unsigned aa = *mask++;
- *device = SkBlendARGB32(color, *device, aa);
+ *device = SkBlendARGB32(pmc, *device, aa);
device += 1;
} while (--w != 0);
device = (uint32_t*)((char*)device + dstOffset);
} while (--height != 0);
}
+static void D32_Mask_Opaque(void* dst, size_t dstRB, SkBitmap::Config,
+ const uint8_t* mask, size_t maskRB, SkColor color,
+ int width, int height) {
+ SkPMColor pmc = SkPreMultiplyColor(color);
+ uint32_t* device = (uint32_t*)dst;
+
+ maskRB -= width;
+ dstRB -= (width << 2);
+ do {
+ int w = width;
+ do {
+ unsigned aa = *mask++;
+ *device = SkAlphaMulQ(pmc, SkAlpha255To256(aa)) + SkAlphaMulQ(*device, SkAlpha255To256(255 - aa));
+ device += 1;
+ } while (--w != 0);
+ device = (uint32_t*)((char*)device + dstRB);
+ mask += maskRB;
+ } while (--height != 0);
+}
+
+static void D32_Mask_Black(void* dst, size_t dstRB, SkBitmap::Config,
+ const uint8_t* mask, size_t maskRB, SkColor,
+ int width, int height) {
+ uint32_t* device = (uint32_t*)dst;
+
+ maskRB -= width;
+ dstRB -= (width << 2);
+ do {
+ int w = width;
+ do {
+ unsigned aa = *mask++;
+ *device = (aa << SK_A32_SHIFT) + SkAlphaMulQ(*device, SkAlpha255To256(255 - aa));
+ device += 1;
+ } while (--w != 0);
+ device = (uint32_t*)((char*)device + dstRB);
+ mask += maskRB;
+ } while (--height != 0);
+}
+
SkBlitMask::Proc SkBlitMask::Factory(SkBitmap::Config config, SkColor color) {
SkBlitMask::Proc proc = PlatformProcs(config, color);
+ proc = NULL;
if (NULL == proc) {
switch (config) {
case SkBitmap::kARGB_8888_Config:
- if ( SK_ColorBLACK != color && 0xFF != SkColorGetA(color) ) {
- //TODO: blitmask for black;
- //TODO: blitmask for opaque;
- proc = SkARGB32_BlitMask_portable;
+ if (SK_ColorBLACK == color) {
+ proc = D32_Mask_Black;
+ } else if (0xFF == SkColorGetA(color)) {
+ proc = D32_Mask_Opaque;
+ } else {
+ proc = D32_Mask_Color;
}
break;
default:
SkARGB32_Blitter::SkARGB32_Blitter(const SkBitmap& device, const SkPaint& paint)
: INHERITED(device) {
- uint32_t color = paint.getColor();
+ SkColor color = paint.getColor();
+ fColor = color;
fSrcA = SkColorGetA(color);
unsigned scale = SkAlpha255To256(fSrcA);
int x = clip.fLeft;
int y = clip.fTop;
- int width = clip.width();
- int height = clip.height();
- uint32_t* device = fDevice.getAddr32(x, y);
- const uint8_t* alpha = mask.getAddr(x, y);
- uint32_t srcColor = fPMColor;
- fBlitMaskProc(device, fDevice.rowBytes(), SkBitmap::kARGB_8888_Config,
- alpha, mask.fRowBytes, srcColor, width, height);
+ fBlitMaskProc(fDevice.getAddr32(x, y), fDevice.rowBytes(),
+ SkBitmap::kARGB_8888_Config,
+ mask.getAddr(x, y), mask.fRowBytes,
+ fColor, clip.width(), clip.height());
}
void SkARGB32_Opaque_Blitter::blitMask(const SkMask& mask,
#endif
// In LCD mode the masks have either an extra couple of rows or columns on the edges.
- uint32_t srcColor = fPMColor;
+ SkPMColor srcColor = fPMColor;
#if defined(SK_SUPPORT_LCDTEXT)
if (lcdMode || verticalLCDMode) {
}
#endif
- uint32_t* device = fDevice.getAddr32(x, y);
- const uint8_t* alpha = mask.getAddr(x, y);
- unsigned maskRB = mask.fRowBytes - width;
- unsigned devRB = fDevice.rowBytes() - (width << 2);
- do {
- int w = width;
- do {
- unsigned aa = *alpha++;
- *device = SkAlphaMulQ(srcColor, SkAlpha255To256(aa)) + SkAlphaMulQ(*device, SkAlpha255To256(255 - aa));
- device += 1;
- } while (--w != 0);
- device = (uint32_t*)((char*)device + devRB);
- alpha += maskRB;
- } while (--height != 0);
+ fBlitMaskProc(fDevice.getAddr32(x, y), fDevice.rowBytes(),
+ SkBitmap::kARGB_8888_Config,
+ mask.getAddr(x, y), mask.fRowBytes, fColor, width, height);
}
//////////////////////////////////////////////////////////////////////////////////////
virtual const SkBitmap* justAnOpaqueColor(uint32_t*);
protected:
- SkColor fPMColor;
+ SkColor fColor;
+ SkPMColor fPMColor;
SkBlitRow::ColorProc fColor32Proc;
SkBlitMask::Proc fBlitMaskProc;
void SkARGB32_BlitMask_SSE2(void* device, size_t dstRB,
SkBitmap::Config dstConfig, const uint8_t* mask,
- size_t maskRB, SkColor color,
+ size_t maskRB, SkColor origColor,
int width, int height)
{
+ SkPMColor color = SkPreMultiplyColor(origColor);
size_t dstOffset = dstRB - (width << 2);
size_t maskOffset = maskRB - width;
SkPMColor* dst = (SkPMColor *)device;