Loading core/java/android/view/DisplayListCanvas.java +14 −0 Original line number Diff line number Diff line Loading @@ -147,10 +147,24 @@ public class DisplayListCanvas extends Canvas { private static native int nGetMaximumTextureWidth(); private static native int nGetMaximumTextureHeight(); /** * Returns the native OpenGLRenderer object. */ long getRenderer() { return mNativeCanvasWrapper; } /////////////////////////////////////////////////////////////////////////// // Setup /////////////////////////////////////////////////////////////////////////// @Override public void setHighContrastText(boolean highContrastText) { nSetHighContrastText(mNativeCanvasWrapper, highContrastText); } private static native void nSetHighContrastText(long renderer, boolean highContrastText); @Override public void insertReorderBarrier() { nInsertReorderBarrier(mNativeCanvasWrapper, true); Loading core/jni/android_graphics_Canvas.cpp +3 −42 Original line number Diff line number Diff line Loading @@ -69,11 +69,6 @@ static jint getHeight(JNIEnv*, jobject, jlong canvasHandle) { return static_cast<jint>(get_canvas(canvasHandle)->height()); } static void setHighContrastText(JNIEnv*, jobject, jlong canvasHandle, jboolean highContrastText) { Canvas* canvas = get_canvas(canvasHandle); canvas->setHighContrastText(highContrastText); } static jint getSaveCount(JNIEnv*, jobject, jlong canvasHandle) { return static_cast<jint>(get_canvas(canvasHandle)->getSaveCount()); } Loading Loading @@ -435,16 +430,6 @@ static void drawBitmapMesh(JNIEnv* env, jobject, jlong canvasHandle, jobject jbi vertA.ptr(), colorA.ptr(), paint); } static void simplifyPaint(int color, SkPaint* paint) { paint->setColor(color); paint->setShader(nullptr); paint->setColorFilter(nullptr); paint->setLooper(nullptr); paint->setStrokeWidth(4 + 0.04 * paint->getTextSize()); paint->setStrokeJoin(SkPaint::kRound_Join); paint->setLooper(nullptr); } class DrawTextFunctor { public: DrawTextFunctor(const Layout& layout, Canvas* canvas, uint16_t* glyphs, float* pos, Loading @@ -469,33 +454,10 @@ public: } size_t glyphCount = end - start; if (CC_UNLIKELY(canvas->isHighContrastText())) { // high contrast draw path int color = paint.getColor(); int channelSum = SkColorGetR(color) + SkColorGetG(color) + SkColorGetB(color); bool darken = channelSum < (128 * 3); // outline SkPaint outlinePaint(paint); simplifyPaint(darken ? SK_ColorWHITE : SK_ColorBLACK, &outlinePaint); outlinePaint.setStyle(SkPaint::kStrokeAndFill_Style); canvas->drawText(glyphs + start, pos + (2 * start), glyphCount, outlinePaint, x, y, bounds.mLeft, bounds.mTop, bounds.mRight, bounds.mBottom, totalAdvance); // inner SkPaint innerPaint(paint); simplifyPaint(darken ? SK_ColorBLACK : SK_ColorWHITE, &innerPaint); innerPaint.setStyle(SkPaint::kFill_Style); canvas->drawText(glyphs + start, pos + (2 * start), glyphCount, innerPaint, x, y, bounds.mLeft, bounds.mTop, bounds.mRight, bounds.mBottom, totalAdvance); } else { // standard draw path canvas->drawText(glyphs + start, pos + (2 * start), glyphCount, paint, x, y, bounds.mLeft, bounds.mTop, bounds.mRight, bounds.mBottom, totalAdvance); } } private: const Layout& layout; Canvas* canvas; Loading Loading @@ -717,7 +679,6 @@ static JNINativeMethod gMethods[] = { {"native_isOpaque","(J)Z", (void*) CanvasJNI::isOpaque}, {"native_getWidth","(J)I", (void*) CanvasJNI::getWidth}, {"native_getHeight","(J)I", (void*) CanvasJNI::getHeight}, {"native_setHighContrastText","(JZ)V", (void*) CanvasJNI::setHighContrastText}, {"native_save","(JI)I", (void*) CanvasJNI::save}, {"native_saveLayer","(JFFFFJI)I", (void*) CanvasJNI::saveLayer}, {"native_saveLayerAlpha","(JFFFFII)I", (void*) CanvasJNI::saveLayerAlpha}, Loading graphics/java/android/graphics/Canvas.java +1 −4 Original line number Diff line number Diff line Loading @@ -215,9 +215,7 @@ public class Canvas { } /** @hide */ public void setHighContrastText(boolean highContrastText) { native_setHighContrastText(mNativeCanvasWrapper, highContrastText); } public void setHighContrastText(boolean highContrastText) {} /** @hide */ public void insertReorderBarrier() {} Loading Loading @@ -1976,7 +1974,6 @@ public class Canvas { private static native void native_setBitmap(long canvasHandle, Bitmap bitmap); private static native boolean native_isOpaque(long canvasHandle); private static native void native_setHighContrastText(long renderer, boolean highContrastText); private static native int native_getWidth(long canvasHandle); private static native int native_getHeight(long canvasHandle); Loading libs/hwui/Canvas.h +0 −3 Original line number Diff line number Diff line Loading @@ -62,9 +62,6 @@ public: virtual int width() = 0; virtual int height() = 0; virtual void setHighContrastText(bool highContrastText) = 0; virtual bool isHighContrastText() = 0; // ---------------------------------------------------------------------------- // Canvas state operations // ---------------------------------------------------------------------------- Loading libs/hwui/DisplayListCanvas.cpp +35 −3 Original line number Diff line number Diff line Loading @@ -437,6 +437,16 @@ void DisplayListCanvas::drawPosText(const uint16_t* text, const float* positions addDrawOp(op); } static void simplifyPaint(int color, SkPaint* paint) { paint->setColor(color); paint->setShader(nullptr); paint->setColorFilter(nullptr); paint->setLooper(nullptr); paint->setStrokeWidth(4 + 0.04 * paint->getTextSize()); paint->setStrokeJoin(SkPaint::kRound_Join); paint->setLooper(nullptr); } void DisplayListCanvas::drawText(const uint16_t* glyphs, const float* positions, int count, const SkPaint& paint, float x, float y, float boundsLeft, float boundsTop, float boundsRight, float boundsBottom, Loading @@ -449,10 +459,32 @@ void DisplayListCanvas::drawText(const uint16_t* glyphs, const float* positions, positions = refBuffer<float>(positions, count * 2); Rect bounds(boundsLeft, boundsTop, boundsRight, boundsBottom); if (CC_UNLIKELY(mHighContrastText)) { // high contrast draw path int color = paint.getColor(); int channelSum = SkColorGetR(color) + SkColorGetG(color) + SkColorGetB(color); bool darken = channelSum < (128 * 3); // outline SkPaint* outlinePaint = copyPaint(&paint); simplifyPaint(darken ? SK_ColorWHITE : SK_ColorBLACK, outlinePaint); outlinePaint->setStyle(SkPaint::kStrokeAndFill_Style); addDrawOp(new (alloc()) DrawTextOp(text, bytesCount, count, x, y, positions, outlinePaint, totalAdvance, bounds)); // bounds? // inner SkPaint* innerPaint = copyPaint(&paint); simplifyPaint(darken ? SK_ColorBLACK : SK_ColorWHITE, innerPaint); innerPaint->setStyle(SkPaint::kFill_Style); addDrawOp(new (alloc()) DrawTextOp(text, bytesCount, count, x, y, positions, innerPaint, totalAdvance, bounds)); } else { // standard draw path DrawOp* op = new (alloc()) DrawTextOp(text, bytesCount, count, x, y, positions, refPaint(&paint), totalAdvance, bounds); addDrawOp(op); } } void DisplayListCanvas::drawRegion(const SkRegion& region, const SkPaint& paint) { if (paint.getStyle() != SkPaint::kFill_Style || Loading Loading
core/java/android/view/DisplayListCanvas.java +14 −0 Original line number Diff line number Diff line Loading @@ -147,10 +147,24 @@ public class DisplayListCanvas extends Canvas { private static native int nGetMaximumTextureWidth(); private static native int nGetMaximumTextureHeight(); /** * Returns the native OpenGLRenderer object. */ long getRenderer() { return mNativeCanvasWrapper; } /////////////////////////////////////////////////////////////////////////// // Setup /////////////////////////////////////////////////////////////////////////// @Override public void setHighContrastText(boolean highContrastText) { nSetHighContrastText(mNativeCanvasWrapper, highContrastText); } private static native void nSetHighContrastText(long renderer, boolean highContrastText); @Override public void insertReorderBarrier() { nInsertReorderBarrier(mNativeCanvasWrapper, true); Loading
core/jni/android_graphics_Canvas.cpp +3 −42 Original line number Diff line number Diff line Loading @@ -69,11 +69,6 @@ static jint getHeight(JNIEnv*, jobject, jlong canvasHandle) { return static_cast<jint>(get_canvas(canvasHandle)->height()); } static void setHighContrastText(JNIEnv*, jobject, jlong canvasHandle, jboolean highContrastText) { Canvas* canvas = get_canvas(canvasHandle); canvas->setHighContrastText(highContrastText); } static jint getSaveCount(JNIEnv*, jobject, jlong canvasHandle) { return static_cast<jint>(get_canvas(canvasHandle)->getSaveCount()); } Loading Loading @@ -435,16 +430,6 @@ static void drawBitmapMesh(JNIEnv* env, jobject, jlong canvasHandle, jobject jbi vertA.ptr(), colorA.ptr(), paint); } static void simplifyPaint(int color, SkPaint* paint) { paint->setColor(color); paint->setShader(nullptr); paint->setColorFilter(nullptr); paint->setLooper(nullptr); paint->setStrokeWidth(4 + 0.04 * paint->getTextSize()); paint->setStrokeJoin(SkPaint::kRound_Join); paint->setLooper(nullptr); } class DrawTextFunctor { public: DrawTextFunctor(const Layout& layout, Canvas* canvas, uint16_t* glyphs, float* pos, Loading @@ -469,33 +454,10 @@ public: } size_t glyphCount = end - start; if (CC_UNLIKELY(canvas->isHighContrastText())) { // high contrast draw path int color = paint.getColor(); int channelSum = SkColorGetR(color) + SkColorGetG(color) + SkColorGetB(color); bool darken = channelSum < (128 * 3); // outline SkPaint outlinePaint(paint); simplifyPaint(darken ? SK_ColorWHITE : SK_ColorBLACK, &outlinePaint); outlinePaint.setStyle(SkPaint::kStrokeAndFill_Style); canvas->drawText(glyphs + start, pos + (2 * start), glyphCount, outlinePaint, x, y, bounds.mLeft, bounds.mTop, bounds.mRight, bounds.mBottom, totalAdvance); // inner SkPaint innerPaint(paint); simplifyPaint(darken ? SK_ColorBLACK : SK_ColorWHITE, &innerPaint); innerPaint.setStyle(SkPaint::kFill_Style); canvas->drawText(glyphs + start, pos + (2 * start), glyphCount, innerPaint, x, y, bounds.mLeft, bounds.mTop, bounds.mRight, bounds.mBottom, totalAdvance); } else { // standard draw path canvas->drawText(glyphs + start, pos + (2 * start), glyphCount, paint, x, y, bounds.mLeft, bounds.mTop, bounds.mRight, bounds.mBottom, totalAdvance); } } private: const Layout& layout; Canvas* canvas; Loading Loading @@ -717,7 +679,6 @@ static JNINativeMethod gMethods[] = { {"native_isOpaque","(J)Z", (void*) CanvasJNI::isOpaque}, {"native_getWidth","(J)I", (void*) CanvasJNI::getWidth}, {"native_getHeight","(J)I", (void*) CanvasJNI::getHeight}, {"native_setHighContrastText","(JZ)V", (void*) CanvasJNI::setHighContrastText}, {"native_save","(JI)I", (void*) CanvasJNI::save}, {"native_saveLayer","(JFFFFJI)I", (void*) CanvasJNI::saveLayer}, {"native_saveLayerAlpha","(JFFFFII)I", (void*) CanvasJNI::saveLayerAlpha}, Loading
graphics/java/android/graphics/Canvas.java +1 −4 Original line number Diff line number Diff line Loading @@ -215,9 +215,7 @@ public class Canvas { } /** @hide */ public void setHighContrastText(boolean highContrastText) { native_setHighContrastText(mNativeCanvasWrapper, highContrastText); } public void setHighContrastText(boolean highContrastText) {} /** @hide */ public void insertReorderBarrier() {} Loading Loading @@ -1976,7 +1974,6 @@ public class Canvas { private static native void native_setBitmap(long canvasHandle, Bitmap bitmap); private static native boolean native_isOpaque(long canvasHandle); private static native void native_setHighContrastText(long renderer, boolean highContrastText); private static native int native_getWidth(long canvasHandle); private static native int native_getHeight(long canvasHandle); Loading
libs/hwui/Canvas.h +0 −3 Original line number Diff line number Diff line Loading @@ -62,9 +62,6 @@ public: virtual int width() = 0; virtual int height() = 0; virtual void setHighContrastText(bool highContrastText) = 0; virtual bool isHighContrastText() = 0; // ---------------------------------------------------------------------------- // Canvas state operations // ---------------------------------------------------------------------------- Loading
libs/hwui/DisplayListCanvas.cpp +35 −3 Original line number Diff line number Diff line Loading @@ -437,6 +437,16 @@ void DisplayListCanvas::drawPosText(const uint16_t* text, const float* positions addDrawOp(op); } static void simplifyPaint(int color, SkPaint* paint) { paint->setColor(color); paint->setShader(nullptr); paint->setColorFilter(nullptr); paint->setLooper(nullptr); paint->setStrokeWidth(4 + 0.04 * paint->getTextSize()); paint->setStrokeJoin(SkPaint::kRound_Join); paint->setLooper(nullptr); } void DisplayListCanvas::drawText(const uint16_t* glyphs, const float* positions, int count, const SkPaint& paint, float x, float y, float boundsLeft, float boundsTop, float boundsRight, float boundsBottom, Loading @@ -449,10 +459,32 @@ void DisplayListCanvas::drawText(const uint16_t* glyphs, const float* positions, positions = refBuffer<float>(positions, count * 2); Rect bounds(boundsLeft, boundsTop, boundsRight, boundsBottom); if (CC_UNLIKELY(mHighContrastText)) { // high contrast draw path int color = paint.getColor(); int channelSum = SkColorGetR(color) + SkColorGetG(color) + SkColorGetB(color); bool darken = channelSum < (128 * 3); // outline SkPaint* outlinePaint = copyPaint(&paint); simplifyPaint(darken ? SK_ColorWHITE : SK_ColorBLACK, outlinePaint); outlinePaint->setStyle(SkPaint::kStrokeAndFill_Style); addDrawOp(new (alloc()) DrawTextOp(text, bytesCount, count, x, y, positions, outlinePaint, totalAdvance, bounds)); // bounds? // inner SkPaint* innerPaint = copyPaint(&paint); simplifyPaint(darken ? SK_ColorBLACK : SK_ColorWHITE, innerPaint); innerPaint->setStyle(SkPaint::kFill_Style); addDrawOp(new (alloc()) DrawTextOp(text, bytesCount, count, x, y, positions, innerPaint, totalAdvance, bounds)); } else { // standard draw path DrawOp* op = new (alloc()) DrawTextOp(text, bytesCount, count, x, y, positions, refPaint(&paint), totalAdvance, bounds); addDrawOp(op); } } void DisplayListCanvas::drawRegion(const SkRegion& region, const SkPaint& paint) { if (paint.getStyle() != SkPaint::kFill_Style || Loading