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

Commit e597d5f9 authored by Michael Kolb's avatar Michael Kolb Committed by Android (Google) Code Review
Browse files

Merge "Use rotation to position circular display mask" into klp-modular-dev

parents aed314e8 8b275ca9
Loading
Loading
Loading
Loading
+23 −3
Original line number Original line Diff line number Diff line
@@ -22,7 +22,6 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.Rect;
import android.util.Log;
import android.view.Display;
import android.view.Display;
import android.view.Surface;
import android.view.Surface;
import android.view.Surface.OutOfResourcesException;
import android.view.Surface.OutOfResourcesException;
@@ -40,6 +39,7 @@ class CircularDisplayMask {
    private int mLastDH;
    private int mLastDH;
    private boolean mDrawNeeded;
    private boolean mDrawNeeded;
    private Paint mPaint;
    private Paint mPaint;
    private int mRotation;


    public CircularDisplayMask(Display display, SurfaceSession session, int zOrder) {
    public CircularDisplayMask(Display display, SurfaceSession session, int zOrder) {
        SurfaceControl ctrl = null;
        SurfaceControl ctrl = null;
@@ -78,7 +78,26 @@ class CircularDisplayMask {
        if (c == null) {
        if (c == null) {
            return;
            return;
        }
        }
        c.drawCircle(160, 160, 160, mPaint);
        int cx = 160;
        int cy = 160;
        switch (mRotation) {
            case Surface.ROTATION_0:
            case Surface.ROTATION_90:
                // chin bottom or right
                cx = 160;
                cy = 160;
                break;
            case Surface.ROTATION_180:
                // chin top
                cx = 160;
                cy = 145;
                break;
            case Surface.ROTATION_270:
                cx = 145;
                cy = 160;
                break;
        }
        c.drawCircle(cx, cy, 160, mPaint);


        mSurface.unlockCanvasAndPost(c);
        mSurface.unlockCanvasAndPost(c);
    }
    }
@@ -97,7 +116,7 @@ class CircularDisplayMask {
        }
        }
    }
    }


    void positionSurface(int dw, int dh) {
    void positionSurface(int dw, int dh, int rotation) {
        if (mLastDW == dw && mLastDH == dh) {
        if (mLastDW == dw && mLastDH == dh) {
            return;
            return;
        }
        }
@@ -105,6 +124,7 @@ class CircularDisplayMask {
        mLastDH = dh;
        mLastDH = dh;
        mSurfaceControl.setSize(dw, dh);
        mSurfaceControl.setSize(dw, dh);
        mDrawNeeded = true;
        mDrawNeeded = true;
        mRotation = rotation;
    }
    }


}
}
+4 −4
Original line number Original line Diff line number Diff line
@@ -290,8 +290,6 @@ public class WindowManagerService extends IWindowManager.Stub
    private static final String DENSITY_OVERRIDE = "ro.config.density_override";
    private static final String DENSITY_OVERRIDE = "ro.config.density_override";
    private static final String SIZE_OVERRIDE = "ro.config.size_override";
    private static final String SIZE_OVERRIDE = "ro.config.size_override";


    private static final String SCREEN_CIRCULAR = "ro.display.circular";

    private static final int MAX_SCREENSHOT_RETRIES = 3;
    private static final int MAX_SCREENSHOT_RETRIES = 3;


    final private KeyguardDisableHandler mKeyguardDisableHandler;
    final private KeyguardDisableHandler mKeyguardDisableHandler;
@@ -5552,7 +5550,9 @@ public class WindowManagerService extends IWindowManager.Stub
    }
    }


    public void showCircularDisplayMaskIfNeeded() {
    public void showCircularDisplayMaskIfNeeded() {
        if (SystemProperties.getBoolean(SCREEN_CIRCULAR, false)) {
        // we're fullscreen and not hosted in an ActivityView
        if (mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_windowIsRound)) {
            mH.sendMessage(mH.obtainMessage(H.SHOW_DISPLAY_MASK));
            mH.sendMessage(mH.obtainMessage(H.SHOW_DISPLAY_MASK));
        }
        }
    }
    }
@@ -9077,7 +9077,7 @@ public class WindowManagerService extends IWindowManager.Stub
                mStrictModeFlash.positionSurface(defaultDw, defaultDh);
                mStrictModeFlash.positionSurface(defaultDw, defaultDh);
            }
            }
            if (mCircularDisplayMask != null) {
            if (mCircularDisplayMask != null) {
                mCircularDisplayMask.positionSurface(defaultDw, defaultDh);
                mCircularDisplayMask.positionSurface(defaultDw, defaultDh, mRotation);
            }
            }


            boolean focusDisplayed = false;
            boolean focusDisplayed = false;