Make casting to bidi flags explicit
Bug: 65024629 Test: checkbuild Change-Id: I0771036359cc1ee5471e9fd4da304598a2f8bf98
This commit is contained in:
@@ -112,8 +112,8 @@ namespace PaintGlue {
|
||||
float measured = 0;
|
||||
|
||||
std::unique_ptr<float[]> advancesArray(new float[count]);
|
||||
MinikinUtils::measureText(&paint, bidiFlags, typeface, text, 0, count, count,
|
||||
advancesArray.get());
|
||||
MinikinUtils::measureText(&paint, static_cast<minikin::Bidi>(bidiFlags), typeface, text,
|
||||
0, count, count, advancesArray.get());
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
// traverse in the given direction
|
||||
@@ -203,8 +203,9 @@ namespace PaintGlue {
|
||||
if (advances) {
|
||||
advancesArray.reset(new jfloat[count]);
|
||||
}
|
||||
const float advance = MinikinUtils::measureText(paint, bidiFlags, typeface, text,
|
||||
start, count, contextCount, advancesArray.get());
|
||||
const float advance = MinikinUtils::measureText(paint,
|
||||
static_cast<minikin::Bidi>(bidiFlags), typeface, text, start, count, contextCount,
|
||||
advancesArray.get());
|
||||
if (advances) {
|
||||
env->SetFloatArrayRegion(advances, advancesIndex, count, advancesArray.get());
|
||||
}
|
||||
@@ -239,7 +240,7 @@ namespace PaintGlue {
|
||||
static jint doTextRunCursor(JNIEnv *env, Paint* paint, const Typeface* typeface,
|
||||
const jchar *text, jint start, jint count, jint dir, jint offset, jint opt) {
|
||||
minikin::GraphemeBreak::MoveOpt moveOpt = minikin::GraphemeBreak::MoveOpt(opt);
|
||||
int bidiFlags = dir == 1 ? minikin::kBidi_Force_RTL : minikin::kBidi_Force_LTR;
|
||||
minikin::Bidi bidiFlags = dir == 1 ? minikin::Bidi::FORCE_RTL : minikin::Bidi::FORCE_LTR;
|
||||
std::unique_ptr<float[]> advancesArray(new float[count]);
|
||||
MinikinUtils::measureText(paint, bidiFlags, typeface, text, start, count, start + count,
|
||||
advancesArray.get());
|
||||
@@ -305,7 +306,7 @@ namespace PaintGlue {
|
||||
static void getTextPath(JNIEnv* env, Paint* paint, const Typeface* typeface, const jchar* text,
|
||||
jint count, jint bidiFlags, jfloat x, jfloat y, SkPath* path) {
|
||||
minikin::Layout layout = MinikinUtils::doLayout(
|
||||
paint, bidiFlags, typeface, text, 0, count, count);
|
||||
paint, static_cast<minikin::Bidi>(bidiFlags), typeface, text, 0, count, count);
|
||||
size_t nGlyphs = layout.nGlyphs();
|
||||
uint16_t* glyphs = new uint16_t[nGlyphs];
|
||||
SkPoint* pos = new SkPoint[nGlyphs];
|
||||
@@ -346,8 +347,8 @@ namespace PaintGlue {
|
||||
SkRect r;
|
||||
SkIRect ir;
|
||||
|
||||
minikin::Layout layout = MinikinUtils::doLayout(
|
||||
&paint, bidiFlags, typeface, text, 0, count, count);
|
||||
minikin::Layout layout = MinikinUtils::doLayout(&paint,
|
||||
static_cast<minikin::Bidi>(bidiFlags), typeface, text, 0, count, count);
|
||||
minikin::MinikinRect rect;
|
||||
layout.getBounds(&rect);
|
||||
r.fLeft = rect.mLeft;
|
||||
@@ -461,8 +462,9 @@ namespace PaintGlue {
|
||||
nChars++;
|
||||
prevCp = cp;
|
||||
}
|
||||
minikin::Layout layout = MinikinUtils::doLayout(
|
||||
paint, bidiFlags, typeface, str.get(), 0, str.size(), str.size());
|
||||
minikin::Layout layout = MinikinUtils::doLayout(paint,
|
||||
static_cast<minikin::Bidi>(bidiFlags), typeface, str.get(), 0, str.size(),
|
||||
str.size());
|
||||
size_t nGlyphs = countNonSpaceGlyphs(layout);
|
||||
if (nGlyphs != 1 && nChars > 1) {
|
||||
// multiple-character input, and was not a ligature
|
||||
@@ -481,8 +483,8 @@ namespace PaintGlue {
|
||||
// since ZZ is reserved for unknown or invalid territory.
|
||||
// U+1F1FF (REGIONAL INDICATOR SYMBOL LETTER Z) is \uD83C\uDDFF in UTF16.
|
||||
static const jchar ZZ_FLAG_STR[] = { 0xD83C, 0xDDFF, 0xD83C, 0xDDFF };
|
||||
minikin::Layout zzLayout = MinikinUtils::doLayout(
|
||||
paint, bidiFlags, typeface, ZZ_FLAG_STR, 0, 4, 4);
|
||||
minikin::Layout zzLayout = MinikinUtils::doLayout(paint,
|
||||
static_cast<minikin::Bidi>(bidiFlags), typeface, ZZ_FLAG_STR, 0, 4, 4);
|
||||
if (zzLayout.nGlyphs() != 1 || layoutContainsNotdef(zzLayout)) {
|
||||
// The font collection doesn't have a glyph for unknown flag. Just return true.
|
||||
return true;
|
||||
@@ -494,7 +496,7 @@ namespace PaintGlue {
|
||||
|
||||
static jfloat doRunAdvance(const Paint* paint, const Typeface* typeface, const jchar buf[],
|
||||
jint start, jint count, jint bufSize, jboolean isRtl, jint offset) {
|
||||
int bidiFlags = isRtl ? minikin::kBidi_Force_RTL : minikin::kBidi_Force_LTR;
|
||||
minikin::Bidi bidiFlags = isRtl ? minikin::Bidi::FORCE_RTL : minikin::Bidi::FORCE_LTR;
|
||||
if (offset == start + count) {
|
||||
return MinikinUtils::measureText(paint, bidiFlags, typeface, buf, start, count,
|
||||
bufSize, nullptr);
|
||||
@@ -519,7 +521,7 @@ namespace PaintGlue {
|
||||
|
||||
static jint doOffsetForAdvance(const Paint* paint, const Typeface* typeface, const jchar buf[],
|
||||
jint start, jint count, jint bufSize, jboolean isRtl, jfloat advance) {
|
||||
int bidiFlags = isRtl ? minikin::kBidi_Force_RTL : minikin::kBidi_Force_LTR;
|
||||
minikin::Bidi bidiFlags = isRtl ? minikin::Bidi::FORCE_RTL : minikin::Bidi::FORCE_LTR;
|
||||
std::unique_ptr<float[]> advancesArray(new float[count]);
|
||||
MinikinUtils::measureText(paint, bidiFlags, typeface, buf, start, count, bufSize,
|
||||
advancesArray.get());
|
||||
|
||||
@@ -480,7 +480,7 @@ static void drawTextChars(JNIEnv* env, jobject, jlong canvasHandle, jcharArray t
|
||||
const Typeface* typeface = paint->getAndroidTypeface();
|
||||
jchar* jchars = env->GetCharArrayElements(text, NULL);
|
||||
get_canvas(canvasHandle)->drawText(jchars + index, 0, count, count, x, y,
|
||||
bidiFlags, *paint, typeface);
|
||||
static_cast<minikin::Bidi>(bidiFlags), *paint, typeface);
|
||||
env->ReleaseCharArrayElements(text, jchars, JNI_ABORT);
|
||||
}
|
||||
|
||||
@@ -492,7 +492,7 @@ static void drawTextString(JNIEnv* env, jobject, jlong canvasHandle, jstring tex
|
||||
const int count = end - start;
|
||||
const jchar* jchars = env->GetStringChars(text, NULL);
|
||||
get_canvas(canvasHandle)->drawText(jchars + start, 0, count, count, x, y,
|
||||
bidiFlags, *paint, typeface);
|
||||
static_cast<minikin::Bidi>(bidiFlags), *paint, typeface);
|
||||
env->ReleaseStringChars(text, jchars);
|
||||
}
|
||||
|
||||
@@ -502,7 +502,7 @@ static void drawTextRunChars(JNIEnv* env, jobject, jlong canvasHandle, jcharArra
|
||||
Paint* paint = reinterpret_cast<Paint*>(paintHandle);
|
||||
const Typeface* typeface = paint->getAndroidTypeface();
|
||||
|
||||
const int bidiFlags = isRtl ? minikin::kBidi_Force_RTL : minikin::kBidi_Force_LTR;
|
||||
const minikin::Bidi bidiFlags = isRtl ? minikin::Bidi::FORCE_RTL : minikin::Bidi::FORCE_LTR;
|
||||
jchar* jchars = env->GetCharArrayElements(text, NULL);
|
||||
get_canvas(canvasHandle)->drawText(jchars + contextIndex, index - contextIndex, count,
|
||||
contextCount, x, y, bidiFlags, *paint, typeface);
|
||||
@@ -515,7 +515,7 @@ static void drawTextRunString(JNIEnv* env, jobject obj, jlong canvasHandle, jstr
|
||||
Paint* paint = reinterpret_cast<Paint*>(paintHandle);
|
||||
const Typeface* typeface = paint->getAndroidTypeface();
|
||||
|
||||
int bidiFlags = isRtl ? minikin::kBidi_Force_RTL : minikin::kBidi_Force_LTR;
|
||||
const minikin::Bidi bidiFlags = isRtl ? minikin::Bidi::FORCE_RTL : minikin::Bidi::FORCE_LTR;
|
||||
jint count = end - start;
|
||||
jint contextCount = contextEnd - contextStart;
|
||||
const jchar* jchars = env->GetStringChars(text, NULL);
|
||||
@@ -533,8 +533,8 @@ static void drawTextOnPathChars(JNIEnv* env, jobject, jlong canvasHandle, jcharA
|
||||
|
||||
jchar* jchars = env->GetCharArrayElements(text, NULL);
|
||||
|
||||
get_canvas(canvasHandle)->drawTextOnPath(jchars + index, count, bidiFlags, *path,
|
||||
hOffset, vOffset, *paint, typeface);
|
||||
get_canvas(canvasHandle)->drawTextOnPath(jchars + index, count,
|
||||
static_cast<minikin::Bidi>(bidiFlags), *path, hOffset, vOffset, *paint, typeface);
|
||||
|
||||
env->ReleaseCharArrayElements(text, jchars, 0);
|
||||
}
|
||||
@@ -549,8 +549,8 @@ static void drawTextOnPathString(JNIEnv* env, jobject, jlong canvasHandle, jstri
|
||||
const jchar* jchars = env->GetStringChars(text, NULL);
|
||||
int count = env->GetStringLength(text);
|
||||
|
||||
get_canvas(canvasHandle)->drawTextOnPath(jchars, count, bidiFlags, *path,
|
||||
hOffset, vOffset, *paint, typeface);
|
||||
get_canvas(canvasHandle)->drawTextOnPath(jchars, count, static_cast<minikin::Bidi>(bidiFlags),
|
||||
*path, hOffset, vOffset, *paint, typeface);
|
||||
|
||||
env->ReleaseStringChars(text, jchars);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,8 @@ private:
|
||||
};
|
||||
|
||||
void Canvas::drawText(const uint16_t* text, int start, int count, int contextCount,
|
||||
float x, float y, int bidiFlags, const Paint& origPaint, const Typeface* typeface) {
|
||||
float x, float y, minikin::Bidi bidiFlags, const Paint& origPaint,
|
||||
const Typeface* typeface) {
|
||||
// minikin may modify the original paint
|
||||
Paint paint(origPaint);
|
||||
|
||||
@@ -206,8 +207,9 @@ private:
|
||||
const SkPath& path;
|
||||
};
|
||||
|
||||
void Canvas::drawTextOnPath(const uint16_t* text, int count, int bidiFlags, const SkPath& path,
|
||||
float hOffset, float vOffset, const Paint& paint, const Typeface* typeface) {
|
||||
void Canvas::drawTextOnPath(const uint16_t* text, int count, minikin::Bidi bidiFlags,
|
||||
const SkPath& path, float hOffset, float vOffset, const Paint& paint,
|
||||
const Typeface* typeface) {
|
||||
Paint paintCopy(paint);
|
||||
minikin::Layout layout = MinikinUtils::doLayout(
|
||||
&paintCopy, bidiFlags, typeface, text, 0, count, count);
|
||||
|
||||
@@ -33,6 +33,7 @@ class SkVertices;
|
||||
|
||||
namespace minikin {
|
||||
class Layout;
|
||||
enum class Bidi : uint8_t;
|
||||
}
|
||||
|
||||
namespace android {
|
||||
@@ -255,10 +256,12 @@ public:
|
||||
* and delegating the final draw to virtual drawGlyphs method.
|
||||
*/
|
||||
void drawText(const uint16_t* text, int start, int count, int contextCount,
|
||||
float x, float y, int bidiFlags, const Paint& origPaint, const Typeface* typeface);
|
||||
float x, float y, minikin::Bidi bidiFlags, const Paint& origPaint,
|
||||
const Typeface* typeface);
|
||||
|
||||
void drawTextOnPath(const uint16_t* text, int count, int bidiFlags, const SkPath& path,
|
||||
float hOffset, float vOffset, const Paint& paint, const Typeface* typeface);
|
||||
void drawTextOnPath(const uint16_t* text, int count, minikin::Bidi bidiFlags,
|
||||
const SkPath& path, float hOffset, float vOffset, const Paint& paint,
|
||||
const Typeface* typeface);
|
||||
|
||||
protected:
|
||||
void drawTextDecorations(float x, float y, float length, const SkPaint& paint);
|
||||
|
||||
@@ -51,9 +51,8 @@ minikin::FontStyle MinikinUtils::prepareMinikinPaint(minikin::MinikinPaint* mini
|
||||
return minikinStyle;
|
||||
}
|
||||
|
||||
minikin::Layout MinikinUtils::doLayout(const Paint* paint, int bidiFlags,
|
||||
const Typeface* typeface, const uint16_t* buf, size_t start, size_t count,
|
||||
size_t bufSize) {
|
||||
minikin::Layout MinikinUtils::doLayout(const Paint* paint, minikin::Bidi bidiFlags,
|
||||
const Typeface* typeface, const uint16_t* buf, size_t start, size_t count, size_t bufSize) {
|
||||
minikin::MinikinPaint minikinPaint;
|
||||
minikin::FontStyle minikinStyle = prepareMinikinPaint(&minikinPaint, paint, typeface);
|
||||
minikin::Layout layout;
|
||||
@@ -62,8 +61,9 @@ minikin::Layout MinikinUtils::doLayout(const Paint* paint, int bidiFlags,
|
||||
return layout;
|
||||
}
|
||||
|
||||
float MinikinUtils::measureText(const Paint* paint, int bidiFlags, const Typeface* typeface,
|
||||
const uint16_t* buf, size_t start, size_t count, size_t bufSize, float *advances) {
|
||||
float MinikinUtils::measureText(const Paint* paint, minikin::Bidi bidiFlags,
|
||||
const Typeface* typeface, const uint16_t* buf, size_t start, size_t count, size_t bufSize,
|
||||
float *advances) {
|
||||
minikin::MinikinPaint minikinPaint;
|
||||
minikin::FontStyle minikinStyle = prepareMinikinPaint(&minikinPaint, paint, typeface);
|
||||
const Typeface* resolvedTypeface = Typeface::resolveDefault(typeface);
|
||||
|
||||
@@ -37,11 +37,11 @@ public:
|
||||
ANDROID_API static minikin::FontStyle prepareMinikinPaint(minikin::MinikinPaint* minikinPaint,
|
||||
const Paint* paint, const Typeface* typeface);
|
||||
|
||||
ANDROID_API static minikin::Layout doLayout(const Paint* paint, int bidiFlags,
|
||||
ANDROID_API static minikin::Layout doLayout(const Paint* paint, minikin::Bidi bidiFlags,
|
||||
const Typeface* typeface, const uint16_t* buf, size_t start, size_t count,
|
||||
size_t bufSize);
|
||||
|
||||
ANDROID_API static float measureText(const Paint* paint, int bidiFlags,
|
||||
ANDROID_API static float measureText(const Paint* paint, minikin::Bidi bidiFlags,
|
||||
const Typeface* typeface, const uint16_t* buf, size_t start, size_t count,
|
||||
size_t bufSize, float *advances);
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "hwui/Paint.h"
|
||||
#include "DeferredLayerUpdater.h"
|
||||
|
||||
#include <minikin/Layout.h>
|
||||
#include <renderthread/EglManager.h>
|
||||
#include <renderthread/OpenGLPipeline.h>
|
||||
#include <pipeline/skia/SkiaOpenGLPipeline.h>
|
||||
@@ -121,13 +122,15 @@ void TestUtils::layoutTextUnscaled(const SkPaint& paint, const char* text,
|
||||
void TestUtils::drawUtf8ToCanvas(Canvas* canvas, const char* text,
|
||||
const SkPaint& paint, float x, float y) {
|
||||
auto utf16 = asciiToUtf16(text);
|
||||
canvas->drawText(utf16.get(), 0, strlen(text), strlen(text), x, y, 0, paint, nullptr);
|
||||
canvas->drawText(utf16.get(), 0, strlen(text), strlen(text), x, y, minikin::Bidi::LTR, paint,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
void TestUtils::drawUtf8ToCanvas(Canvas* canvas, const char* text,
|
||||
const SkPaint& paint, const SkPath& path) {
|
||||
auto utf16 = asciiToUtf16(text);
|
||||
canvas->drawTextOnPath(utf16.get(), strlen(text), 0, path, 0, 0, paint, nullptr);
|
||||
canvas->drawTextOnPath(utf16.get(), strlen(text), minikin::Bidi::LTR, path, 0, 0, paint,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
void TestUtils::TestTask::run() {
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
for (int i = 0; i < 5; i++) {
|
||||
paint.setTextSize(10 + (frameNr % 20) + i * 20);
|
||||
canvas->drawText(text.get(), 0, textLength, textLength,
|
||||
0, 100 * (i + 2), minikin::kBidi_Force_LTR, paint, nullptr);
|
||||
0, 100 * (i + 2), minikin::Bidi::FORCE_LTR, paint, nullptr);
|
||||
}
|
||||
|
||||
container->setStagingDisplayList(canvas->finishRecording());
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
std::string offscreen = "offscreen line " + stri;
|
||||
std::unique_ptr<uint16_t[]> offtext = TestUtils::asciiToUtf16(offscreen.c_str());
|
||||
canvas.drawText(offtext.get(), 0, offscreen.length(), offscreen.length(),
|
||||
bounds.fLeft, top + padding, minikin::kBidi_Force_LTR, mBluePaint, nullptr);
|
||||
bounds.fLeft, top + padding, minikin::Bidi::FORCE_LTR, mBluePaint, nullptr);
|
||||
canvas.restore();
|
||||
|
||||
canvas.drawRect(bounds.fLeft, top + padding, bounds.fRight,
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
std::string onscreen = "onscreen line " + stri;
|
||||
std::unique_ptr<uint16_t[]> ontext = TestUtils::asciiToUtf16(onscreen.c_str());
|
||||
canvas.drawText(ontext.get(), 0, onscreen.length(), onscreen.length(), bounds.fLeft,
|
||||
top + smallRectHeight - padding, minikin::kBidi_Force_LTR, mGreenPaint,
|
||||
top + smallRectHeight - padding, minikin::Bidi::FORCE_LTR, mGreenPaint,
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -806,7 +806,7 @@ OPENGL_PIPELINE_TEST(RecordingCanvas, drawText) {
|
||||
paint.setTextSize(20);
|
||||
paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
|
||||
std::unique_ptr<uint16_t[]> dst = TestUtils::asciiToUtf16("HELLO");
|
||||
canvas.drawText(dst.get(), 0, 5, 5, 25, 25, minikin::kBidi_Force_LTR, paint, NULL);
|
||||
canvas.drawText(dst.get(), 0, 5, 5, 25, 25, minikin::Bidi::FORCE_LTR, paint, NULL);
|
||||
});
|
||||
|
||||
int count = 0;
|
||||
@@ -830,7 +830,7 @@ OPENGL_PIPELINE_TEST(RecordingCanvas, drawTextInHighContrast) {
|
||||
paint.setTextSize(20);
|
||||
paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
|
||||
std::unique_ptr<uint16_t[]> dst = TestUtils::asciiToUtf16("HELLO");
|
||||
canvas.drawText(dst.get(), 0, 5, 5, 25, 25, minikin::kBidi_Force_LTR, paint, NULL);
|
||||
canvas.drawText(dst.get(), 0, 5, 5, 25, 25, minikin::Bidi::FORCE_LTR, paint, NULL);
|
||||
});
|
||||
Properties::enableHighContrastText = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user