Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(713)

Unified Diff: src/core/SkPaint.cpp

Issue 1718423002: Simplify and combine SkDrawCacheProc and SkMeasureCacheProc to SkPaint::GlyphCacheProc. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkDraw.cpp ('k') | src/core/SkTextToPathIter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPaint.cpp
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index d2ea8eeda09612835691c7093b6f561df05218ed..d3384a628d05dc421758816d893bbbb7800fe403 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
« no previous file with comments | « src/core/SkDraw.cpp ('k') | src/core/SkTextToPathIter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698