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

Commit ef3443f2 authored by Winson Chung's avatar Winson Chung
Browse files

Keep PIP screenshot layer below input consumer layer

Fixes: 188830778
Test: Resize w/o seamless resizing and try touching the PIP
Change-Id: I55c45fc670cd3acc3b674809eb3afea626f34f06
parent 5eef4114
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -32,11 +32,12 @@ public class ScreenshotUtils {
     * @param t the transaction used to set changes on the resulting screenshot.
     * @param t the transaction used to set changes on the resulting screenshot.
     * @param sc the SurfaceControl to take a screenshot of
     * @param sc the SurfaceControl to take a screenshot of
     * @param crop the crop to use when capturing the screenshot
     * @param crop the crop to use when capturing the screenshot
     * @param layer the layer to place the screenshot
     *
     *
     * @return A SurfaceControl where the screenshot will be attached, or null if failed.
     * @return A SurfaceControl where the screenshot will be attached, or null if failed.
     */
     */
    public static SurfaceControl takeScreenshot(SurfaceControl.Transaction t, SurfaceControl sc,
    public static SurfaceControl takeScreenshot(SurfaceControl.Transaction t, SurfaceControl sc,
            Rect crop) {
            Rect crop, int layer) {
        final SurfaceControl.ScreenshotHardwareBuffer buffer = SurfaceControl.captureLayers(
        final SurfaceControl.ScreenshotHardwareBuffer buffer = SurfaceControl.captureLayers(
                new SurfaceControl.LayerCaptureArgs.Builder(sc)
                new SurfaceControl.LayerCaptureArgs.Builder(sc)
                        .setSourceCrop(crop)
                        .setSourceCrop(crop)
@@ -60,7 +61,7 @@ public class ScreenshotUtils {
        t.setBuffer(screenshot, graphicBuffer);
        t.setBuffer(screenshot, graphicBuffer);
        t.setColorSpace(screenshot, buffer.getColorSpace());
        t.setColorSpace(screenshot, buffer.getColorSpace());
        t.reparent(screenshot, sc);
        t.reparent(screenshot, sc);
        t.setLayer(screenshot, Integer.MAX_VALUE);
        t.setLayer(screenshot, layer);
        t.show(screenshot);
        t.show(screenshot);
        t.apply();
        t.apply();
        return screenshot;
        return screenshot;
+4 −1
Original line number Original line Diff line number Diff line
@@ -1159,8 +1159,11 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
            preResizeBounds.offsetTo(0, 0);
            preResizeBounds.offsetTo(0, 0);
            final Rect snapshotDest = new Rect(0, 0, destinationBounds.width(),
            final Rect snapshotDest = new Rect(0, 0, destinationBounds.width(),
                    destinationBounds.height());
                    destinationBounds.height());
            // Note: Put this at layer=MAX_VALUE-2 since the input consumer for PIP is placed at
            //       MAX_VALUE-1
            final SurfaceControl snapshotSurface = ScreenshotUtils.takeScreenshot(
            final SurfaceControl snapshotSurface = ScreenshotUtils.takeScreenshot(
                    mSurfaceControlTransactionFactory.getTransaction(), mLeash, preResizeBounds);
                    mSurfaceControlTransactionFactory.getTransaction(), mLeash, preResizeBounds,
                    Integer.MAX_VALUE - 2);
            if (snapshotSurface != null) {
            if (snapshotSurface != null) {
                mSyncTransactionQueue.queue(wct);
                mSyncTransactionQueue.queue(wct);
                mSyncTransactionQueue.runInSync(t -> {
                mSyncTransactionQueue.runInSync(t -> {