diff options
-rw-r--r-- | include/core/SkPaint.h | 4 | ||||
-rw-r--r-- | src/core/SkPaint.cpp | 28 |
2 files changed, 16 insertions, 16 deletions
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h index a564824448..8cc8733c27 100644 --- a/include/core/SkPaint.h +++ b/include/core/SkPaint.h @@ -1306,9 +1306,7 @@ public: @param byteLength length of character storage in bytes @return number of glyphs represented by text of length byteLength */ - int countText(const void* text, size_t byteLength) const { - return this->textToGlyphs(text, byteLength, nullptr); - } + int countText(const void* text, size_t byteLength) const; /** Returns the advance width of text if kVerticalText_Flag is clear, and the height of text if kVerticalText_Flag is set. diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index ab3e2da9b5..3ace475714 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -393,27 +393,29 @@ SkScalar SkPaint::MaxCacheSize2(SkScalar maxLimit) { #include "SkGlyphCache.h" #include "SkUtils.h" -int SkPaint::textToGlyphs(const void* textData, size_t byteLength, uint16_t glyphs[]) const { - if (byteLength == 0) { - return 0; - } - - SkASSERT(textData != nullptr); - - if (nullptr == glyphs) { - switch (this->getTextEncoding()) { +int SkPaint::countText(const void* text, size_t byteLength) const { + SkASSERT(text != nullptr); + switch (this->getTextEncoding()) { case kUTF8_TextEncoding: - return SkUTF8_CountUnichars(textData, byteLength); + return SkUTF8_CountUnichars(text, byteLength); case kUTF16_TextEncoding: - return SkUTF16_CountUnichars(textData, byteLength); + return SkUTF16_CountUnichars(text, byteLength); case kUTF32_TextEncoding: return SkToInt(byteLength >> 2); case kGlyphID_TextEncoding: return SkToInt(byteLength >> 1); default: SkDEBUGFAIL("unknown text encoding"); - } - return 0; + } + + return 0; +} + +int SkPaint::textToGlyphs(const void* textData, size_t byteLength, uint16_t glyphs[]) const { + SkASSERT(textData != nullptr); + + if (nullptr == glyphs) { + return this->countText(textData, byteLength); } // if we get here, we have a valid glyphs[] array, so time to fill it in |