Reason for revert: False alert on zheng.xu's original CL - it didn't break anything.

R=bungeman@google.com, reed@google.com, zheng.xu@arm.com, robertphillips@google.com, rmistry@google.com
TBR=bungeman@google.com, reed@google.com, rmistry@google.com, robertphillips@google.com, zheng.xu@arm.com
NOTREECHECKS=true
NOTRY=true
BUG=

Author: bensong@google.com

Review URL: https://codereview.chromium.org/117963003

git-svn-id: http://skia.googlecode.com/svn/trunk@12822 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2013-12-26 15:50:29 +00:00
parent f4552d6b66
commit 6fa81d7878
3 changed files with 27 additions and 32 deletions

View File

@ -1,4 +1,4 @@

/*
* Copyright 2006 The Android Open Source Project
*
@ -216,6 +216,9 @@ private:
bool getCBoxForLetter(char letter, FT_BBox* bbox);
// Caller must lock gFTMutex before calling this function.
void updateGlyphIfLCD(SkGlyph* glyph);
// Caller must lock gFTMutex before calling this function.
// update FreeType2 glyph slot with glyph emboldened
void emboldenIfNeeded(FT_Face face, FT_GlyphSlot glyph);
};
///////////////////////////////////////////////////////////////////////////
@ -1139,10 +1142,7 @@ bool SkScalerContext_FreeType::getCBoxForLetter(char letter, FT_BBox* bbox) {
return false;
if (FT_Load_Glyph(fFace, glyph_id, fLoadGlyphFlags) != 0)
return false;
if ((fRec.fFlags & kEmbolden_Flag) &&
!(fFace->style_flags & FT_STYLE_FLAG_BOLD)) {
emboldenOutline(fFace, &fFace->glyph->outline);
}
emboldenIfNeeded(fFace, fFace->glyph);
FT_Outline_Get_CBox(&fFace->glyph->outline, bbox);
return true;
}
@ -1192,6 +1192,7 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) {
glyph->zeroMetrics();
return;
}
emboldenIfNeeded(fFace, fFace->glyph);
switch ( fFace->glyph->format ) {
case FT_GLYPH_FORMAT_OUTLINE:
@ -1201,10 +1202,6 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) {
glyph->fTop = 0;
glyph->fLeft = 0;
} else {
if (fRec.fFlags & kEmbolden_Flag && !(fFace->style_flags & FT_STYLE_FLAG_BOLD)) {
emboldenOutline(fFace, &fFace->glyph->outline);
}
FT_BBox bbox;
getBBoxForCurrentGlyph(glyph, &bbox, true);
@ -1218,11 +1215,6 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) {
break;
case FT_GLYPH_FORMAT_BITMAP:
if (fRec.fFlags & kEmbolden_Flag) {
FT_GlyphSlot_Own_Bitmap(fFace->glyph);
FT_Bitmap_Embolden(gFTLibrary, &fFace->glyph->bitmap, kBitmapEmboldenStrength, 0);
}
if (fRec.fFlags & SkScalerContext::kVertical_Flag) {
FT_Vector vector;
vector.x = fFace->glyph->metrics.vertBearingX - fFace->glyph->metrics.horiBearingX;
@ -1301,6 +1293,7 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) {
return;
}
emboldenIfNeeded(fFace, fFace->glyph);
generateGlyphImage(fFace, glyph);
}
@ -1328,6 +1321,7 @@ void SkScalerContext_FreeType::generatePath(const SkGlyph& glyph,
path->reset();
return;
}
emboldenIfNeeded(fFace, fFace->glyph);
generateGlyphPath(fFace, path);
@ -1469,6 +1463,25 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx,
}
}
void SkScalerContext_FreeType::emboldenIfNeeded(FT_Face face, FT_GlyphSlot glyph)
{
if (fRec.fFlags & SkScalerContext::kEmbolden_Flag) {
switch ( glyph->format ) {
case FT_GLYPH_FORMAT_OUTLINE:
FT_Pos strength;
strength = FT_MulFix(face->units_per_EM, face->size->metrics.y_scale) / 24;
FT_Outline_Embolden(&glyph->outline, strength);
break;
case FT_GLYPH_FORMAT_BITMAP:
FT_GlyphSlot_Own_Bitmap(glyph);
FT_Bitmap_Embolden(glyph->library, &glyph->bitmap, kBitmapEmboldenStrength, 0);
break;
default:
SkDEBUGFAIL("unknown glyph format");
}
}
}
///////////////////////////////////////////////////////////////////////////////
#include "SkUtils.h"

View File

@ -344,11 +344,6 @@ void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face, const SkGly
FT_BBox bbox;
FT_Bitmap target;
if (fRec.fFlags & SkScalerContext::kEmbolden_Flag &&
!(face->style_flags & FT_STYLE_FLAG_BOLD)) {
emboldenOutline(face, outline);
}
int dx = 0, dy = 0;
if (fRec.fFlags & SkScalerContext::kSubpixelPositioning_Flag) {
dx = SkFixedToFDot6(glyph.getSubXFixed());
@ -547,10 +542,6 @@ static int cubic_proc(const FT_Vector* pt0, const FT_Vector* pt1,
void SkScalerContext_FreeType_Base::generateGlyphPath(FT_Face face,
SkPath* path)
{
if (fRec.fFlags & SkScalerContext::kEmbolden_Flag) {
emboldenOutline(face, &face->glyph->outline);
}
FT_Outline_Funcs funcs;
funcs.move_to = move_proc;
@ -569,11 +560,3 @@ void SkScalerContext_FreeType_Base::generateGlyphPath(FT_Face face,
path->close();
}
void SkScalerContext_FreeType_Base::emboldenOutline(FT_Face face, FT_Outline* outline)
{
FT_Pos strength;
strength = FT_MulFix(face->units_per_EM, face->size->metrics.y_scale)
/ 24;
FT_Outline_Embolden(outline, strength);
}

View File

@ -39,7 +39,6 @@ protected:
void generateGlyphImage(FT_Face face, const SkGlyph& glyph);
void generateGlyphPath(FT_Face face, SkPath* path);
void emboldenOutline(FT_Face face, FT_Outline* outline);
private:
typedef SkScalerContext INHERITED;