Merge "Fix some TextLayoutCache issues"

This commit is contained in:
Fabrice Di Meglio
2011-09-14 11:05:04 -07:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 20 deletions

View File

@@ -366,26 +366,22 @@ public:
NPE_CHECK_RETURN_ZERO(env, jpaint);
NPE_CHECK_RETURN_ZERO(env, text);
size_t textLength = env->GetStringLength(text);
int count = end - start;
if ((start | count) < 0) {
if ((start | count) < 0 || (size_t)end > textLength) {
doThrowAIOOBE(env);
return 0;
}
if (count == 0) {
return 0;
}
size_t textLength = env->GetStringLength(text);
if ((size_t)count > textLength) {
doThrowAIOOBE(env);
return 0;
}
const jchar* textArray = env->GetStringChars(text, NULL);
SkPaint* paint = GraphicsJNI::getNativePaint(env, jpaint);
jfloat width = 0;
#if RTL_USE_HARFBUZZ
TextLayout::getTextRunAdvances(paint, textArray, start, count, end,
TextLayout::getTextRunAdvances(paint, textArray, start, count, textLength,
paint->getFlags(), NULL /* dont need all advances */, width);
#else

View File

@@ -163,20 +163,20 @@ sp<TextLayoutCacheValue> TextLayoutCache::getValue(SkPaint* paint,
// Update timing information for statistics
value->setElapsedTime(endTime - startTime);
LOGD("CACHE MISS: Added entry for text='%s' with start=%d, count=%d, "
LOGD("CACHE MISS: Added entry with start=%d, count=%d, "
"contextCount=%d, entry size %d bytes, remaining space %d bytes"
" - Compute time in nanos: %d",
String8(text, contextCount).string(), start, count, contextCount,
size, mMaxSize - mSize, value->getElapsedTime());
" - Compute time in nanos: %d - Text='%s' ",
start, count, contextCount, size, mMaxSize - mSize, value->getElapsedTime(),
String8(text, contextCount).string());
}
} else {
if (mDebugEnabled) {
LOGD("CACHE MISS: Calculated but not storing entry because it is too big "
"for text='%s' with start=%d, count=%d, contextCount=%d, "
"with start=%d, count=%d, contextCount=%d, "
"entry size %d bytes, remaining space %d bytes"
" - Compute time in nanos: %lld",
String8(text, contextCount).string(), start, count, contextCount,
size, mMaxSize - mSize, endTime);
" - Compute time in nanos: %lld - Text='%s'",
start, count, contextCount, size, mMaxSize - mSize, endTime,
String8(text, contextCount).string());
}
value.clear();
}
@@ -190,12 +190,12 @@ sp<TextLayoutCacheValue> TextLayoutCache::getValue(SkPaint* paint,
if (value->getElapsedTime() > 0) {
float deltaPercent = 100 * ((value->getElapsedTime() - elapsedTimeThruCacheGet)
/ ((float)value->getElapsedTime()));
LOGD("CACHE HIT #%d for text='%s' with start=%d, count=%d, contextCount=%d "
LOGD("CACHE HIT #%d with start=%d, count=%d, contextCount=%d "
"- Compute time in nanos: %d - "
"Cache get time in nanos: %lld - Gain in percent: %2.2f",
mCacheHitCount, String8(text, contextCount).string(), start, count,
contextCount,
value->getElapsedTime(), elapsedTimeThruCacheGet, deltaPercent);
"Cache get time in nanos: %lld - Gain in percent: %2.2f - Text='%s' ",
mCacheHitCount, start, count, contextCount,
value->getElapsedTime(), elapsedTimeThruCacheGet, deltaPercent,
String8(text, contextCount).string());
}
if (mCacheHitCount % DEFAULT_DUMP_STATS_CACHE_HIT_INTERVAL == 0) {
dumpCacheStats();