aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPaint.cpp
diff options
context:
space:
mode:
authorGravatar benjaminwagner <benjaminwagner@google.com>2016-02-23 10:44:31 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-23 10:44:32 -0800
commitd936f63c35fb7dfb2b6c20802206adbfc3cc48d0 (patch)
treeb4c2eb1ce6e6db5ec9f2cde82f98988fd8781f1d /src/core/SkPaint.cpp
parent246ba3a8b488eb1cecb98fa0cd657b62c9801a51 (diff)
Simplify and combine SkDrawCacheProc and SkMeasureCacheProc to SkPaint::GlyphCacheProc.
All callers of (the result of) SkPaint::getDrawCacheProc were passing zero as the last two arguments. This is the same as (the result of) SkPaint::getMeasureCacheProc(true). Per bungeman, make this typedef a member of SkPaint. Although the typedef is technically public, the only uses are private, so this is not really an API change. TBR=reed GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1718423002 Review URL: https://codereview.chromium.org/1718423002
Diffstat (limited to 'src/core/SkPaint.cpp')
-rw-r--r--src/core/SkPaint.cpp120
1 files changed, 8 insertions, 112 deletions
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index d2ea8eeda0..d3384a628d 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -682,8 +682,8 @@ static const SkGlyph& sk_getAdvance_glyph_next(SkGlyphCache* cache,
return cache->getGlyphIDAdvance(glyphID);
}
-SkMeasureCacheProc SkPaint::getMeasureCacheProc(bool needFullMetrics) const {
- static const SkMeasureCacheProc gMeasureCacheProcs[] = {
+SkPaint::GlyphCacheProc SkPaint::getGlyphCacheProc(bool needFullMetrics) const {
+ static const GlyphCacheProc gGlyphCacheProcs[] = {
sk_getMetrics_utf8_next,
sk_getMetrics_utf16_next,
sk_getMetrics_utf32_next,
@@ -701,111 +701,8 @@ SkMeasureCacheProc SkPaint::getMeasureCacheProc(bool needFullMetrics) const {
index += 4;
}
- SkASSERT(index < SK_ARRAY_COUNT(gMeasureCacheProcs));
- return gMeasureCacheProcs[index];
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-static const SkGlyph& sk_getMetrics_utf8_00(SkGlyphCache* cache,
- const char** text, SkFixed, SkFixed) {
- SkASSERT(cache != nullptr);
- SkASSERT(text != nullptr);
-
- return cache->getUnicharMetrics(SkUTF8_NextUnichar(text));
-}
-
-static const SkGlyph& sk_getMetrics_utf8_xy(SkGlyphCache* cache,
- const char** text, SkFixed x, SkFixed y) {
- SkASSERT(cache != nullptr);
- SkASSERT(text != nullptr);
-
- return cache->getUnicharMetrics(SkUTF8_NextUnichar(text), x, y);
-}
-
-static const SkGlyph& sk_getMetrics_utf16_00(SkGlyphCache* cache,
- const char** text, SkFixed, SkFixed) {
- SkASSERT(cache != nullptr);
- SkASSERT(text != nullptr);
-
- return cache->getUnicharMetrics(SkUTF16_NextUnichar((const uint16_t**)text));
-}
-
-static const SkGlyph& sk_getMetrics_utf16_xy(SkGlyphCache* cache,
- const char** text, SkFixed x, SkFixed y) {
- SkASSERT(cache != nullptr);
- SkASSERT(text != nullptr);
-
- return cache->getUnicharMetrics(SkUTF16_NextUnichar((const uint16_t**)text),
- x, y);
-}
-
-static const SkGlyph& sk_getMetrics_utf32_00(SkGlyphCache* cache,
- const char** text, SkFixed, SkFixed) {
- SkASSERT(cache != nullptr);
- SkASSERT(text != nullptr);
-
- const int32_t* ptr = *(const int32_t**)text;
- SkUnichar uni = *ptr++;
- *text = (const char*)ptr;
- return cache->getUnicharMetrics(uni);
-}
-
-static const SkGlyph& sk_getMetrics_utf32_xy(SkGlyphCache* cache,
- const char** text, SkFixed x, SkFixed y) {
- SkASSERT(cache != nullptr);
- SkASSERT(text != nullptr);
-
- const int32_t* ptr = *(const int32_t**)text;
- SkUnichar uni = *ptr++;
- *text = (const char*)ptr;
- return cache->getUnicharMetrics(uni, x, y);
-}
-
-static const SkGlyph& sk_getMetrics_glyph_00(SkGlyphCache* cache,
- const char** text, SkFixed, SkFixed) {
- SkASSERT(cache != nullptr);
- SkASSERT(text != nullptr);
-
- const uint16_t* ptr = *(const uint16_t**)text;
- unsigned glyphID = *ptr;
- ptr += 1;
- *text = (const char*)ptr;
- return cache->getGlyphIDMetrics(glyphID);
-}
-
-static const SkGlyph& sk_getMetrics_glyph_xy(SkGlyphCache* cache,
- const char** text, SkFixed x, SkFixed y) {
- SkASSERT(cache != nullptr);
- SkASSERT(text != nullptr);
-
- const uint16_t* ptr = *(const uint16_t**)text;
- unsigned glyphID = *ptr;
- ptr += 1;
- *text = (const char*)ptr;
- return cache->getGlyphIDMetrics(glyphID, x, y);
-}
-
-SkDrawCacheProc SkPaint::getDrawCacheProc() const {
- static const SkDrawCacheProc gDrawCacheProcs[] = {
- sk_getMetrics_utf8_00,
- sk_getMetrics_utf16_00,
- sk_getMetrics_utf32_00,
- sk_getMetrics_glyph_00,
-
- sk_getMetrics_utf8_xy,
- sk_getMetrics_utf16_xy,
- sk_getMetrics_utf32_xy,
- sk_getMetrics_glyph_xy
- };
-
- unsigned index = this->getTextEncoding();
- if (fBitfields.fFlags & kSubpixelText_Flag) {
- index += 4;
- }
-
- SkASSERT(index < SK_ARRAY_COUNT(gDrawCacheProcs));
- return gDrawCacheProcs[index];
+ SkASSERT(index < SK_ARRAY_COUNT(gGlyphCacheProcs));
+ return gGlyphCacheProcs[index];
}
///////////////////////////////////////////////////////////////////////////////
@@ -900,7 +797,7 @@ SkScalar SkPaint::measure_text(SkGlyphCache* cache,
return 0;
}
- SkMeasureCacheProc glyphCacheProc = this->getMeasureCacheProc(nullptr != bounds);
+ GlyphCacheProc glyphCacheProc = this->getGlyphCacheProc(nullptr != bounds);
int xyIndex;
JoinBoundsProc joinBoundsProc;
@@ -1025,7 +922,7 @@ size_t SkPaint::breakText(const void* textD, size_t length, SkScalar maxWidth,
SkAutoGlyphCache autoCache(paint, nullptr, nullptr);
SkGlyphCache* cache = autoCache.getCache();
- SkMeasureCacheProc glyphCacheProc = paint.getMeasureCacheProc(false);
+ GlyphCacheProc glyphCacheProc = paint.getGlyphCacheProc(false);
const int xyIndex = paint.isVerticalText() ? 1 : 0;
// use 64bits for our accumulator, to avoid overflowing 16.16
Sk48Dot16 max = SkScalarToFixed(maxWidth);
@@ -1143,8 +1040,7 @@ int SkPaint::getTextWidths(const void* textData, size_t byteLength,
SkAutoGlyphCache autoCache(paint, nullptr, nullptr);
SkGlyphCache* cache = autoCache.getCache();
- SkMeasureCacheProc glyphCacheProc;
- glyphCacheProc = paint.getMeasureCacheProc(nullptr != bounds);
+ GlyphCacheProc glyphCacheProc = paint.getGlyphCacheProc(nullptr != bounds);
const char* text = (const char*)textData;
const char* stop = text + byteLength;
@@ -2397,7 +2293,7 @@ SkTextBaseIter::SkTextBaseIter(const char text[], size_t length,
const SkPaint& paint,
bool applyStrokeAndPathEffects)
: fPaint(paint) {
- fGlyphCacheProc = paint.getMeasureCacheProc(true);
+ fGlyphCacheProc = paint.getGlyphCacheProc(true);
fPaint.setLinearText(true);
fPaint.setMaskFilter(nullptr); // don't want this affecting our path-cache lookup