am e0ebf19c: Merge "Support for context in Minikin shaping" into lmp-preview-dev
* commit 'e0ebf19cbfa60ba3eb0891d5e8416b70b212bc36':
Support for context in Minikin shaping
diff --git a/core/jni/android/graphics/Canvas.cpp b/core/jni/android/graphics/Canvas.cpp
index bdaf3a0..d1203a7 100644
--- a/core/jni/android/graphics/Canvas.cpp
+++ b/core/jni/android/graphics/Canvas.cpp
@@ -818,8 +818,8 @@
#ifdef USE_MINIKIN
Layout layout;
- MinikinUtils::SetLayoutProperties(&layout, paint, flags, typeface);
- layout.doLayout(textArray + start, count);
+ std::string css = MinikinUtils::setLayoutProperties(&layout, paint, flags, typeface);
+ layout.doLayout(textArray, start, count, contextCount, css);
drawGlyphsToSkia(canvas, paint, layout, x, y);
#else
sp<TextLayoutValue> value = TextLayoutEngine::getInstance().getValue(paint,
diff --git a/core/jni/android/graphics/MinikinUtils.cpp b/core/jni/android/graphics/MinikinUtils.cpp
index 146bc3d..a9360ea 100644
--- a/core/jni/android/graphics/MinikinUtils.cpp
+++ b/core/jni/android/graphics/MinikinUtils.cpp
@@ -16,6 +16,7 @@
#define LOG_TAG "Minikin"
#include <cutils/log.h>
+#include <string>
#include "SkPaint.h"
#include "minikin/Layout.h"
@@ -36,8 +37,8 @@
return off + n;
}
-void MinikinUtils::SetLayoutProperties(Layout* layout, const SkPaint* paint, int flags,
- TypefaceImpl* typeface) {
+std::string MinikinUtils::setLayoutProperties(Layout* layout, const SkPaint* paint, int bidiFlags,
+ TypefaceImpl* typeface) {
TypefaceImpl* resolvedFace = TypefaceImpl_resolveDefault(typeface);
layout->setFontCollection(resolvedFace->fFontCollection);
FontStyle style = resolvedFace->fStyle;
@@ -51,13 +52,14 @@
MinikinFontSkia::packPaintFlags(paint),
style.getWeight() * 100,
style.getItalic() ? "italic" : "normal",
- flags);
+ bidiFlags);
SkString langString = paint->getPaintOptionsAndroid().getLanguage().getTag();
off = snprintfcat(css, off, sizeof(css), " lang: %s;", langString.c_str());
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);
layout->setProperties(css);
+ return std::string(css);
}
float MinikinUtils::xOffsetForTextAlign(SkPaint* paint, const Layout& layout) {
diff --git a/core/jni/android/graphics/MinikinUtils.h b/core/jni/android/graphics/MinikinUtils.h
index 3996c82..ea7eb5d 100644
--- a/core/jni/android/graphics/MinikinUtils.h
+++ b/core/jni/android/graphics/MinikinUtils.h
@@ -31,8 +31,8 @@
class MinikinUtils {
public:
- static void SetLayoutProperties(Layout* layout, const SkPaint* paint, int flags,
- TypefaceImpl* face);
+ static std::string setLayoutProperties(Layout* layout, const SkPaint* paint, int bidiFlags,
+ TypefaceImpl* typeface);
static float xOffsetForTextAlign(SkPaint* paint, const Layout& layout);
diff --git a/core/jni/android/graphics/Paint.cpp b/core/jni/android/graphics/Paint.cpp
index 4000b07..3dc874e 100644
--- a/core/jni/android/graphics/Paint.cpp
+++ b/core/jni/android/graphics/Paint.cpp
@@ -520,8 +520,8 @@
#ifdef USE_MINIKIN
Layout layout;
TypefaceImpl* typeface = GraphicsJNI::getNativeTypeface(env, jpaint);
- MinikinUtils::SetLayoutProperties(&layout, paint, bidiFlags, typeface);
- layout.doLayout(textArray + index, count);
+ std::string css = MinikinUtils::setLayoutProperties(&layout, paint, bidiFlags, typeface);
+ layout.doLayout(textArray, index, count, textLength, css);
result = layout.getAdvance();
#else
TextLayout::getTextRunAdvances(paint, textArray, index, count, textLength,
@@ -554,8 +554,8 @@
#ifdef USE_MINIKIN
Layout layout;
TypefaceImpl* typeface = GraphicsJNI::getNativeTypeface(env, jpaint);
- MinikinUtils::SetLayoutProperties(&layout, paint, bidiFlags, typeface);
- layout.doLayout(textArray + start, count);
+ std::string css = MinikinUtils::setLayoutProperties(&layout, paint, bidiFlags, typeface);
+ layout.doLayout(textArray, start, count, textLength, css);
width = layout.getAdvance();
#else
TextLayout::getTextRunAdvances(paint, textArray, start, count, textLength,
@@ -582,8 +582,8 @@
#ifdef USE_MINIKIN
Layout layout;
TypefaceImpl* typeface = GraphicsJNI::getNativeTypeface(env, jpaint);
- MinikinUtils::SetLayoutProperties(&layout, paint, bidiFlags, typeface);
- layout.doLayout(textArray, textLength);
+ std::string css = MinikinUtils::setLayoutProperties(&layout, paint, bidiFlags, typeface);
+ layout.doLayout(textArray, 0, textLength, textLength, css);
width = layout.getAdvance();
#else
TextLayout::getTextRunAdvances(paint, textArray, 0, textLength, textLength,
@@ -617,8 +617,8 @@
#ifdef USE_MINIKIN
Layout layout;
- MinikinUtils::SetLayoutProperties(&layout, paint, bidiFlags, typeface);
- layout.doLayout(text, count);
+ std::string css = MinikinUtils::setLayoutProperties(&layout, paint, bidiFlags, typeface);
+ layout.doLayout(text, 0, count, count, css);
layout.getAdvances(widthsArray);
#else
TextLayout::getTextRunAdvances(paint, text, 0, count, count,
@@ -715,8 +715,8 @@
#ifdef USE_MINIKIN
Layout layout;
- MinikinUtils::SetLayoutProperties(&layout, paint, flags, typeface);
- layout.doLayout(text + start, count);
+ std::string css = MinikinUtils::setLayoutProperties(&layout, paint, flags, typeface);
+ layout.doLayout(text, start, count, contextCount, css);
layout.getAdvances(advancesArray);
totalAdvance = layout.getAdvance();
#else
@@ -860,8 +860,8 @@
jint count, jint bidiFlags, jfloat x, jfloat y, SkPath* path) {
#ifdef USE_MINIKIN
Layout layout;
- MinikinUtils::SetLayoutProperties(&layout, paint, bidiFlags, typeface);
- layout.doLayout(text, count);
+ std::string css = MinikinUtils::setLayoutProperties(&layout, paint, bidiFlags, typeface);
+ layout.doLayout(text, 0, count, count, css);
size_t nGlyphs = layout.nGlyphs();
uint16_t* glyphs = new uint16_t[nGlyphs];
SkPoint* pos = new SkPoint[nGlyphs];
@@ -992,8 +992,8 @@
#ifdef USE_MINIKIN
Layout layout;
- MinikinUtils::SetLayoutProperties(&layout, &paint, bidiFlags, typeface);
- layout.doLayout(text, count);
+ std::string css = MinikinUtils::setLayoutProperties(&layout, &paint, bidiFlags, typeface);
+ layout.doLayout(text, 0, count, count, css);
MinikinRect rect;
layout.getBounds(&rect);
r.fLeft = rect.mLeft;
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index 6b35be1..33fd346 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -645,8 +645,8 @@
jfloat x, jfloat y, int flags, SkPaint* paint, TypefaceImpl* typeface) {
#ifdef USE_MINIKIN
Layout layout;
- MinikinUtils::SetLayoutProperties(&layout, paint, flags, typeface);
- layout.doLayout(text, count);
+ std::string css = MinikinUtils::setLayoutProperties(&layout, paint, flags, typeface);
+ layout.doLayout(text, 0, count, count, css);
x += xOffsetForTextAlign(paint, layout.getAdvance());
renderTextLayout(renderer, &layout, x, y, paint);
#else
@@ -689,8 +689,8 @@
int flags, SkPaint* paint, TypefaceImpl* typeface) {
#ifdef USE_MINIKIN
Layout layout;
- MinikinUtils::SetLayoutProperties(&layout, paint, flags, typeface);
- layout.doLayout(text + start, count);
+ std::string css = MinikinUtils::setLayoutProperties(&layout, paint, flags, typeface);
+ layout.doLayout(text, start, count, contextCount, css);
x += xOffsetForTextAlign(paint, layout.getAdvance());
renderTextLayout(renderer, &layout, x, y, paint);
#else