Merge "Less aggressive glyphs precaching" into jb-mr2-dev
This commit is contained in:
@@ -1169,6 +1169,7 @@ public:
|
||||
break;
|
||||
}
|
||||
mLocalBounds.set(x, mY + metrics.fTop, x + length, mY + metrics.fBottom);
|
||||
memset(&mPrecacheTransform.data[0], 0xff, 16 * sizeof(float));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1179,9 +1180,11 @@ public:
|
||||
virtual void onDrawOpDeferred(OpenGLRenderer& renderer) {
|
||||
SkPaint* paint = getPaint(renderer);
|
||||
FontRenderer& fontRenderer = renderer.getCaches().fontRenderer->getFontRenderer(paint);
|
||||
const bool pureTranslate = state.mMatrix.isPureTranslate();
|
||||
const mat4 transform = renderer.findBestFontTransform(state.mMatrix);
|
||||
fontRenderer.precache(paint, mText, mCount, transform);
|
||||
const mat4& transform = renderer.findBestFontTransform(state.mMatrix);
|
||||
if (mPrecacheTransform != transform) {
|
||||
fontRenderer.precache(paint, mText, mCount, transform);
|
||||
mPrecacheTransform = transform;
|
||||
}
|
||||
}
|
||||
|
||||
virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
|
||||
@@ -1210,6 +1213,7 @@ private:
|
||||
float mY;
|
||||
const float* mPositions;
|
||||
float mLength;
|
||||
mat4 mPrecacheTransform;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -93,6 +93,14 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend bool operator==(const Matrix4& a, const Matrix4& b) {
|
||||
return !memcmp(&a.data[0], &b.data[0], 16 * sizeof(float));
|
||||
}
|
||||
|
||||
friend bool operator!=(const Matrix4& a, const Matrix4& b) {
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
void loadIdentity();
|
||||
|
||||
void load(const float* v);
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
*/
|
||||
|
||||
#define LOG_TAG "OpenGLRenderer"
|
||||
#define ATRACE_TAG ATRACE_TAG_VIEW
|
||||
|
||||
#include <cutils/compiler.h>
|
||||
|
||||
#include <utils/JenkinsHash.h>
|
||||
#include <utils/Trace.h>
|
||||
|
||||
#include <SkGlyph.h>
|
||||
#include <SkUtils.h>
|
||||
@@ -261,11 +263,8 @@ void Font::drawCachedGlyph(CachedGlyphInfo* glyph, float x, float hOffset, float
|
||||
}
|
||||
|
||||
CachedGlyphInfo* Font::getCachedGlyph(SkPaint* paint, glyph_t textUnit, bool precaching) {
|
||||
CachedGlyphInfo* cachedGlyph = NULL;
|
||||
ssize_t index = mCachedGlyphs.indexOfKey(textUnit);
|
||||
if (index >= 0) {
|
||||
cachedGlyph = mCachedGlyphs.valueAt(index);
|
||||
|
||||
CachedGlyphInfo* cachedGlyph = mCachedGlyphs.valueFor(textUnit);
|
||||
if (cachedGlyph) {
|
||||
// Is the glyph still in texture cache?
|
||||
if (!cachedGlyph->mIsValid) {
|
||||
const SkGlyph& skiaGlyph = GET_METRICS(paint, textUnit,
|
||||
@@ -346,11 +345,13 @@ void Font::measure(SkPaint* paint, const char* text, uint32_t start, uint32_t le
|
||||
}
|
||||
|
||||
void Font::precache(SkPaint* paint, const char* text, int numGlyphs) {
|
||||
ATRACE_NAME("precacheText");
|
||||
|
||||
if (numGlyphs == 0 || text == NULL) {
|
||||
return;
|
||||
}
|
||||
int glyphsCount = 0;
|
||||
|
||||
int glyphsCount = 0;
|
||||
while (glyphsCount < numGlyphs) {
|
||||
glyph_t glyph = GET_GLYPH(text);
|
||||
|
||||
@@ -360,7 +361,6 @@ void Font::precache(SkPaint* paint, const char* text, int numGlyphs) {
|
||||
}
|
||||
|
||||
CachedGlyphInfo* cachedGlyph = getCachedGlyph(paint, glyph, true);
|
||||
|
||||
glyphsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user