aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-08 14:19:08 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-08 14:19:08 +0000
commit0a01f5a2c44f3d6a7fa2d3c837f46894d9b29e5d (patch)
tree798f1a35f3e901da800762710f1d5c37bde03636
parent60af92cb6de814b14ee5d40b71bfbd79227597ec (diff)
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
-rw-r--r--src/core/SkGlyphCache.cpp2
-rw-r--r--src/core/SkGlyphCache.h6
-rw-r--r--src/core/SkPaint.cpp11
-rw-r--r--src/core/SkScalerContext.cpp12
-rw-r--r--src/core/SkScalerContext.h3
5 files changed, 20 insertions, 14 deletions
diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp
index d33a13f4bc..a1f738e81b 100644
--- a/src/core/SkGlyphCache.cpp
+++ b/src/core/SkGlyphCache.cpp
@@ -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));
diff --git a/src/core/SkGlyphCache.h b/src/core/SkGlyphCache.h
index 39a1c389c2..bbf3eb3f29 100644
--- a/src/core/SkGlyphCache.h
+++ b/src/core/SkGlyphCache.h
@@ -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,
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index aa1b8e4803..6c16428d81 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -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;
}
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index 93abf6b3c2..ba14908c2e 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -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);
}
diff --git a/src/core/SkScalerContext.h b/src/core/SkScalerContext.h
index dceabc18d9..d17b423496 100644
--- a/src/core/SkScalerContext.h
+++ b/src/core/SkScalerContext.h
@@ -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);