aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPaint.cpp
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2018-05-02 13:43:49 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-02 20:50:28 +0000
commit90864a21c4ab6c7da3c6d671cf85a97373578243 (patch)
tree4a05c1c0413f14a938c26ed5db21823698f1bd18 /src/core/SkPaint.cpp
parent908ad22437a5926e7f417dfeb4446722c8dd57dc (diff)
Simplify textToGlyphs
Change-Id: I9f2ae8e669ab3c22b66f9b10bd2650b5f5ab0bd4 Reviewed-on: https://skia-review.googlesource.com/125345 Reviewed-by: Herb Derby <herb@google.com> Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Herb Derby <herb@google.com> Auto-Submit: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core/SkPaint.cpp')
-rw-r--r--src/core/SkPaint.cpp28
1 files changed, 15 insertions, 13 deletions
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