From: reed@google.com Date: Thu, 2 May 2013 20:39:44 +0000 (+0000) Subject: add HACK_COLORGLYPHS (disabled) to test colorglyphs X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~12523 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f77b35d86ad439917bda78334deb31fbcc16cdae;p=platform%2Fupstream%2FlibSkiaSharp.git add HACK_COLORGLYPHS (disabled) to test colorglyphs git-svn-id: http://skia.googlecode.com/svn/trunk@8972 2bbb7eff-a529-9590-31e7-b0007b416f81 --- diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp index a706e05..1bb1801 100755 --- a/src/ports/SkFontHost_mac.cpp +++ b/src/ports/SkFontHost_mac.cpp @@ -43,6 +43,8 @@ #include "SkTypefaceCache.h" #include "SkFontMgr.h" +//#define HACK_COLORGLYPHS + class SkScalerContext_Mac; // CTFontManagerCopyAvailableFontFamilyNames() is not always available, so we @@ -1082,6 +1084,9 @@ void SkScalerContext_Mac::generateMetrics(SkGlyph* glyph) { glyph->fLeft += offset.fX; glyph->fTop += offset.fY; } +#ifdef HACK_COLORGLYPHS + glyph->fMaskFormat = SkMask::kARGB32_Format; +#endif } #include "SkColorPriv.h" @@ -1197,6 +1202,23 @@ static void rgb_to_lcd32(const CGRGBPixel* SK_RESTRICT cgPixels, size_t cgRowByt } } +#ifdef HACK_COLORGLYPHS +// hack to colorize the output for testing kARGB32_Format +static SkPMColor cgpixels_to_pmcolor(CGRGBPixel rgb, const SkGlyph& glyph, + int x, int y) { + U8CPU r = (rgb >> 16) & 0xFF; + U8CPU g = (rgb >> 8) & 0xFF; + U8CPU b = (rgb >> 0) & 0xFF; + unsigned a = SkComputeLuminance(r, g, b); + + // compute gradient from x,y + r = x * 255 / glyph.fWidth; + g = 0; + b = (glyph.fHeight - y) * 255 / glyph.fHeight; + return SkPreMultiplyARGB(a, r, g, b); // red +} +#endif + template T* SkTAddByteOffset(T* ptr, size_t byteOffset) { return (T*)((char*)ptr + byteOffset); } @@ -1277,6 +1299,20 @@ void SkScalerContext_Mac::generateImage(const SkGlyph& glyph) { dst += dstRB; } } break; +#ifdef HACK_COLORGLYPHS + case SkMask::kARGB32_Format: { + const int width = glyph.fWidth; + size_t dstRB = glyph.rowBytes(); + SkPMColor* dst = (SkPMColor*)glyph.fImage; + for (int y = 0; y < glyph.fHeight; y++) { + for (int x = 0; x < width; ++x) { + dst[x] = cgpixels_to_pmcolor(cgPixels[x], glyph, x, y); + } + cgPixels = (CGRGBPixel*)((char*)cgPixels + cgRowBytes); + dst = (SkPMColor*)((char*)dst + dstRB); + } + } break; +#endif default: SkDEBUGFAIL("unexpected mask format"); break;