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

Commit c6e4acc2 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Consider window background opacity when determining snapshot translucency" into pi-dev

parents 5d4678e9 02378b43
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2177,7 +2177,8 @@ public class ActivityManager {
        }

        /**
         * @return Whether or not the snapshot is of a translucent app window.
         * @return Whether or not the snapshot is of a translucent app window (non-fullscreen or has
         * a non-opaque pixel format).
         */
        public boolean isTranslucent() {
            return mIsTranslucent;
+6 −3
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.app.ActivityManager.TaskSnapshot;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.GraphicBuffer;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.os.Environment;
import android.os.Handler;
@@ -266,7 +267,7 @@ class TaskSnapshotController {

        final GraphicBuffer buffer = SurfaceControl.captureLayers(
                task.getSurfaceControl().getHandle(), mTmpRect, scaleFraction);

        final boolean isWindowTranslucent = mainWindow.getAttrs().format != PixelFormat.OPAQUE;
        if (buffer == null || buffer.getWidth() <= 1 || buffer.getHeight() <= 1) {
            if (DEBUG_SCREENSHOT) {
                Slog.w(TAG_WM, "Failed to take screenshot for " + task);
@@ -276,7 +277,7 @@ class TaskSnapshotController {
        return new TaskSnapshot(buffer, top.getConfiguration().orientation,
                getInsets(mainWindow), isLowRamDevice /* reduced */, scaleFraction /* scale */,
                true /* isRealSnapshot */, task.getWindowingMode(), getSystemUiVisibility(task),
                !top.fillsParent());
                !top.fillsParent() || isWindowTranslucent);
    }

    private boolean shouldDisableSnapshots() {
@@ -363,11 +364,13 @@ class TaskSnapshotController {
        if (hwBitmap == null) {
            return null;
        }
        // Note, the app theme snapshot is never translucent because we enforce a non-translucent
        // color above
        return new TaskSnapshot(hwBitmap.createGraphicBufferHandle(),
                topChild.getConfiguration().orientation, mainWindow.mStableInsets,
                ActivityManager.isLowRamDeviceStatic() /* reduced */, 1.0f /* scale */,
                false /* isRealSnapshot */, task.getWindowingMode(), getSystemUiVisibility(task),
                !topChild.fillsParent());
                false);
    }

    /**