Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 938e884a authored by John Reck's avatar John Reck
Browse files

Avoid setting high contrast in every view draw

Test: high contrast text still works
Change-Id: I6674d1aca8dddf7eb9725a5346aed12ef1dbc195
parent 3a580256
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -51,7 +51,6 @@ public class CanvasPerfTest {

        while (state.keepRunning()) {
            canvas = node.start(200, 200);
            canvas.setHighContrastText(false);
            int save = canvas.save();
            canvas.clipRect(1, 1, 199, 199);
            canvas.insertReorderBarrier();
+9 −0
Original line number Diff line number Diff line
@@ -914,6 +914,14 @@ public final class ThreadedRenderer {
        return nCreateHardwareBitmap(node.getNativeDisplayList(), width, height);
    }

    /**
     * Sets whether or not high contrast text rendering is enabled. The setting is global
     * but only affects content rendered after the change is made.
     */
    public static void setHighContrastText(boolean highContrastText) {
        nSetHighContrastText(highContrastText);
    }

    @Override
    protected void finalize() throws Throwable {
        try {
@@ -1063,4 +1071,5 @@ public final class ThreadedRenderer {
            int srcLeft, int srcTop, int srcRight, int srcBottom, Bitmap bitmap);

    private static native Bitmap nCreateHardwareBitmap(long renderNode, int width, int height);
    private static native void nSetHighContrastText(boolean enabled);
}
+0 −6
Original line number Diff line number Diff line
@@ -18055,7 +18055,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            int layerType = getLayerType();
            final DisplayListCanvas canvas = renderNode.start(width, height);
            canvas.setHighContrastText(mAttachInfo.mHighContrastText);
            try {
                if (layerType == LAYER_TYPE_SOFTWARE) {
@@ -25364,11 +25363,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
         */
        boolean mViewScrollChanged;
        /**
         * Set to true if high contrast mode enabled
         */
        boolean mHighContrastText;
        /**
         * Set to true if a pointer event is currently being handled.
         */
+2 −2
Original line number Diff line number Diff line
@@ -7741,11 +7741,11 @@ public final class ViewRootImpl implements ViewParent,

    final class HighContrastTextManager implements HighTextContrastChangeListener {
        HighContrastTextManager() {
            mAttachInfo.mHighContrastText = mAccessibilityManager.isHighTextContrastEnabled();
            ThreadedRenderer.setHighContrastText(mAccessibilityManager.isHighTextContrastEnabled());
        }
        @Override
        public void onHighTextContrastStateChanged(boolean enabled) {
            mAttachInfo.mHighContrastText = enabled;
            ThreadedRenderer.setHighContrastText(enabled);

            // Destroy Displaylists so they can be recreated with high contrast recordings
            destroyHardwareResources();
+0 −6
Original line number Diff line number Diff line
@@ -77,11 +77,6 @@ static jint getHeight(jlong canvasHandle) {
    return static_cast<jint>(get_canvas(canvasHandle)->height());
}

static void setHighContrastText(jlong canvasHandle, jboolean highContrastText) {
    Canvas* canvas = get_canvas(canvasHandle);
    canvas->setHighContrastText(highContrastText);
}

static jint save(jlong canvasHandle, jint flagsHandle) {
    SaveFlags::Flags flags = static_cast<SaveFlags::Flags>(flagsHandle);
    return static_cast<jint>(get_canvas(canvasHandle)->save(flags));
@@ -588,7 +583,6 @@ static const JNINativeMethod gMethods[] = {
    {"nIsOpaque","(J)Z", (void*) CanvasJNI::isOpaque},
    {"nGetWidth","(J)I", (void*) CanvasJNI::getWidth},
    {"nGetHeight","(J)I", (void*) CanvasJNI::getHeight},
    {"nSetHighContrastText","(JZ)V", (void*) CanvasJNI::setHighContrastText},
    {"nSave","(JI)I", (void*) CanvasJNI::save},
    {"nSaveLayer","(JFFFFJI)I", (void*) CanvasJNI::saveLayer},
    {"nSaveLayerAlpha","(JFFFFII)I", (void*) CanvasJNI::saveLayerAlpha},
Loading