diff options
author | Behdad Esfahbod <behdad@google.com> | 2014-07-25 19:30:49 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-07-24 15:37:54 +0000 |
commit | c437f6eef2e92fd1ca1c542a8e41315253ec7747 (patch) | |
tree | 86167820487cf016778358da4c2881596ba0298e /core/jni/android/graphics | |
parent | b9333b5970911343950900a6f46dcbbd6d920ce9 (diff) | |
parent | 63c5c78a72a21d57913e8601cc2a1ab72a424a02 (diff) | |
download | frameworks_base-c437f6eef2e92fd1ca1c542a8e41315253ec7747.zip frameworks_base-c437f6eef2e92fd1ca1c542a8e41315253ec7747.tar.gz frameworks_base-c437f6eef2e92fd1ca1c542a8e41315253ec7747.tar.bz2 |
Merge "Further centralize Minikin interaction" into lmp-dev
Diffstat (limited to 'core/jni/android/graphics')
-rw-r--r-- | core/jni/android/graphics/MinikinUtils.cpp | 6 | ||||
-rw-r--r-- | core/jni/android/graphics/MinikinUtils.h | 4 | ||||
-rw-r--r-- | core/jni/android/graphics/Paint.cpp | 24 |
3 files changed, 13 insertions, 21 deletions
diff --git a/core/jni/android/graphics/MinikinUtils.cpp b/core/jni/android/graphics/MinikinUtils.cpp index 802f2ab..2ad8330 100644 --- a/core/jni/android/graphics/MinikinUtils.cpp +++ b/core/jni/android/graphics/MinikinUtils.cpp @@ -40,8 +40,8 @@ static int snprintfcat(char* buf, int off, int size, const char* format, ...) { return off + n; } -std::string MinikinUtils::setLayoutProperties(Layout* layout, const Paint* paint, int bidiFlags, - TypefaceImpl* typeface) { +void MinikinUtils::doLayout(Layout* layout, const Paint* paint, int bidiFlags, TypefaceImpl* typeface, + const uint16_t* buf, size_t start, size_t count, size_t bufSize) { TypefaceImpl* resolvedFace = TypefaceImpl_resolveDefault(typeface); layout->setFontCollection(resolvedFace->fFontCollection); FontStyle style = resolvedFace->fStyle; @@ -62,7 +62,7 @@ std::string MinikinUtils::setLayoutProperties(Layout* layout, const Paint* paint SkPaintOptionsAndroid::FontVariant var = paint->getPaintOptionsAndroid().getFontVariant(); const char* varstr = var == SkPaintOptionsAndroid::kElegant_Variant ? "elegant" : "compact"; off = snprintfcat(css, off, sizeof(css), " -minikin-variant: %s;", varstr); - return std::string(css); + layout->doLayout(buf, start, count, bufSize, std::string(css)); } float MinikinUtils::xOffsetForTextAlign(Paint* paint, const Layout& layout) { diff --git a/core/jni/android/graphics/MinikinUtils.h b/core/jni/android/graphics/MinikinUtils.h index 0562c3b..647cbd8 100644 --- a/core/jni/android/graphics/MinikinUtils.h +++ b/core/jni/android/graphics/MinikinUtils.h @@ -45,8 +45,8 @@ class TypefaceImpl; class MinikinUtils { public: - static std::string setLayoutProperties(Layout* layout, const Paint* paint, int bidiFlags, - TypefaceImpl* typeface); + static void doLayout(Layout* layout, const Paint* paint, int bidiFlags, TypefaceImpl* typeface, + const uint16_t* buf, size_t start, size_t count, size_t bufSize); static float xOffsetForTextAlign(Paint* paint, const Layout& layout); diff --git a/core/jni/android/graphics/Paint.cpp b/core/jni/android/graphics/Paint.cpp index e2b3684..a1f09bd 100644 --- a/core/jni/android/graphics/Paint.cpp +++ b/core/jni/android/graphics/Paint.cpp @@ -535,8 +535,7 @@ public: Layout layout; TypefaceImpl* typeface = GraphicsJNI::getNativeTypeface(env, jpaint); - std::string css = MinikinUtils::setLayoutProperties(&layout, paint, bidiFlags, typeface); - layout.doLayout(textArray, index, count, textLength, css); + MinikinUtils::doLayout(&layout, paint, bidiFlags, typeface, textArray, index, count, textLength); result = layout.getAdvance(); env->ReleaseCharArrayElements(text, const_cast<jchar*>(textArray), JNI_ABORT); return result; @@ -563,8 +562,7 @@ public: Layout layout; TypefaceImpl* typeface = GraphicsJNI::getNativeTypeface(env, jpaint); - std::string css = MinikinUtils::setLayoutProperties(&layout, paint, bidiFlags, typeface); - layout.doLayout(textArray, start, count, textLength, css); + MinikinUtils::doLayout(&layout, paint, bidiFlags, typeface, textArray, start, count, textLength); width = layout.getAdvance(); env->ReleaseStringChars(text, textArray); @@ -586,8 +584,7 @@ public: Layout layout; TypefaceImpl* typeface = GraphicsJNI::getNativeTypeface(env, jpaint); - std::string css = MinikinUtils::setLayoutProperties(&layout, paint, bidiFlags, typeface); - layout.doLayout(textArray, 0, textLength, textLength, css); + MinikinUtils::doLayout(&layout, paint, bidiFlags, typeface, textArray, 0, textLength, textLength); width = layout.getAdvance(); env->ReleaseStringChars(text, textArray); @@ -616,8 +613,7 @@ public: jfloat* widthsArray = autoWidths.ptr(); Layout layout; - std::string css = MinikinUtils::setLayoutProperties(&layout, paint, bidiFlags, typeface); - layout.doLayout(text, 0, count, count, css); + MinikinUtils::doLayout(&layout, paint, bidiFlags, typeface, text, 0, count, count); layout.getAdvances(widthsArray); return count; @@ -670,8 +666,7 @@ public: int bidiFlags = isRtl ? kBidi_Force_RTL : kBidi_Force_LTR; Layout layout; - std::string css = MinikinUtils::setLayoutProperties(&layout, paint, bidiFlags, typeface); - layout.doLayout(text, start, count, contextCount, css); + MinikinUtils::doLayout(&layout, paint, bidiFlags, typeface, text, start, count, contextCount); layout.getAdvances(advancesArray); totalAdvance = layout.getAdvance(); @@ -770,8 +765,7 @@ public: static void getTextPath(JNIEnv* env, Paint* paint, TypefaceImpl* typeface, const jchar* text, jint count, jint bidiFlags, jfloat x, jfloat y, SkPath* path) { Layout layout; - std::string css = MinikinUtils::setLayoutProperties(&layout, paint, bidiFlags, typeface); - layout.doLayout(text, 0, count, count, css); + MinikinUtils::doLayout(&layout, paint, bidiFlags, typeface, text, 0, count, count); size_t nGlyphs = layout.nGlyphs(); uint16_t* glyphs = new uint16_t[nGlyphs]; SkPoint* pos = new SkPoint[nGlyphs]; @@ -833,8 +827,7 @@ public: float measured = 0; Layout layout; - std::string css = MinikinUtils::setLayoutProperties(&layout, &paint, bidiFlags, typeface); - layout.doLayout(text, 0, count, count, css); + MinikinUtils::doLayout(&layout, &paint, bidiFlags, typeface, text, 0, count, count); float* advances = new float[count]; layout.getAdvances(advances); const bool forwardScan = (textBufferDirection == Paint::kForward_TextBufferDirection); @@ -914,8 +907,7 @@ public: SkIRect ir; Layout layout; - std::string css = MinikinUtils::setLayoutProperties(&layout, &paint, bidiFlags, typeface); - layout.doLayout(text, 0, count, count, css); + MinikinUtils::doLayout(&layout, &paint, bidiFlags, typeface, text, 0, count, count); MinikinRect rect; layout.getBounds(&rect); r.fLeft = rect.mLeft; |