summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Fabrice Di Meglio <fdimeglio@google.com> 2012-01-23 15:46:58 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2012-01-23 15:46:58 -0800
commit22cfd047abb09929331ce2727499a24bcbb3604b (patch)
tree7944f5b499a5754647d29f2adfe71cb94bf196fa
parentd215ddf3d95b0d009ea7fc50c0d36647ebaa1c14 (diff)
parentbd901dee317d10c6a921922c3d7d788b90306c82 (diff)
Merge "Fix bug #5846413 "phone" keyboard layout is broken on master"
-rw-r--r--core/jni/android/graphics/Canvas.cpp3
-rw-r--r--core/jni/android/graphics/Paint.cpp36
-rw-r--r--core/jni/android/graphics/TextLayoutCache.cpp10
-rw-r--r--core/jni/android/graphics/TextLayoutCache.h10
4 files changed, 41 insertions, 18 deletions
diff --git a/core/jni/android/graphics/Canvas.cpp b/core/jni/android/graphics/Canvas.cpp
index 3e9ab86486b8..c8b725a7337a 100644
--- a/core/jni/android/graphics/Canvas.cpp
+++ b/core/jni/android/graphics/Canvas.cpp
@@ -776,9 +776,6 @@ public:
static void doDrawGlyphs(SkCanvas* canvas, const jchar* glyphArray, int index, int count,
jfloat x, jfloat y, int flags, SkPaint* paint) {
- // TODO: need to suppress this code after the GL renderer is modified for not
- // copying the paint
-
// Beware: this needs Glyph encoding (already done on the Paint constructor)
canvas->drawText(glyphArray + index * 2, count * 2, x, y, *paint);
}
diff --git a/core/jni/android/graphics/Paint.cpp b/core/jni/android/graphics/Paint.cpp
index 9f3238abc9b5..9bcfa5f7ad2c 100644
--- a/core/jni/android/graphics/Paint.cpp
+++ b/core/jni/android/graphics/Paint.cpp
@@ -466,7 +466,8 @@ public:
jchar* glyphsArray = env->GetCharArrayElements(glyphs, NULL);
TextLayoutCacheValue value(contextCount);
- TextLayoutEngine::getInstance().computeValues(&value, paint, text, start, count, contextCount, flags);
+ TextLayoutEngine::getInstance().computeValues(&value, paint, text, start, count,
+ contextCount, flags);
const jchar* shapedGlyphs = value.getGlyphs();
size_t glyphsCount = value.getGlyphsCount();
memcpy(glyphsArray, shapedGlyphs, sizeof(jchar) * glyphsCount);
@@ -673,13 +674,25 @@ public:
}
}
- static int breakText(JNIEnv* env, const SkPaint& paint, const jchar text[],
+ static int breakText(JNIEnv* env, SkPaint& paint, const jchar text[],
int count, float maxWidth, jfloatArray jmeasured,
SkPaint::TextBufferDirection tbd) {
- SkASSERT(paint.getTextEncoding() == SkPaint::kUTF16_TextEncoding);
+ sp<TextLayoutCacheValue> value;
+#if USE_TEXT_LAYOUT_CACHE
+ value = TextLayoutCache::getInstance().getValue(&paint, text, 0, count,
+ count, paint.getFlags());
+ if (value == NULL) {
+ ALOGE("Cannot get TextLayoutCache value for text = '%s'",
+ String8(text, count).string());
+ }
+#else
+ value = new TextLayoutCacheValue(count);
+ TextLayoutEngine::getInstance().computeValues(value.get(), &paint,
+ reinterpret_cast<const UChar*>(text), 0, count, count, paint.getFlags());
+#endif
SkScalar measured;
- size_t bytes = paint.breakText(text, count << 1,
+ size_t bytes = paint.breakText(value->getGlyphs(), value->getGlyphsCount() << 1,
SkFloatToScalar(maxWidth), &measured, tbd);
SkASSERT((bytes & 1) == 0);
@@ -743,7 +756,20 @@ public:
SkRect r;
SkIRect ir;
- paint.measureText(text, count << 1, &r);
+ sp<TextLayoutCacheValue> value;
+#if USE_TEXT_LAYOUT_CACHE
+ value = TextLayoutCache::getInstance().getValue(&paint, text, 0, count,
+ count, paint.getFlags());
+ if (value == NULL) {
+ ALOGE("Cannot get TextLayoutCache value for text = '%s'",
+ String8(text, count).string());
+ }
+#else
+ value = new TextLayoutCacheValue(count);
+ TextLayoutEngine::getInstance().computeValues(value.get(), &paint,
+ reinterpret_cast<const UChar*>(text), 0, count, count, paint.getFlags());
+#endif
+ paint.measureText(value->getGlyphs(), value->getGlyphsCount() << 1, &r);
r.roundOut(&ir);
GraphicsJNI::irect_to_jrect(ir, env, bounds);
}
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp
index d26f563519ad..71c283a73e75 100644
--- a/core/jni/android/graphics/TextLayoutCache.cpp
+++ b/core/jni/android/graphics/TextLayoutCache.cpp
@@ -93,7 +93,7 @@ void TextLayoutCache::clear() {
/*
* Caching
*/
-sp<TextLayoutCacheValue> TextLayoutCache::getValue(SkPaint* paint,
+sp<TextLayoutCacheValue> TextLayoutCache::getValue(const SkPaint* paint,
const jchar* text, jint start, jint count, jint contextCount, jint dirFlags) {
AutoMutex _l(mLock);
nsecs_t startTime = 0;
@@ -360,7 +360,7 @@ TextLayoutEngine::~TextLayoutEngine() {
// we don't bother at the moment
}
-void TextLayoutEngine::computeValues(TextLayoutCacheValue* value, SkPaint* paint, const UChar* chars,
+void TextLayoutEngine::computeValues(TextLayoutCacheValue* value, const SkPaint* paint, const UChar* chars,
size_t start, size_t count, size_t contextCount, int dirFlags) {
computeValues(paint, chars, start, count, contextCount, dirFlags,
@@ -371,7 +371,7 @@ void TextLayoutEngine::computeValues(TextLayoutCacheValue* value, SkPaint* paint
#endif
}
-void TextLayoutEngine::computeValues(SkPaint* paint, const UChar* chars,
+void TextLayoutEngine::computeValues(const SkPaint* paint, const UChar* chars,
size_t start, size_t count, size_t contextCount, int dirFlags,
Vector<jfloat>* const outAdvances, jfloat* outTotalAdvance,
Vector<jchar>* const outGlyphs) {
@@ -513,7 +513,7 @@ static void logGlyphs(HB_ShaperItem shaperItem) {
}
}
-void TextLayoutEngine::computeRunValues(SkPaint* paint, const UChar* chars,
+void TextLayoutEngine::computeRunValues(const SkPaint* paint, const UChar* chars,
size_t count, bool isRTL,
Vector<jfloat>* const outAdvances, jfloat* outTotalAdvance,
Vector<jchar>* const outGlyphs) {
@@ -719,7 +719,7 @@ void TextLayoutEngine::computeRunValues(SkPaint* paint, const UChar* chars,
}
-size_t TextLayoutEngine::shapeFontRun(SkPaint* paint, bool isRTL) {
+size_t TextLayoutEngine::shapeFontRun(const SkPaint* paint, bool isRTL) {
// Reset kerning
mShaperItem.kerning_applied = false;
diff --git a/core/jni/android/graphics/TextLayoutCache.h b/core/jni/android/graphics/TextLayoutCache.h
index 510aa18f6788..956e8cac3dd9 100644
--- a/core/jni/android/graphics/TextLayoutCache.h
+++ b/core/jni/android/graphics/TextLayoutCache.h
@@ -179,7 +179,7 @@ public:
*/
void operator()(TextLayoutCacheKey& text, sp<TextLayoutCacheValue>& desc);
- sp<TextLayoutCacheValue> getValue(SkPaint* paint, const jchar* text, jint start, jint count,
+ sp<TextLayoutCacheValue> getValue(const SkPaint* paint, const jchar* text, jint start, jint count,
jint contextCount, jint dirFlags);
/**
@@ -224,7 +224,7 @@ public:
TextLayoutEngine();
virtual ~TextLayoutEngine();
- void computeValues(TextLayoutCacheValue* value, SkPaint* paint, const UChar* chars,
+ void computeValues(TextLayoutCacheValue* value, const SkPaint* paint, const UChar* chars,
size_t start, size_t count, size_t contextCount, int dirFlags);
private:
@@ -273,14 +273,14 @@ private:
*/
UnicodeString mBuffer;
- size_t shapeFontRun(SkPaint* paint, bool isRTL);
+ size_t shapeFontRun(const SkPaint* paint, bool isRTL);
- void computeValues(SkPaint* paint, const UChar* chars,
+ void computeValues(const SkPaint* paint, const UChar* chars,
size_t start, size_t count, size_t contextCount, int dirFlags,
Vector<jfloat>* const outAdvances, jfloat* outTotalAdvance,
Vector<jchar>* const outGlyphs);
- void computeRunValues(SkPaint* paint, const UChar* chars,
+ void computeRunValues(const SkPaint* paint, const UChar* chars,
size_t count, bool isRTL,
Vector<jfloat>* const outAdvances, jfloat* outTotalAdvance,
Vector<jchar>* const outGlyphs);