diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-03-02 16:02:07 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-03-02 16:02:07 +0000 |
commit | d61b92b63c0a3619c3b7d08d1e4cd4aeef8028fe (patch) | |
tree | 4763b3dc53659390b0061105670238ce6171d947 | |
parent | 3f5ebb431f548740d0f4f650682e49475c695ff3 (diff) |
restore old no-gamma behavior when requested
Review URL: https://codereview.appspot.com/5722047
git-svn-id: http://skia.googlecode.com/svn/trunk@3303 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | src/ports/SkFontHost_FreeType.cpp | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index 39d6a0809e..da1040daa3 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -1116,7 +1116,19 @@ static const uint8_t* getGammaTable(U8CPU luminance) { return gGammaTables[luminance >> 6]; } - +#ifndef SK_USE_COLOR_LUMINANCE +static const uint8_t* getIdentityTable() { + static bool gOnce; + static uint8_t gIdentityTable[256]; + if (!gOnce) { + for (int i = 0; i < 256; ++i) { + gIdentityTable[i] = i; + } + gOnce = true; + } + return gIdentityTable; +} +#endif static uint16_t packTriple(unsigned r, unsigned g, unsigned b) { return SkPackRGB16(r >> 3, g >> 2, b >> 3); @@ -1212,9 +1224,17 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) { const uint8_t* tableB = getGammaTable(SkColorGetB(lumColor)); #else unsigned lum = fRec.getLuminanceByte(); - const uint8_t* tableR = getGammaTable(lum); - const uint8_t* tableG = getGammaTable(lum); - const uint8_t* tableB = getGammaTable(lum); + const uint8_t* tableR; + const uint8_t* tableG; + const uint8_t* tableB; + + bool isWhite = lum >= WHITE_LUMINANCE_LIMIT; + bool isBlack = lum <= BLACK_LUMINANCE_LIMIT; + if ((gGammaTables[0] || gGammaTables[1]) && (isBlack || isWhite)) { + tableR = tableG = tableB = gGammaTables[isBlack ? 0 : 1]; + } else { + tableR = tableG = tableB = getIdentityTable(); + } #endif switch ( fFace->glyph->format ) { @@ -1328,7 +1348,9 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) { goto ERROR; } -#ifdef SK_GAMMA_APPLY_TO_A8 +// We used to always do this pre-USE_COLOR_LUMINANCE, but with colorlum, +// it is optional +#if defined(SK_GAMMA_APPLY_TO_A8) || !defined(SK_USE_COLOR_LUMINANCE) if (SkMask::kA8_Format == glyph.fMaskFormat) { SkASSERT(tableR == tableG && tableR == tableB); const uint8_t* table = tableR; |