diff options
author | Romain Guy <romainguy@google.com> | 2012-05-14 13:59:31 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2012-05-14 13:59:47 -0700 |
commit | 7249c95ffc05fb8775e6ecb567c9450680eb1b65 (patch) | |
tree | fbfc1a9381c1a863c99e51cd858cb060f1f6f9ed /src/core | |
parent | 7c6d54cdf8d0da62a7478bda7927d779b0481218 (diff) | |
download | external_skia-7249c95ffc05fb8775e6ecb567c9450680eb1b65.zip external_skia-7249c95ffc05fb8775e6ecb567c9450680eb1b65.tar.gz external_skia-7249c95ffc05fb8775e6ecb567c9450680eb1b65.tar.bz2 |
Add new utfToGlyphs API for GL renderer
Bug #6408362
Change-Id: I69c21d9aeeb663aa6244132ce8d598be888886e2
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkPaint.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index 82a1f57..07fe9b0 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -440,6 +440,37 @@ const void* SkPaint::findImage(const SkGlyph& glyph) { SkGlyphCache::AttachCache(cache); return image; } + +int SkPaint::utfToGlyphs(const void* textData, TextEncoding encoding, + size_t byteLength, uint16_t glyphs[]) const { + + SkAutoGlyphCache autoCache(*this, NULL); + SkGlyphCache* cache = autoCache.getCache(); + + const char* text = (const char*) textData; + const char* stop = text + byteLength; + uint16_t* gptr = glyphs; + + switch (encoding) { + case SkPaint::kUTF8_TextEncoding: + while (text < stop) { + *gptr++ = cache->unicharToGlyph(SkUTF8_NextUnichar(&text)); + } + break; + case SkPaint::kUTF16_TextEncoding: { + const uint16_t* text16 = (const uint16_t*)text; + const uint16_t* stop16 = (const uint16_t*)stop; + while (text16 < stop16) { + *gptr++ = cache->unicharToGlyph(SkUTF16_NextUnichar(&text16)); + } + break; + } + default: + SkDEBUGFAIL("unknown text encoding"); + } + return gptr - glyphs; +} + #endif int SkPaint::textToGlyphs(const void* textData, size_t byteLength, |