we only need one fontmetrics, since the paint (and fontcache) now know explicitly
if they are horizontal or vertical. Review URL: https://codereview.chromium.org/14940018 git-svn-id: http://skia.googlecode.com/svn/trunk@9058 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
60af92cb6d
commit
0a01f5a2c4
@ -62,7 +62,7 @@ SkGlyphCache::SkGlyphCache(SkTypeface* typeface, const SkDescriptor* desc)
|
||||
|
||||
fDesc = desc->copy();
|
||||
fScalerContext = typeface->createScalerContext(desc);
|
||||
fScalerContext->getFontMetrics(NULL, &fFontMetricsY);
|
||||
fScalerContext->getFontMetrics(&fFontMetrics);
|
||||
|
||||
// init to 0 so that all of the pointers will be null
|
||||
memset(fGlyphHash, 0, sizeof(fGlyphHash));
|
||||
|
@ -95,8 +95,8 @@ public:
|
||||
|
||||
/** Return the vertical metrics for this strike.
|
||||
*/
|
||||
const SkPaint::FontMetrics& getFontMetricsY() const {
|
||||
return fFontMetricsY;
|
||||
const SkPaint::FontMetrics& getFontMetrics() const {
|
||||
return fFontMetrics;
|
||||
}
|
||||
|
||||
const SkDescriptor& getDescriptor() const { return *fDesc; }
|
||||
@ -220,7 +220,7 @@ private:
|
||||
SkGlyphCache* fNext, *fPrev;
|
||||
SkDescriptor* fDesc;
|
||||
SkScalerContext* fScalerContext;
|
||||
SkPaint::FontMetrics fFontMetricsY;
|
||||
SkPaint::FontMetrics fFontMetrics;
|
||||
|
||||
enum {
|
||||
kHashBits = 12,
|
||||
|
@ -1203,7 +1203,7 @@ size_t SkPaint::breakText(const void* textD, size_t length, SkScalar maxWidth,
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static bool FontMetricsCacheProc(const SkGlyphCache* cache, void* context) {
|
||||
*(SkPaint::FontMetrics*)context = cache->getFontMetricsY();
|
||||
*(SkPaint::FontMetrics*)context = cache->getFontMetrics();
|
||||
return false; // don't detach the cache
|
||||
}
|
||||
|
||||
@ -1228,11 +1228,6 @@ SkScalar SkPaint::getFontMetrics(FontMetrics* metrics, SkScalar zoom) const {
|
||||
zoomPtr = &zoomMatrix;
|
||||
}
|
||||
|
||||
#if 0
|
||||
SkAutoGlyphCache autoCache(*this, zoomPtr);
|
||||
SkGlyphCache* cache = autoCache.getCache();
|
||||
const FontMetrics& my = cache->getFontMetricsY();
|
||||
#endif
|
||||
FontMetrics storage;
|
||||
if (NULL == metrics) {
|
||||
metrics = &storage;
|
||||
@ -1246,6 +1241,10 @@ SkScalar SkPaint::getFontMetrics(FontMetrics* metrics, SkScalar zoom) const {
|
||||
metrics->fDescent = SkScalarMul(metrics->fDescent, scale);
|
||||
metrics->fBottom = SkScalarMul(metrics->fBottom, scale);
|
||||
metrics->fLeading = SkScalarMul(metrics->fLeading, scale);
|
||||
metrics->fAvgCharWidth = SkScalarMul(metrics->fAvgCharWidth, scale);
|
||||
metrics->fXMin = SkScalarMul(metrics->fXMin, scale);
|
||||
metrics->fXMax = SkScalarMul(metrics->fXMax, scale);
|
||||
metrics->fXHeight = SkScalarMul(metrics->fXHeight, scale);
|
||||
}
|
||||
return metrics->fDescent - metrics->fAscent + metrics->fLeading;
|
||||
}
|
||||
|
@ -663,8 +663,16 @@ void SkScalerContext::getPath(const SkGlyph& glyph, SkPath* path) {
|
||||
this->internalGetPath(glyph, NULL, path, NULL);
|
||||
}
|
||||
|
||||
void SkScalerContext::getFontMetrics(SkPaint::FontMetrics* mx,
|
||||
SkPaint::FontMetrics* my) {
|
||||
void SkScalerContext::getFontMetrics(SkPaint::FontMetrics* fm) {
|
||||
// All of this complexity should go away when we change generateFontMetrics
|
||||
// to just take one parameter (since it knows if it is vertical or not)
|
||||
SkPaint::FontMetrics* mx = NULL;
|
||||
SkPaint::FontMetrics* my = NULL;
|
||||
if (fRec.fFlags & kVertical_Flag) {
|
||||
mx = fm;
|
||||
} else {
|
||||
my = fm;
|
||||
}
|
||||
this->generateFontMetrics(mx, my);
|
||||
}
|
||||
|
||||
|
@ -180,8 +180,7 @@ public:
|
||||
void getMetrics(SkGlyph*);
|
||||
void getImage(const SkGlyph&);
|
||||
void getPath(const SkGlyph&, SkPath*);
|
||||
void getFontMetrics(SkPaint::FontMetrics* mX,
|
||||
SkPaint::FontMetrics* mY);
|
||||
void getFontMetrics(SkPaint::FontMetrics*);
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
unsigned getBaseGlyphCount(SkUnichar charCode);
|
||||
|
Loading…
Reference in New Issue
Block a user