зеркало из https://github.com/mozilla/moz-skia.git
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:
Родитель
60af92cb6d
Коммит
0a01f5a2c4
|
@ -62,7 +62,7 @@ SkGlyphCache::SkGlyphCache(SkTypeface* typeface, const SkDescriptor* desc)
|
||||||
|
|
||||||
fDesc = desc->copy();
|
fDesc = desc->copy();
|
||||||
fScalerContext = typeface->createScalerContext(desc);
|
fScalerContext = typeface->createScalerContext(desc);
|
||||||
fScalerContext->getFontMetrics(NULL, &fFontMetricsY);
|
fScalerContext->getFontMetrics(&fFontMetrics);
|
||||||
|
|
||||||
// init to 0 so that all of the pointers will be null
|
// init to 0 so that all of the pointers will be null
|
||||||
memset(fGlyphHash, 0, sizeof(fGlyphHash));
|
memset(fGlyphHash, 0, sizeof(fGlyphHash));
|
||||||
|
|
|
@ -95,8 +95,8 @@ public:
|
||||||
|
|
||||||
/** Return the vertical metrics for this strike.
|
/** Return the vertical metrics for this strike.
|
||||||
*/
|
*/
|
||||||
const SkPaint::FontMetrics& getFontMetricsY() const {
|
const SkPaint::FontMetrics& getFontMetrics() const {
|
||||||
return fFontMetricsY;
|
return fFontMetrics;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SkDescriptor& getDescriptor() const { return *fDesc; }
|
const SkDescriptor& getDescriptor() const { return *fDesc; }
|
||||||
|
@ -220,7 +220,7 @@ private:
|
||||||
SkGlyphCache* fNext, *fPrev;
|
SkGlyphCache* fNext, *fPrev;
|
||||||
SkDescriptor* fDesc;
|
SkDescriptor* fDesc;
|
||||||
SkScalerContext* fScalerContext;
|
SkScalerContext* fScalerContext;
|
||||||
SkPaint::FontMetrics fFontMetricsY;
|
SkPaint::FontMetrics fFontMetrics;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
kHashBits = 12,
|
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) {
|
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
|
return false; // don't detach the cache
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1228,11 +1228,6 @@ SkScalar SkPaint::getFontMetrics(FontMetrics* metrics, SkScalar zoom) const {
|
||||||
zoomPtr = &zoomMatrix;
|
zoomPtr = &zoomMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
SkAutoGlyphCache autoCache(*this, zoomPtr);
|
|
||||||
SkGlyphCache* cache = autoCache.getCache();
|
|
||||||
const FontMetrics& my = cache->getFontMetricsY();
|
|
||||||
#endif
|
|
||||||
FontMetrics storage;
|
FontMetrics storage;
|
||||||
if (NULL == metrics) {
|
if (NULL == metrics) {
|
||||||
metrics = &storage;
|
metrics = &storage;
|
||||||
|
@ -1246,6 +1241,10 @@ SkScalar SkPaint::getFontMetrics(FontMetrics* metrics, SkScalar zoom) const {
|
||||||
metrics->fDescent = SkScalarMul(metrics->fDescent, scale);
|
metrics->fDescent = SkScalarMul(metrics->fDescent, scale);
|
||||||
metrics->fBottom = SkScalarMul(metrics->fBottom, scale);
|
metrics->fBottom = SkScalarMul(metrics->fBottom, scale);
|
||||||
metrics->fLeading = SkScalarMul(metrics->fLeading, 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;
|
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);
|
this->internalGetPath(glyph, NULL, path, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkScalerContext::getFontMetrics(SkPaint::FontMetrics* mx,
|
void SkScalerContext::getFontMetrics(SkPaint::FontMetrics* fm) {
|
||||||
SkPaint::FontMetrics* my) {
|
// 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);
|
this->generateFontMetrics(mx, my);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,8 +180,7 @@ public:
|
||||||
void getMetrics(SkGlyph*);
|
void getMetrics(SkGlyph*);
|
||||||
void getImage(const SkGlyph&);
|
void getImage(const SkGlyph&);
|
||||||
void getPath(const SkGlyph&, SkPath*);
|
void getPath(const SkGlyph&, SkPath*);
|
||||||
void getFontMetrics(SkPaint::FontMetrics* mX,
|
void getFontMetrics(SkPaint::FontMetrics*);
|
||||||
SkPaint::FontMetrics* mY);
|
|
||||||
|
|
||||||
#ifdef SK_BUILD_FOR_ANDROID
|
#ifdef SK_BUILD_FOR_ANDROID
|
||||||
unsigned getBaseGlyphCount(SkUnichar charCode);
|
unsigned getBaseGlyphCount(SkUnichar charCode);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче