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

Commit 0bd4a945 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "WindowlessViewRoot: Add transparency and SurfaceInset support"

parents e6f339e5 3e722b14
Loading
Loading
Loading
Loading
+14 −1
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package android.view;
package android.view;


import android.content.res.Configuration;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.Rect;
import android.os.IBinder;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.RemoteException;
@@ -93,6 +94,14 @@ class WindowlessWindowManager implements IWindowSession {
    @Override
    @Override
    public void remove(android.view.IWindow window) {}
    public void remove(android.view.IWindow window) {}


    private boolean isOpaque(WindowManager.LayoutParams attrs) {
        if (attrs.surfaceInsets.left != 0 || attrs.surfaceInsets.top != 0 ||
                attrs.surfaceInsets.right != 0 || attrs.surfaceInsets.bottom != 0) {
            return false;
        }
        return !PixelFormat.formatHasAlpha(attrs.format);
    }

    @Override
    @Override
    public int relayout(IWindow window, int seq, WindowManager.LayoutParams attrs,
    public int relayout(IWindow window, int seq, WindowManager.LayoutParams attrs,
            int requestedWidth, int requestedHeight, int viewFlags, int flags, long frameNumber,
            int requestedWidth, int requestedHeight, int viewFlags, int flags, long frameNumber,
@@ -109,7 +118,11 @@ class WindowlessWindowManager implements IWindowSession {
                    "Invalid window token (never added or removed already)");
                    "Invalid window token (never added or removed already)");
        }
        }
        SurfaceControl.Transaction t = new SurfaceControl.Transaction();
        SurfaceControl.Transaction t = new SurfaceControl.Transaction();
        t.show(sc).setBufferSize(sc, requestedWidth, requestedHeight).apply();
        t.show(sc).setBufferSize(sc,
                requestedWidth + attrs.surfaceInsets.left + attrs.surfaceInsets.right,
                requestedHeight + attrs.surfaceInsets.top + attrs.surfaceInsets.bottom)
            .setOpaque(sc, isOpaque(attrs))
            .apply();
        outSurfaceControl.copyFrom(sc);
        outSurfaceControl.copyFrom(sc);
        outFrame.set(0, 0, requestedWidth, requestedHeight);
        outFrame.set(0, 0, requestedWidth, requestedHeight);