aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkDraw.cpp6
-rw-r--r--src/core/SkPaint.cpp120
-rw-r--r--src/core/SkTextToPathIter.h2
3 files changed, 12 insertions, 116 deletions
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 0c17c94884..4db759474f 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -1606,8 +1606,8 @@ void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength,
paint.setStyle(SkPaint::kFill_Style);
paint.setPathEffect(nullptr);
- SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc();
- SkAutoGlyphCache cache(paint, &fDevice->surfaceProps(), this->fakeGamma(), nullptr);
+ SkPaint::GlyphCacheProc glyphCacheProc = paint.getGlyphCacheProc(true);
+ SkAutoGlyphCache cache(paint, &fDevice->surfaceProps(), this->fakeGamma(), nullptr);
const char* stop = text + byteLength;
SkTextAlignProc alignProc(paint.getTextAlign());
@@ -1618,7 +1618,7 @@ void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength,
paint.setPathEffect(origPaint.getPathEffect());
while (text < stop) {
- const SkGlyph& glyph = glyphCacheProc(cache.get(), &text, 0, 0);
+ const SkGlyph& glyph = glyphCacheProc(cache.get(), &text);
if (glyph.fWidth) {
const SkPath* path = cache->findPath(glyph);
if (path) {
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
diff --git a/src/core/SkTextToPathIter.h b/src/core/SkTextToPathIter.h
index e299552327..435c1c79f0 100644
--- a/src/core/SkTextToPathIter.h
+++ b/src/core/SkTextToPathIter.h
@@ -25,7 +25,7 @@ protected:
SkFixed fPrevAdvance;
const char* fText;
const char* fStop;
- SkMeasureCacheProc fGlyphCacheProc;
+ SkPaint::GlyphCacheProc fGlyphCacheProc;
SkScalar fXPos; // accumulated xpos, returned in next
SkAutoKern fAutoKern;