Commit 7249c95f authored by Romain Guy's avatar Romain Guy
Browse files

Add new utfToGlyphs API for GL renderer

Bug #6408362

Change-Id: I69c21d9aeeb663aa6244132ce8d598be888886e2
parent 7c6d54cd
......@@ -870,6 +870,9 @@ public:
/** Returns the base glyph count for the strike associated with this paint
*/
unsigned getBaseGlyphCount(SkUnichar text) const;
int utfToGlyphs(const void* text, TextEncoding encoding,
size_t byteLength, uint16_t glyphs[]) const;
#endif
// returns true if the paint's settings (e.g. xfermode + alpha) resolve to
......
......@@ -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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment