submit LCD alpha support

http://codereview.appspot.com/4851042/

M    src/core/SkBlitter_ARGB32.cpp



git-svn-id: http://skia.googlecode.com/svn/trunk@2047 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
caryclark@google.com 2011-08-05 14:17:12 +00:00
parent a5a1da81d0
commit 53d11e0655

View File

@ -28,10 +28,13 @@ static inline int blend32(int src, int dst, int scale) {
} }
static void blit_lcd16_opaque(SkPMColor dst[], const uint16_t src[], static void blit_lcd16_opaque(SkPMColor dst[], const uint16_t src[],
SkPMColor color, int width) { SkColor color, int width) {
int srcR = SkGetPackedR32(color); int srcA = SkColorGetA(color);
int srcG = SkGetPackedG32(color); int srcR = SkColorGetR(color);
int srcB = SkGetPackedB32(color); int srcG = SkColorGetG(color);
int srcB = SkColorGetB(color);
srcA = SkAlpha255To256(srcA);
for (int i = 0; i < width; i++) { for (int i = 0; i < width; i++) {
uint16_t mask = src[i]; uint16_t mask = src[i];
@ -48,11 +51,15 @@ static void blit_lcd16_opaque(SkPMColor dst[], const uint16_t src[],
int maskG = SkGetPackedG16(mask) >> (SK_G16_BITS - 5); int maskG = SkGetPackedG16(mask) >> (SK_G16_BITS - 5);
int maskB = SkGetPackedB16(mask) >> (SK_B16_BITS - 5); int maskB = SkGetPackedB16(mask) >> (SK_B16_BITS - 5);
// Now upscale them to 0..256, so we can use SkAlphaBlend // Now upscale them to 0..32, so we can use blend32
maskR = upscale31To32(maskR); maskR = upscale31To32(maskR);
maskG = upscale31To32(maskG); maskG = upscale31To32(maskG);
maskB = upscale31To32(maskB); maskB = upscale31To32(maskB);
maskR = maskR * srcA >> 8;
maskG = maskG * srcA >> 8;
maskB = maskB * srcA >> 8;
int maskA = SkMax32(SkMax32(maskR, maskG), maskB); int maskA = SkMax32(SkMax32(maskR, maskG), maskB);
int dstA = SkGetPackedA32(d); int dstA = SkGetPackedA32(d);
@ -68,10 +75,13 @@ static void blit_lcd16_opaque(SkPMColor dst[], const uint16_t src[],
} }
static void blit_lcd32_opaque(SkPMColor dst[], const uint32_t src[], static void blit_lcd32_opaque(SkPMColor dst[], const uint32_t src[],
SkPMColor color, int width) { SkColor color, int width) {
int srcR = SkGetPackedR32(color); int srcA = SkColorGetA(color);
int srcG = SkGetPackedG32(color); int srcR = SkColorGetR(color);
int srcB = SkGetPackedB32(color); int srcG = SkColorGetG(color);
int srcB = SkColorGetB(color);
srcA = SkAlpha255To256(srcA);
for (int i = 0; i < width; i++) { for (int i = 0; i < width; i++) {
uint32_t mask = src[i]; uint32_t mask = src[i];
@ -90,6 +100,10 @@ static void blit_lcd32_opaque(SkPMColor dst[], const uint32_t src[],
maskG = SkAlpha255To256(maskG); maskG = SkAlpha255To256(maskG);
maskB = SkAlpha255To256(maskB); maskB = SkAlpha255To256(maskB);
maskR = maskR * srcA >> 8;
maskG = maskG * srcA >> 8;
maskB = maskB * srcA >> 8;
int maskA = SkMax32(SkMax32(maskR, maskG), maskB); int maskA = SkMax32(SkMax32(maskR, maskG), maskB);
int dstA = SkGetPackedA32(d); int dstA = SkGetPackedA32(d);
@ -105,7 +119,7 @@ static void blit_lcd32_opaque(SkPMColor dst[], const uint32_t src[],
} }
static void blitmask_lcd16(const SkBitmap& device, const SkMask& mask, static void blitmask_lcd16(const SkBitmap& device, const SkMask& mask,
const SkIRect& clip, SkPMColor srcColor) { const SkIRect& clip, SkColor srcColor) {
int x = clip.fLeft; int x = clip.fLeft;
int y = clip.fTop; int y = clip.fTop;
int width = clip.width(); int width = clip.width();
@ -122,7 +136,7 @@ static void blitmask_lcd16(const SkBitmap& device, const SkMask& mask,
} }
static void blitmask_lcd32(const SkBitmap& device, const SkMask& mask, static void blitmask_lcd32(const SkBitmap& device, const SkMask& mask,
const SkIRect& clip, SkPMColor srcColor) { const SkIRect& clip, SkColor srcColor) {
int x = clip.fLeft; int x = clip.fLeft;
int y = clip.fTop; int y = clip.fTop;
int width = clip.width(); int width = clip.width();
@ -290,10 +304,10 @@ void SkARGB32_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) {
SkARGB32_Blit32(fDevice, mask, clip, fPMColor); SkARGB32_Blit32(fDevice, mask, clip, fPMColor);
return; return;
} else if (SkMask::kLCD16_Format == mask.fFormat) { } else if (SkMask::kLCD16_Format == mask.fFormat) {
blitmask_lcd16(fDevice, mask, clip, fPMColor); blitmask_lcd16(fDevice, mask, clip, fColor);
return; return;
} else if (SkMask::kLCD32_Format == mask.fFormat) { } else if (SkMask::kLCD32_Format == mask.fFormat) {
blitmask_lcd32(fDevice, mask, clip, fPMColor); blitmask_lcd32(fDevice, mask, clip, fColor);
return; return;
} }
@ -317,10 +331,10 @@ void SkARGB32_Opaque_Blitter::blitMask(const SkMask& mask,
SkARGB32_Blit32(fDevice, mask, clip, fPMColor); SkARGB32_Blit32(fDevice, mask, clip, fPMColor);
return; return;
} else if (SkMask::kLCD16_Format == mask.fFormat) { } else if (SkMask::kLCD16_Format == mask.fFormat) {
blitmask_lcd16(fDevice, mask, clip, fPMColor); blitmask_lcd16(fDevice, mask, clip, fColor);
return; return;
} else if (SkMask::kLCD32_Format == mask.fFormat) { } else if (SkMask::kLCD32_Format == mask.fFormat) {
blitmask_lcd32(fDevice, mask, clip, fPMColor); blitmask_lcd32(fDevice, mask, clip, fColor);
return; return;
} }
@ -396,9 +410,9 @@ void SkARGB32_Black_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) {
} else if (SkMask::kARGB32_Format == mask.fFormat) { } else if (SkMask::kARGB32_Format == mask.fFormat) {
SkARGB32_Blit32(fDevice, mask, clip, fPMColor); SkARGB32_Blit32(fDevice, mask, clip, fPMColor);
} else if (SkMask::kLCD16_Format == mask.fFormat) { } else if (SkMask::kLCD16_Format == mask.fFormat) {
blitmask_lcd16(fDevice, mask, clip, fPMColor); blitmask_lcd16(fDevice, mask, clip, fColor);
} else if (SkMask::kLCD32_Format == mask.fFormat) { } else if (SkMask::kLCD32_Format == mask.fFormat) {
blitmask_lcd32(fDevice, mask, clip, fPMColor); blitmask_lcd32(fDevice, mask, clip, fColor);
} else { } else {
fBlitMaskProc(fDevice.getAddr32(clip.fLeft, clip.fTop), fBlitMaskProc(fDevice.getAddr32(clip.fLeft, clip.fTop),
fDevice.rowBytes(), fDevice.rowBytes(),