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

Commit fae7c2cc authored by Julien Chaffraix's avatar Julien Chaffraix Committed by Steve Kondik
Browse files

Add a color inversion algorithm to Android.

This flips the colors in the page (not including images) to use OLED's
lower power when displaying dark colors.

frameworks/base part of the change.

Change-Id: I250083c9c60cf68f906991252d81f0bbec32bc6e
parent 27f870c9
Loading
Loading
Loading
Loading
+18 −0
Original line number Original line Diff line number Diff line
@@ -178,6 +178,7 @@ public class WebSettings {
    private boolean         mUseWideViewport = false;
    private boolean         mUseWideViewport = false;
    private boolean         mSupportMultipleWindows = false;
    private boolean         mSupportMultipleWindows = false;
    private boolean         mShrinksStandaloneImagesToFit = false;
    private boolean         mShrinksStandaloneImagesToFit = false;
    private boolean         mInvertColor = false;
    // HTML5 API flags
    // HTML5 API flags
    private boolean         mAppCacheEnabled = false;
    private boolean         mAppCacheEnabled = false;
    private boolean         mDatabaseEnabled = false;
    private boolean         mDatabaseEnabled = false;
@@ -1387,6 +1388,23 @@ public class WebSettings {
        }
        }
     }
     }


    /**
     * @hide
     */
    public synchronized void setInvertColor(boolean invert) {
        if (mInvertColor != invert) {
            mInvertColor = invert;
            postSync();
        }
    }

    /**
     * @hide
     */
    public synchronized boolean getInvertColor() {
        return mInvertColor;
    }

    int getDoubleTapToastCount() {
    int getDoubleTapToastCount() {
        return mDoubleTapToastCount;
        return mDoubleTapToastCount;
    }
    }
+3 −0
Original line number Original line Diff line number Diff line
@@ -525,6 +525,8 @@ final class WebViewCore {


    private native void nativeSetBackgroundColor(int color);
    private native void nativeSetBackgroundColor(int color);


    private native void nativeSetColorInversion(boolean invert);

    private native void nativeDumpDomTree(boolean useFile);
    private native void nativeDumpDomTree(boolean useFile);


    private native void nativeDumpRenderTree(boolean useFile);
    private native void nativeDumpRenderTree(boolean useFile);
@@ -1792,6 +1794,7 @@ final class WebViewCore {
            df = mScrollFilter;
            df = mScrollFilter;
        }
        }
        canvas.setDrawFilter(df);
        canvas.setDrawFilter(df);
        nativeSetColorInversion(mSettings.getInvertColor());
        boolean tookTooLong = nativeDrawContent(canvas, color);
        boolean tookTooLong = nativeDrawContent(canvas, color);
        canvas.setDrawFilter(null);
        canvas.setDrawFilter(null);
        if (tookTooLong && mSplitPictureIsScheduled == false) {
        if (tookTooLong && mSplitPictureIsScheduled == false) {