summaryrefslogtreecommitdiffstats
path: root/core/jni
diff options
context:
space:
mode:
authorRaph Levien <raph@google.com>2015-08-31 16:21:20 -0700
committerRoozbeh Pournader <roozbeh@google.com>2015-10-14 19:11:33 +0000
commit35e026929b10bf05c4c78fce6f05d7569972c5cb (patch)
treebdd52e2b3a736a04b7add2ed8c3e746768828a1b /core/jni
parentb7e722b88fab8b67f8a2ef54a7acb8c6672b6f46 (diff)
downloadframeworks_base-35e026929b10bf05c4c78fce6f05d7569972c5cb.zip
frameworks_base-35e026929b10bf05c4c78fce6f05d7569972c5cb.tar.gz
frameworks_base-35e026929b10bf05c4c78fce6f05d7569972c5cb.tar.bz2
Load binary hyphen data files
Support for loading the pre-compiled binary format for hyphenation patterns. Bug: 21562869 Bug: 21826930 Bug: 24570591 Change-Id: Iaeaa9c9ac9dac236af6b0d7894c2e2396bc8447d (cherry picked from commit 091dba2de1e5fa7d4db9f8ccbf1f86e5825d0f52)
Diffstat (limited to 'core/jni')
-rw-r--r--core/jni/android_text_StaticLayout.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/core/jni/android_text_StaticLayout.cpp b/core/jni/android_text_StaticLayout.cpp
index 90e4bb6..a94ea8b 100644
--- a/core/jni/android_text_StaticLayout.cpp
+++ b/core/jni/android_text_StaticLayout.cpp
@@ -117,9 +117,17 @@ static void nFinishBuilder(JNIEnv*, jclass, jlong nativePtr) {
b->finish();
}
-static jlong nLoadHyphenator(JNIEnv* env, jclass, jstring patternData) {
- ScopedStringChars str(env, patternData);
- Hyphenator* hyphenator = Hyphenator::load(str.get(), str.size());
+static jlong nLoadHyphenator(JNIEnv* env, jclass, jobject buffer, jint offset) {
+ const uint8_t* bytebuf = nullptr;
+ if (buffer != nullptr) {
+ void* rawbuf = env->GetDirectBufferAddress(buffer);
+ if (rawbuf != nullptr) {
+ bytebuf = reinterpret_cast<const uint8_t*>(rawbuf) + offset;
+ } else {
+ ALOGE("failed to get direct buffer address");
+ }
+ }
+ Hyphenator* hyphenator = Hyphenator::loadBinary(bytebuf);
return reinterpret_cast<jlong>(hyphenator);
}
@@ -177,7 +185,7 @@ static JNINativeMethod gMethods[] = {
{"nNewBuilder", "()J", (void*) nNewBuilder},
{"nFreeBuilder", "(J)V", (void*) nFreeBuilder},
{"nFinishBuilder", "(J)V", (void*) nFinishBuilder},
- {"nLoadHyphenator", "(Ljava/lang/String;)J", (void*) nLoadHyphenator},
+ {"nLoadHyphenator", "(Ljava/nio/ByteBuffer;I)J", (void*) nLoadHyphenator},
{"nSetLocale", "(JLjava/lang/String;J)V", (void*) nSetLocale},
{"nSetupParagraph", "(J[CIFIF[IIII)V", (void*) nSetupParagraph},
{"nSetIndents", "(J[I)V", (void*) nSetIndents},