diff options
| author | 2011-09-13 15:57:58 -0700 | |
|---|---|---|
| committer | 2011-09-13 15:57:58 -0700 | |
| commit | 51f383d65f9ee3c7d73d0508b576550e7998c5b5 (patch) | |
| tree | 3ee7a9ea071f14a40bb3d4adaaa4bf1a07b6b3b5 | |
| parent | f0ec2dd3270b60b1516293190757de298f187957 (diff) | |
Fix some TextLayoutCache issues
- wrong ContextCount was passed
- better logs
Change-Id: Ie78ba70f98f3cf017c168ab8848cc080fc175f31
| -rw-r--r-- | core/jni/android/graphics/Paint.cpp | 10 | ||||
| -rw-r--r-- | core/jni/android/graphics/TextLayoutCache.cpp | 26 |
2 files changed, 16 insertions, 20 deletions
diff --git a/core/jni/android/graphics/Paint.cpp b/core/jni/android/graphics/Paint.cpp index 423eff4408e3..7d222f639392 100644 --- a/core/jni/android/graphics/Paint.cpp +++ b/core/jni/android/graphics/Paint.cpp @@ -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 diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp index 7f79277d3fab..d04e05977fb1 100644 --- a/core/jni/android/graphics/TextLayoutCache.cpp +++ b/core/jni/android/graphics/TextLayoutCache.cpp @@ -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(); |