aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports
diff options
context:
space:
mode:
authorGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-10-26 19:35:54 +0000
committerGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-10-26 19:35:54 +0000
commita76de72a6036da0a6b051b14411b80941971f881 (patch)
tree140b2d29d87aa3cb966b7c76e14028ff9cdf76fe /src/ports
parentde96163a80167636d95837f9ee6a2e98baf9d350 (diff)
Clean up usage of mask gamma.
Diffstat (limited to 'src/ports')
-rw-r--r--src/ports/SkFontHost_FreeType.cpp20
-rw-r--r--src/ports/SkFontHost_FreeType_common.cpp31
-rw-r--r--src/ports/SkFontHost_FreeType_common.h2
-rw-r--r--src/ports/SkFontHost_mac_coretext.cpp36
-rwxr-xr-xsrc/ports/SkFontHost_win.cpp39
-rw-r--r--src/ports/SkFontHost_win_dw.cpp34
6 files changed, 63 insertions, 99 deletions
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index c3f75959ec..35dc22b597 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -169,15 +169,15 @@ public:
}
protected:
- virtual unsigned generateGlyphCount();
- virtual uint16_t generateCharToGlyph(SkUnichar uni);
- virtual void generateAdvance(SkGlyph* glyph);
- virtual void generateMetrics(SkGlyph* glyph);
- virtual void generateImage(const SkGlyph& glyph, SkMaskGamma::PreBlend* maskPreBlend);
- virtual void generatePath(const SkGlyph& glyph, SkPath* path);
+ virtual unsigned generateGlyphCount() SK_OVERRIDE;
+ virtual uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE;
+ virtual void generateAdvance(SkGlyph* glyph) SK_OVERRIDE;
+ virtual void generateMetrics(SkGlyph* glyph) SK_OVERRIDE;
+ virtual void generateImage(const SkGlyph& glyph) SK_OVERRIDE;
+ virtual void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE;
virtual void generateFontMetrics(SkPaint::FontMetrics* mx,
- SkPaint::FontMetrics* my);
- virtual SkUnichar generateGlyphToChar(uint16_t glyph);
+ SkPaint::FontMetrics* my) SK_OVERRIDE;
+ virtual SkUnichar generateGlyphToChar(uint16_t glyph) SK_OVERRIDE;
private:
SkFaceRec* fFaceRec;
@@ -1135,7 +1135,7 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) {
}
-void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph, SkMaskGamma::PreBlend* maskPreBlend) {
+void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) {
SkAutoMutexAcquire ac(gFTMutex);
FT_Error err;
@@ -1153,7 +1153,7 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph, SkMaskGamma::
return;
}
- generateGlyphImage(fFace, glyph, maskPreBlend);
+ generateGlyphImage(fFace, glyph);
}
diff --git a/src/ports/SkFontHost_FreeType_common.cpp b/src/ports/SkFontHost_FreeType_common.cpp
index 3a827d70bc..a6fb0dc0fd 100644
--- a/src/ports/SkFontHost_FreeType_common.cpp
+++ b/src/ports/SkFontHost_FreeType_common.cpp
@@ -119,20 +119,7 @@ static void copyFT2LCD16(const SkGlyph& glyph, const FT_Bitmap& bitmap,
}
}
-void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face,
- const SkGlyph& glyph,
- SkMaskGamma::PreBlend* maskPreBlend)
-{
- //Must be careful not to use these if maskPreBlend == NULL
- const uint8_t* tableR = NULL;
- const uint8_t* tableG = NULL;
- const uint8_t* tableB = NULL;
- if (maskPreBlend) {
- tableR = maskPreBlend->fR;
- tableG = maskPreBlend->fG;
- tableB = maskPreBlend->fB;
- }
-
+void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face, const SkGlyph& glyph) {
const bool doBGR = SkToBool(fRec.fFlags & SkScalerContext::kLCD_BGROrder_Flag);
const bool doVert = SkToBool(fRec.fFlags & SkScalerContext::kLCD_Vertical_Flag);
@@ -167,12 +154,12 @@ void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face,
if (SkMask::kLCD16_Format == glyph.fMaskFormat) {
FT_Render_Glyph(face->glyph, doVert ? FT_RENDER_MODE_LCD_V : FT_RENDER_MODE_LCD);
- if (maskPreBlend) {
+ if (fPreBlend.isApplicable()) {
copyFT2LCD16<true>(glyph, face->glyph->bitmap, doBGR, doVert,
- tableR, tableG, tableB);
+ fPreBlend.fR, fPreBlend.fG, fPreBlend.fB);
} else {
copyFT2LCD16<false>(glyph, face->glyph->bitmap, doBGR, doVert,
- tableR, tableG, tableB);
+ fPreBlend.fR, fPreBlend.fG, fPreBlend.fB);
}
} else {
target.width = glyph.fWidth;
@@ -238,12 +225,12 @@ void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face,
dst += glyph.rowBytes();
}
} else if (SkMask::kLCD16_Format == glyph.fMaskFormat) {
- if (maskPreBlend) {
+ if (fPreBlend.isApplicable()) {
copyFT2LCD16<true>(glyph, face->glyph->bitmap, doBGR, doVert,
- tableR, tableG, tableB);
+ fPreBlend.fR, fPreBlend.fG, fPreBlend.fB);
} else {
copyFT2LCD16<false>(glyph, face->glyph->bitmap, doBGR, doVert,
- tableR, tableG, tableB);
+ fPreBlend.fR, fPreBlend.fG, fPreBlend.fB);
}
} else {
SkDEBUGFAIL("unknown glyph bitmap transform needed");
@@ -259,13 +246,13 @@ void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face,
// We used to always do this pre-USE_COLOR_LUMINANCE, but with colorlum,
// it is optional
#if defined(SK_GAMMA_APPLY_TO_A8)
- if (SkMask::kA8_Format == glyph.fMaskFormat && maskPreBlend) {
+ if (SkMask::kA8_Format == glyph.fMaskFormat && fPreBlend.isApplicable()) {
uint8_t* SK_RESTRICT dst = (uint8_t*)glyph.fImage;
unsigned rowBytes = glyph.rowBytes();
for (int y = glyph.fHeight - 1; y >= 0; --y) {
for (int x = glyph.fWidth - 1; x >= 0; --x) {
- dst[x] = tableG[dst[x]];
+ dst[x] = fPreBlend.fG[dst[x]];
}
dst += rowBytes;
}
diff --git a/src/ports/SkFontHost_FreeType_common.h b/src/ports/SkFontHost_FreeType_common.h
index d5f2c08ab2..01100de43e 100644
--- a/src/ports/SkFontHost_FreeType_common.h
+++ b/src/ports/SkFontHost_FreeType_common.h
@@ -36,7 +36,7 @@ public:
{}
protected:
- void generateGlyphImage(FT_Face face, const SkGlyph& glyph, SkMaskGamma::PreBlend* maskPreBlend);
+ void generateGlyphImage(FT_Face face, const SkGlyph& glyph);
void generateGlyphPath(FT_Face face, const SkGlyph& glyph, SkPath* path);
void emboldenOutline(FT_Face face, FT_Outline* outline);
};
diff --git a/src/ports/SkFontHost_mac_coretext.cpp b/src/ports/SkFontHost_mac_coretext.cpp
index e385337388..27e0437406 100644
--- a/src/ports/SkFontHost_mac_coretext.cpp
+++ b/src/ports/SkFontHost_mac_coretext.cpp
@@ -617,7 +617,7 @@ protected:
uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE;
void generateAdvance(SkGlyph* glyph) SK_OVERRIDE;
void generateMetrics(SkGlyph* glyph) SK_OVERRIDE;
- void generateImage(const SkGlyph& glyph, SkMaskGamma::PreBlend* maskPreBlend) SK_OVERRIDE;
+ void generateImage(const SkGlyph& glyph) SK_OVERRIDE;
void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE;
void generateFontMetrics(SkPaint::FontMetrics* mX, SkPaint::FontMetrics* mY) SK_OVERRIDE;
@@ -1198,7 +1198,7 @@ template <typename T> T* SkTAddByteOffset(T* ptr, size_t byteOffset) {
return (T*)((char*)ptr + byteOffset);
}
-void SkScalerContext_Mac::generateImage(const SkGlyph& glyph, SkMaskGamma::PreBlend* maskPreBlend) {
+void SkScalerContext_Mac::generateImage(const SkGlyph& glyph) {
CGGlyph cgGlyph = (CGGlyph) glyph.getGlyphID(fBaseGlyphCount);
// FIXME: lcd smoothed un-hinted rasterization unsupported.
@@ -1237,37 +1237,31 @@ void SkScalerContext_Mac::generateImage(const SkGlyph& glyph, SkMaskGamma::PreBl
}
}
- // Must be careful not to use these if maskPreBlend == NULL
- const uint8_t* tableR = NULL;
- const uint8_t* tableG = NULL;
- const uint8_t* tableB = NULL;
- if (maskPreBlend) {
- tableR = maskPreBlend->fR;
- tableG = maskPreBlend->fG;
- tableB = maskPreBlend->fB;
- }
-
// Convert glyph to mask
switch (glyph.fMaskFormat) {
case SkMask::kLCD32_Format: {
- if (maskPreBlend) {
- rgb_to_lcd32<true>(cgPixels, cgRowBytes, glyph, tableR, tableG, tableB);
+ if (fPreBlend.isApplicable()) {
+ rgb_to_lcd32<true>(cgPixels, cgRowBytes, glyph,
+ fPreBlend.fR, fPreBlend.fG, fPreBlend.fB);
} else {
- rgb_to_lcd32<false>(cgPixels, cgRowBytes, glyph, tableR, tableG, tableB);
+ rgb_to_lcd32<false>(cgPixels, cgRowBytes, glyph,
+ fPreBlend.fR, fPreBlend.fG, fPreBlend.fB);
}
} break;
case SkMask::kLCD16_Format: {
- if (maskPreBlend) {
- rgb_to_lcd16<true>(cgPixels, cgRowBytes, glyph, tableR, tableG, tableB);
+ if (fPreBlend.isApplicable()) {
+ rgb_to_lcd16<true>(cgPixels, cgRowBytes, glyph,
+ fPreBlend.fR, fPreBlend.fG, fPreBlend.fB);
} else {
- rgb_to_lcd16<false>(cgPixels, cgRowBytes, glyph, tableR, tableG, tableB);
+ rgb_to_lcd16<false>(cgPixels, cgRowBytes, glyph,
+ fPreBlend.fR, fPreBlend.fG, fPreBlend.fB);
}
} break;
case SkMask::kA8_Format: {
- if (maskPreBlend) {
- rgb_to_a8<true>(cgPixels, cgRowBytes, glyph, tableG);
+ if (fPreBlend.isApplicable()) {
+ rgb_to_a8<true>(cgPixels, cgRowBytes, glyph, fPreBlend.fG);
} else {
- rgb_to_a8<false>(cgPixels, cgRowBytes, glyph, tableG);
+ rgb_to_a8<false>(cgPixels, cgRowBytes, glyph, fPreBlend.fG);
}
} break;
case SkMask::kBW_Format: {
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
index f2603e99a8..9a377c0cdd 100755
--- a/src/ports/SkFontHost_win.cpp
+++ b/src/ports/SkFontHost_win.cpp
@@ -548,9 +548,10 @@ protected:
virtual uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE;
virtual void generateAdvance(SkGlyph* glyph) SK_OVERRIDE;
virtual void generateMetrics(SkGlyph* glyph) SK_OVERRIDE;
- virtual void generateImage(const SkGlyph& glyph, SkMaskGamma::PreBlend* maskPreBlend) SK_OVERRIDE;
+ virtual void generateImage(const SkGlyph& glyph) SK_OVERRIDE;
virtual void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE;
- virtual void generateFontMetrics(SkPaint::FontMetrics* mX, SkPaint::FontMetrics* mY) SK_OVERRIDE;
+ virtual void generateFontMetrics(SkPaint::FontMetrics* mX,
+ SkPaint::FontMetrics* mY) SK_OVERRIDE;
private:
HDCOffscreen fOffscreen;
@@ -1134,20 +1135,10 @@ static inline unsigned clamp255(unsigned x) {
return x - (x >> 8);
}
-void SkScalerContext_Windows::generateImage(const SkGlyph& glyph, SkMaskGamma::PreBlend* maskPreBlend) {
+void SkScalerContext_Windows::generateImage(const SkGlyph& glyph) {
SkAutoMutexAcquire ac(gFTMutex);
SkASSERT(fDDC);
- //Must be careful not to use these if maskPreBlend == NULL
- const uint8_t* tableR = NULL;
- const uint8_t* tableG = NULL;
- const uint8_t* tableB = NULL;
- if (maskPreBlend) {
- tableR = maskPreBlend->fR;
- tableG = maskPreBlend->fG;
- tableB = maskPreBlend->fB;
- }
-
const bool isBW = SkMask::kBW_Format == fRec.fMaskFormat;
const bool isAA = !isLCD(fRec);
@@ -1202,10 +1193,10 @@ void SkScalerContext_Windows::generateImage(const SkGlyph& glyph, SkMaskGamma::P
// since the caller may require A8 for maskfilters, we can't check for BW
// ... until we have the caller tell us that explicitly
const SkGdiRGB* src = (const SkGdiRGB*)bits;
- if (maskPreBlend) {
- rgb_to_a8<true>(src, srcRB, glyph, tableG);
+ if (fPreBlend.isApplicable()) {
+ rgb_to_a8<true>(src, srcRB, glyph, fPreBlend.fG);
} else {
- rgb_to_a8<false>(src, srcRB, glyph, tableG);
+ rgb_to_a8<false>(src, srcRB, glyph, fPreBlend.fG);
}
} else { // LCD16
const SkGdiRGB* src = (const SkGdiRGB*)bits;
@@ -1214,17 +1205,21 @@ void SkScalerContext_Windows::generateImage(const SkGlyph& glyph, SkMaskGamma::P
((SkGlyph*)&glyph)->fMaskFormat = SkMask::kBW_Format;
} else {
if (SkMask::kLCD16_Format == glyph.fMaskFormat) {
- if (maskPreBlend) {
- rgb_to_lcd16<true>(src, srcRB, glyph, tableR, tableG, tableB);
+ if (fPreBlend.isApplicable()) {
+ rgb_to_lcd16<true>(src, srcRB, glyph,
+ fPreBlend.fR, fPreBlend.fG, fPreBlend.fB);
} else {
- rgb_to_lcd16<false>(src, srcRB, glyph, tableR, tableG, tableB);
+ rgb_to_lcd16<false>(src, srcRB, glyph,
+ fPreBlend.fR, fPreBlend.fG, fPreBlend.fB);
}
} else {
SkASSERT(SkMask::kLCD32_Format == glyph.fMaskFormat);
- if (maskPreBlend) {
- rgb_to_lcd32<true>(src, srcRB, glyph, tableR, tableG, tableB);
+ if (fPreBlend.isApplicable()) {
+ rgb_to_lcd32<true>(src, srcRB, glyph,
+ fPreBlend.fR, fPreBlend.fG, fPreBlend.fB);
} else {
- rgb_to_lcd32<false>(src, srcRB, glyph, tableR, tableG, tableB);
+ rgb_to_lcd32<false>(src, srcRB, glyph,
+ fPreBlend.fR, fPreBlend.fG, fPreBlend.fB);
}
}
}
diff --git a/src/ports/SkFontHost_win_dw.cpp b/src/ports/SkFontHost_win_dw.cpp
index 82d44eeb33..67ee5c4927 100644
--- a/src/ports/SkFontHost_win_dw.cpp
+++ b/src/ports/SkFontHost_win_dw.cpp
@@ -489,8 +489,7 @@ protected:
virtual uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE;
virtual void generateAdvance(SkGlyph* glyph) SK_OVERRIDE;
virtual void generateMetrics(SkGlyph* glyph) SK_OVERRIDE;
- virtual void generateImage(const SkGlyph& glyph,
- SkMaskGamma::PreBlend* maskPreBlend) SK_OVERRIDE;
+ virtual void generateImage(const SkGlyph& glyph) SK_OVERRIDE;
virtual void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE;
virtual void generateFontMetrics(SkPaint::FontMetrics* mX,
SkPaint::FontMetrics* mY) SK_OVERRIDE;
@@ -975,20 +974,9 @@ static void rgb_to_lcd32(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph,
}
}
-void SkScalerContext_Windows::generateImage(const SkGlyph& glyph,
- SkMaskGamma::PreBlend* maskPreBlend) {
+void SkScalerContext_Windows::generateImage(const SkGlyph& glyph) {
SkAutoMutexAcquire ac(gFTMutex);
- //Must be careful not to use these if maskPreBlend == NULL
- const uint8_t* tableR = NULL;
- const uint8_t* tableG = NULL;
- const uint8_t* tableB = NULL;
- if (maskPreBlend) {
- tableR = maskPreBlend->fR;
- tableG = maskPreBlend->fG;
- tableB = maskPreBlend->fB;
- }
-
const bool isBW = SkMask::kBW_Format == fRec.fMaskFormat;
const bool isAA = !isLCD(fRec);
@@ -1006,23 +994,23 @@ void SkScalerContext_Windows::generateImage(const SkGlyph& glyph,
if (isBW) {
bilevel_to_bw(src, glyph);
} else if (isAA) {
- if (maskPreBlend) {
- rgb_to_a8<true>(src, glyph, tableG);
+ if (fPreBlend.isApplicable()) {
+ rgb_to_a8<true>(src, glyph, fPreBlend.fG);
} else {
- rgb_to_a8<false>(src, glyph, tableG);
+ rgb_to_a8<false>(src, glyph, fPreBlend.fG);
}
} else if (SkMask::kLCD16_Format == glyph.fMaskFormat) {
- if (maskPreBlend) {
- rgb_to_lcd16<true>(src, glyph, tableR, tableG, tableB);
+ if (fPreBlend.isApplicable()) {
+ rgb_to_lcd16<true>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend.fB);
} else {
- rgb_to_lcd16<false>(src, glyph, tableR, tableG, tableB);
+ rgb_to_lcd16<false>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend.fB);
}
} else {
SkASSERT(SkMask::kLCD32_Format == glyph.fMaskFormat);
- if (maskPreBlend) {
- rgb_to_lcd32<true>(src, glyph, tableR, tableG, tableB);
+ if (fPreBlend.isApplicable()) {
+ rgb_to_lcd32<true>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend.fB);
} else {
- rgb_to_lcd32<false>(src, glyph, tableR, tableG, tableB);
+ rgb_to_lcd32<false>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend.fB);
}
}
}