Merge "Properly pre-cache latin glyphs Bug #6408362" into jb-dev
This commit is contained in:
@@ -776,12 +776,6 @@ void FontRenderer::checkInit() {
|
|||||||
initTextTexture();
|
initTextTexture();
|
||||||
initVertexArrayBuffers();
|
initVertexArrayBuffers();
|
||||||
|
|
||||||
// We store a string with letters in a rough frequency of occurrence
|
|
||||||
mLatinPrecache = String16("eisarntolcdugpmhbyfvkwzxjq ");
|
|
||||||
mLatinPrecache += String16("EISARNTOLCDUGPMHBYFVKWZXJQ");
|
|
||||||
mLatinPrecache += String16(",.?!()-+@;:'");
|
|
||||||
mLatinPrecache += String16("0123456789");
|
|
||||||
|
|
||||||
mInitialized = true;
|
mInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -944,11 +938,19 @@ uint32_t FontRenderer::getRemainingCacheCapacity() {
|
|||||||
void FontRenderer::precacheLatin(SkPaint* paint) {
|
void FontRenderer::precacheLatin(SkPaint* paint) {
|
||||||
// Remaining capacity is measured in %
|
// Remaining capacity is measured in %
|
||||||
uint32_t remainingCapacity = getRemainingCacheCapacity();
|
uint32_t remainingCapacity = getRemainingCacheCapacity();
|
||||||
uint32_t precacheIdx = 0;
|
uint32_t precacheIndex = 0;
|
||||||
while (remainingCapacity > 25 && precacheIdx < mLatinPrecache.size()) {
|
|
||||||
mCurrentFont->getCachedGlyph(paint, (int32_t) mLatinPrecache[precacheIdx]);
|
// We store a string with letters in a rough frequency of occurrence
|
||||||
|
String16 l("eisarntolcdugpmhbyfvkwzxjq EISARNTOLCDUGPMHBYFVKWZXJQ,.?!()-+@;:'0123456789");
|
||||||
|
|
||||||
|
size_t size = l.size();
|
||||||
|
uint16_t latin[size];
|
||||||
|
paint->utfToGlyphs(l.string(), SkPaint::kUTF16_TextEncoding, size * sizeof(char16_t), latin);
|
||||||
|
|
||||||
|
while (remainingCapacity > 25 && precacheIndex < size) {
|
||||||
|
mCurrentFont->getCachedGlyph(paint, TO_GLYPH(latin[precacheIndex]));
|
||||||
remainingCapacity = getRemainingCacheCapacity();
|
remainingCapacity = getRemainingCacheCapacity();
|
||||||
precacheIdx ++;
|
precacheIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,11 +41,13 @@ namespace uirenderer {
|
|||||||
|
|
||||||
#if RENDER_TEXT_AS_GLYPHS
|
#if RENDER_TEXT_AS_GLYPHS
|
||||||
typedef uint16_t glyph_t;
|
typedef uint16_t glyph_t;
|
||||||
|
#define TO_GLYPH(g) g
|
||||||
#define GET_METRICS(paint, glyph) paint->getGlyphMetrics(glyph)
|
#define GET_METRICS(paint, glyph) paint->getGlyphMetrics(glyph)
|
||||||
#define GET_GLYPH(text) nextGlyph((const uint16_t**) &text)
|
#define GET_GLYPH(text) nextGlyph((const uint16_t**) &text)
|
||||||
#define IS_END_OF_STRING(glyph) false
|
#define IS_END_OF_STRING(glyph) false
|
||||||
#else
|
#else
|
||||||
typedef SkUnichar glyph_t;
|
typedef SkUnichar glyph_t;
|
||||||
|
#define TO_GLYPH(g) ((SkUnichar) g)
|
||||||
#define GET_METRICS(paint, glyph) paint->getUnicharMetrics(glyph)
|
#define GET_METRICS(paint, glyph) paint->getUnicharMetrics(glyph)
|
||||||
#define GET_GLYPH(text) SkUTF16_NextUnichar((const uint16_t**) &text)
|
#define GET_GLYPH(text) SkUTF16_NextUnichar((const uint16_t**) &text)
|
||||||
#define IS_END_OF_STRING(glyph) glyph < 0
|
#define IS_END_OF_STRING(glyph) glyph < 0
|
||||||
@@ -98,7 +100,7 @@ public:
|
|||||||
uint32_t mCurrentRow;
|
uint32_t mCurrentRow;
|
||||||
uint32_t mCurrentCol;
|
uint32_t mCurrentCol;
|
||||||
bool mDirty;
|
bool mDirty;
|
||||||
CacheTexture *mCacheTexture;
|
CacheTexture* mCacheTexture;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CachedGlyphInfo {
|
struct CachedGlyphInfo {
|
||||||
@@ -236,8 +238,6 @@ public:
|
|||||||
FontRenderer();
|
FontRenderer();
|
||||||
~FontRenderer();
|
~FontRenderer();
|
||||||
|
|
||||||
void init();
|
|
||||||
void deinit();
|
|
||||||
void flushLargeCaches();
|
void flushLargeCaches();
|
||||||
|
|
||||||
void setGammaTable(const uint8_t* gammaTable) {
|
void setGammaTable(const uint8_t* gammaTable) {
|
||||||
@@ -278,6 +278,7 @@ public:
|
|||||||
|
|
||||||
GLuint getTexture(bool linearFiltering = false) {
|
GLuint getTexture(bool linearFiltering = false) {
|
||||||
checkInit();
|
checkInit();
|
||||||
|
|
||||||
if (linearFiltering != mCurrentCacheTexture->mLinearFiltering) {
|
if (linearFiltering != mCurrentCacheTexture->mLinearFiltering) {
|
||||||
mCurrentCacheTexture->mLinearFiltering = linearFiltering;
|
mCurrentCacheTexture->mLinearFiltering = linearFiltering;
|
||||||
mLinearFiltering = linearFiltering;
|
mLinearFiltering = linearFiltering;
|
||||||
@@ -287,6 +288,7 @@ public:
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mCurrentCacheTexture->mTextureId;
|
return mCurrentCacheTexture->mTextureId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,7 +328,6 @@ protected:
|
|||||||
void initRender(const Rect* clip, Rect* bounds);
|
void initRender(const Rect* clip, Rect* bounds);
|
||||||
void finishRender();
|
void finishRender();
|
||||||
|
|
||||||
String16 mLatinPrecache;
|
|
||||||
void precacheLatin(SkPaint* paint);
|
void precacheLatin(SkPaint* paint);
|
||||||
|
|
||||||
void issueDrawCommand();
|
void issueDrawCommand();
|
||||||
|
|||||||
Reference in New Issue
Block a user