diff options
author | caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-06-22 13:19:43 +0000 |
---|---|---|
committer | caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-06-22 13:19:43 +0000 |
commit | 1eeaf0ba2381f84ffd889f56303cbe0d1886bb21 (patch) | |
tree | 99852310e8d9f0a3f7a9c94f3ff0afb0375b48e4 /src/core | |
parent | 3c898186c9082c535e589807752a0a9dc5d28aa0 (diff) |
Add support for 8 bits/component glyphs, to
better match the fonts produced by CoreText on OS/X.
M include/config/SkUserConfig.h
M include/core/SkMask.h
M include/core/SkScalerContext.h
M src/core/SkBlitter_ARGB32.cpp
M src/core/SkScalerContext.cpp
M src/core/SkPaint.cpp
M src/gpu/SkGrFontScaler.cpp
M src/ports/SkFontHost_mac_coretext.cpp
M src/ports/SkFontHost_mac.cpp
M gpu/include/GrTypes.h
M gpu/src/GrAtlas.cpp
git-svn-id: http://skia.googlecode.com/svn/trunk@1672 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkBlitter_ARGB32.cpp | 62 | ||||
-rw-r--r-- | src/core/SkPaint.cpp | 8 | ||||
-rw-r--r-- | src/core/SkScalerContext.cpp | 1 |
3 files changed, 70 insertions, 1 deletions
diff --git a/src/core/SkBlitter_ARGB32.cpp b/src/core/SkBlitter_ARGB32.cpp index dec355a1e4..1901937080 100644 --- a/src/core/SkBlitter_ARGB32.cpp +++ b/src/core/SkBlitter_ARGB32.cpp @@ -92,6 +92,43 @@ static void blit_lcd16_opaque(SkPMColor dst[], const uint16_t src[], } } +static void blit_lcd32_opaque(SkPMColor dst[], const uint32_t src[], + SkPMColor color, int width) { + int srcR = SkGetPackedR32(color); + int srcG = SkGetPackedG32(color); + int srcB = SkGetPackedB32(color); + + for (int i = 0; i < width; i++) { + uint32_t mask = src[i]; + if (0 == mask) { + continue; + } + + SkPMColor d = dst[i]; + + int maskR = SkGetPackedR32(mask); + int maskG = SkGetPackedG32(mask); + int maskB = SkGetPackedB32(mask); + + // Now upscale them to 0..256, so we can use SkAlphaBlend + maskR = SkAlpha255To256(maskR); + maskG = SkAlpha255To256(maskG); + maskB = SkAlpha255To256(maskB); + + int maskA = SkMax32(SkMax32(maskR, maskG), maskB); + + int dstA = SkGetPackedA32(d); + int dstR = SkGetPackedR32(d); + int dstG = SkGetPackedG32(d); + int dstB = SkGetPackedB32(d); + + dst[i] = SkPackARGB32(SkAlphaBlend(0xFF, dstA, maskA), + SkAlphaBlend(srcR, dstR, maskR), + SkAlphaBlend(srcG, dstG, maskG), + SkAlphaBlend(srcB, dstB, maskB)); + } +} + static void blitmask_lcd16(const SkBitmap& device, const SkMask& mask, const SkIRect& clip, SkPMColor srcColor) { int x = clip.fLeft; @@ -109,6 +146,23 @@ static void blitmask_lcd16(const SkBitmap& device, const SkMask& mask, } while (--height != 0); } +static void blitmask_lcd32(const SkBitmap& device, const SkMask& mask, + const SkIRect& clip, SkPMColor srcColor) { + int x = clip.fLeft; + int y = clip.fTop; + int width = clip.width(); + int height = clip.height(); + + SkPMColor* dstRow = device.getAddr32(x, y); + const uint32_t* srcRow = mask.getAddrLCD32(x, y); + + do { + blit_lcd32_opaque(dstRow, srcRow, srcColor, width); + dstRow = (SkPMColor*)((char*)dstRow + device.rowBytes()); + srcRow = (const uint32_t*)((const char*)srcRow + mask.fRowBytes); + } while (--height != 0); +} + ////////////////////////////////////////////////////////////////////////////////////// static void SkARGB32_Blit32(const SkBitmap& device, const SkMask& mask, @@ -263,6 +317,9 @@ void SkARGB32_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) { } else if (SkMask::kLCD16_Format == mask.fFormat) { blitmask_lcd16(fDevice, mask, clip, fPMColor); return; + } else if (SkMask::kLCD32_Format == mask.fFormat) { + blitmask_lcd32(fDevice, mask, clip, fPMColor); + return; } int x = clip.fLeft; @@ -287,6 +344,9 @@ void SkARGB32_Opaque_Blitter::blitMask(const SkMask& mask, } else if (SkMask::kLCD16_Format == mask.fFormat) { blitmask_lcd16(fDevice, mask, clip, fPMColor); return; + } else if (SkMask::kLCD32_Format == mask.fFormat) { + blitmask_lcd32(fDevice, mask, clip, fPMColor); + return; } int x = clip.fLeft; @@ -395,6 +455,8 @@ void SkARGB32_Black_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) { SkARGB32_Blit32(fDevice, mask, clip, fPMColor); } else if (SkMask::kLCD16_Format == mask.fFormat) { blitmask_lcd16(fDevice, mask, clip, fPMColor); + } else if (SkMask::kLCD32_Format == mask.fFormat) { + blitmask_lcd32(fDevice, mask, clip, fPMColor); } else { #if defined(SK_SUPPORT_LCDTEXT) const bool lcdMode = mask.fFormat == SkMask::kHorizontalLCD_Format; diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index f9abe3f420..0608320f40 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -1198,7 +1198,11 @@ static SkMask::Format computeMaskFormat(const SkPaint& paint) { } #else if (flags & SkPaint::kLCDRenderText_Flag) { +#if !defined(SK_SUPPORT_888_TEXT) return SkMask::kLCD16_Format; +#else + return SkMask::kLCD32_Format; +#endif } #endif @@ -1294,7 +1298,9 @@ void SkScalerContext::MakeRec(const SkPaint& paint, rec->fMaskFormat = SkToU8(computeMaskFormat(paint)); - if (SkMask::kLCD16_Format == rec->fMaskFormat) { + if (SkMask::kLCD16_Format == rec->fMaskFormat || + SkMask::kLCD32_Format == rec->fMaskFormat) + { SkFontHost::LCDOrder order = SkFontHost::GetSubpixelOrder(); SkFontHost::LCDOrientation orient = SkFontHost::GetSubpixelOrientation(); if (SkFontHost::kNONE_LCDOrder == order) { diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp index 05439f1f55..2109531c0b 100644 --- a/src/core/SkScalerContext.cpp +++ b/src/core/SkScalerContext.cpp @@ -497,6 +497,7 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) { if (NULL == fMaskFilter && fRec.fMaskFormat != SkMask::kBW_Format && fRec.fMaskFormat != SkMask::kLCD16_Format && + fRec.fMaskFormat != SkMask::kLCD32_Format && (fRec.fFlags & (kGammaForBlack_Flag | kGammaForWhite_Flag)) != 0) { const uint8_t* table = (fRec.fFlags & kGammaForBlack_Flag) ? gBlackGammaTable : gWhiteGammaTable; |