Fix text corruption when rendering RTL enabled text.
Change-Id: I5450fd9cad1c5a66875affdbcd34308aea4c36ac
This commit is contained in:
@@ -151,7 +151,7 @@ jint TextLayout::layoutLine(const jchar* text, jint len, jint flags, int &dir, j
|
||||
}
|
||||
|
||||
bool TextLayout::prepareText(SkPaint *paint, const jchar* text, jsize len, jint bidiFlags,
|
||||
const jchar** outText, int32_t* outBytes) {
|
||||
const jchar** outText, int32_t* outBytes, jchar** outBuffer) {
|
||||
const jchar *workText = text;
|
||||
jchar *buffer = NULL;
|
||||
int dir = kDirection_LTR;
|
||||
@@ -196,8 +196,8 @@ bool TextLayout::prepareText(SkPaint *paint, const jchar* text, jsize len, jint
|
||||
|
||||
*outBytes = (workLimit - workText) << 1;
|
||||
*outText = workText;
|
||||
|
||||
free(buffer);
|
||||
*outBuffer = buffer;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -207,8 +207,9 @@ bool TextLayout::prepareText(SkPaint *paint, const jchar* text, jsize len, jint
|
||||
void TextLayout::handleText(SkPaint *paint, const jchar* text, jsize len,
|
||||
jint bidiFlags, jfloat x, jfloat y,SkCanvas *canvas, SkPath *path) {
|
||||
const jchar *workText;
|
||||
jchar *buffer = NULL;
|
||||
int32_t workBytes;
|
||||
if (prepareText(paint, text, len, bidiFlags, &workText, &workBytes)) {
|
||||
if (prepareText(paint, text, len, bidiFlags, &workText, &workBytes, &buffer)) {
|
||||
SkScalar x_ = SkFloatToScalar(x);
|
||||
SkScalar y_ = SkFloatToScalar(y);
|
||||
if (canvas) {
|
||||
@@ -216,6 +217,7 @@ void TextLayout::handleText(SkPaint *paint, const jchar* text, jsize len,
|
||||
} else {
|
||||
paint->getTextPath(workText, workBytes, x_, y_, path);
|
||||
}
|
||||
free(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
SkPath* path, SkCanvas* canvas);
|
||||
|
||||
static bool prepareText(SkPaint *paint, const jchar* text, jsize len, jint bidiFlags,
|
||||
const jchar** outText, int32_t* outBytes);
|
||||
const jchar** outText, int32_t* outBytes, jchar** outBuffer);
|
||||
|
||||
private:
|
||||
static bool needsLayout(const jchar* text, jint len, jint bidiFlags);
|
||||
|
||||
@@ -256,9 +256,11 @@ static void android_view_GLES20Canvas_setupLinearShader(JNIEnv* env, jobject can
|
||||
static void renderText(OpenGLRenderer* renderer, const jchar* text, int count,
|
||||
jfloat x, jfloat y, int flags, SkPaint* paint) {
|
||||
const jchar *workText;
|
||||
jchar* buffer = NULL;
|
||||
int32_t workBytes;
|
||||
if (TextLayout::prepareText(paint, text, count, flags, &workText, &workBytes)) {
|
||||
if (TextLayout::prepareText(paint, text, count, flags, &workText, &workBytes, &buffer)) {
|
||||
renderer->drawText((const char*) workText, workBytes, count, x, y, paint);
|
||||
free(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user