diff options
Diffstat (limited to 'core/jni/android')
-rw-r--r-- | core/jni/android/graphics/Shader.cpp | 8 | ||||
-rw-r--r-- | core/jni/android/graphics/TextLayout.cpp | 18 | ||||
-rw-r--r-- | core/jni/android/graphics/TextLayout.h | 3 |
3 files changed, 21 insertions, 8 deletions
diff --git a/core/jni/android/graphics/Shader.cpp b/core/jni/android/graphics/Shader.cpp index 2b98e89..36413d7 100644 --- a/core/jni/android/graphics/Shader.cpp +++ b/core/jni/android/graphics/Shader.cpp @@ -149,7 +149,9 @@ static SkiaShader* LinearGradient_postCreate1(JNIEnv* env, jobject o, SkShader* storedBounds[2] = x1; storedBounds[3] = y1; jfloat* storedPositions = new jfloat[count]; uint32_t* storedColors = new uint32_t[count]; - memcpy(storedColors, colorValues, count); + for (size_t i = 0; i < count; i++) { + storedColors[i] = static_cast<uint32_t>(colorValues[i]); + } if (posArray) { AutoJavaFloatArray autoPos(env, posArray, count); @@ -185,8 +187,8 @@ static SkiaShader* LinearGradient_postCreate2(JNIEnv* env, jobject o, SkShader* storedPositions[1] = 1.0f; uint32_t* storedColors = new uint32_t[2]; - storedColors[0] = color0; - storedColors[1] = color1; + storedColors[0] = static_cast<uint32_t>(color0); + storedColors[1] = static_cast<uint32_t>(color1); SkiaShader* skiaShader = new SkiaLinearGradientShader(storedBounds, storedColors, storedPositions, 2, shader, static_cast<SkShader::TileMode>(tileMode), NULL, diff --git a/core/jni/android/graphics/TextLayout.cpp b/core/jni/android/graphics/TextLayout.cpp index 716d960..147e1fa 100644 --- a/core/jni/android/graphics/TextLayout.cpp +++ b/core/jni/android/graphics/TextLayout.cpp @@ -221,6 +221,18 @@ void TextLayout::handleText(SkPaint *paint, const jchar* text, jsize len, } } +bool TextLayout::prepareRtlTextRun(const jchar* context, jsize start, jsize& count, + jsize contextCount, jchar* shaped) { + UErrorCode status = U_ZERO_ERROR; + count = shapeRtlText(context, start, count, contextCount, shaped, status); + if (U_SUCCESS(status)) { + return true; + } else { + LOG(LOG_WARN, "LAYOUT", "drawTextRun error %d\n", status); + } + return false; +} + void TextLayout::drawTextRun(SkPaint* paint, const jchar* chars, jint start, jint count, jint contextCount, int dirFlags, jfloat x, jfloat y, SkCanvas* canvas) { @@ -231,12 +243,8 @@ void TextLayout::drawTextRun(SkPaint* paint, const jchar* chars, uint8_t rtl = dirFlags & 0x1; if (rtl) { SkAutoSTMalloc<80, jchar> buffer(contextCount); - UErrorCode status = U_ZERO_ERROR; - count = shapeRtlText(chars, start, count, contextCount, buffer.get(), status); - if (U_SUCCESS(status)) { + if (prepareRtlTextRun(chars, start, count, contextCount, buffer.get())) { canvas->drawText(buffer.get(), count << 1, x_, y_, *paint); - } else { - LOG(LOG_WARN, "LAYOUT", "drawTextRun error %d\n", status); } } else { canvas->drawText(chars + start, count << 1, x_, y_, *paint); diff --git a/core/jni/android/graphics/TextLayout.h b/core/jni/android/graphics/TextLayout.h index 3d05e18..8f666c0 100644 --- a/core/jni/android/graphics/TextLayout.h +++ b/core/jni/android/graphics/TextLayout.h @@ -66,6 +66,9 @@ public: static bool prepareText(SkPaint *paint, const jchar* text, jsize len, jint bidiFlags, const jchar** outText, int32_t* outBytes, jchar** outBuffer); + static bool prepareRtlTextRun(const jchar* context, jsize start, jsize& count, + jsize contextCount, jchar* shaped); + private: static bool needsLayout(const jchar* text, jint len, jint bidiFlags); |