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

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

Update code to draw into hardware bitmaps.

Bug: 37698012
Bug: 38510859
Test: Dock task from Recents, ensure that it enters multiwindow.
Test: go/wm-smoke

Change-Id: Ia8f60f5884bb8d620dc554b61eaa95aa0038aee3
parent d2638591
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -37,7 +37,10 @@ import android.os.IRemoteCallback;
import android.os.RemoteException;
import android.util.Log;
import android.view.AppTransitionAnimationSpec;
import android.view.DisplayListCanvas;
import android.view.IAppTransitionAnimationSpecsFuture;
import android.view.RenderNode;
import android.view.ThreadedRenderer;

import com.android.internal.annotations.GuardedBy;
import com.android.systemui.recents.Recents;
@@ -358,18 +361,23 @@ public class RecentsTransitionHelper {
            b.eraseColor(Color.TRANSPARENT);
            return b;
        } else {
            Bitmap b = Bitmap.createBitmap(fromWidth, fromHeight,
                    Bitmap.Config.ARGB_8888);

            if (RecentsDebugFlags.Static.EnableTransitionThumbnailDebugMode) {
                Bitmap b = Bitmap.createBitmap(fromWidth, fromHeight, Bitmap.Config.ARGB_8888);
                b.eraseColor(0xFFff0000);
                return b.createAshmemBitmap();
            } else {
                Canvas c = new Canvas(b);

                // Create a hardware bitmap to render the TaskView into because it may be bound to a
                // snapshot that is backed by a GraphicBuffer
                RenderNode node = RenderNode.create("RecentsTransitionHelper", null);
                node.setLeftTopRightBottom(0, 0, fromWidth, fromHeight);
                node.setClipToBounds(false);
                DisplayListCanvas c = node.start(fromWidth, fromHeight);
                c.scale(scale, scale);
                taskView.draw(c);
                c.setBitmap(null);
                node.end(c);
                return ThreadedRenderer.createHardwareBitmap(node, fromWidth, fromHeight);
            }
            return b.createAshmemBitmap();
        }
    }

+13 −7
Original line number Diff line number Diff line
@@ -31,6 +31,9 @@ import android.graphics.Rect;
import android.os.Environment;
import android.os.Handler;
import android.util.ArraySet;
import android.view.DisplayListCanvas;
import android.view.RenderNode;
import android.view.ThreadedRenderer;
import android.view.WindowManager.LayoutParams;
import android.view.WindowManagerPolicy.ScreenOffListener;
import android.view.WindowManagerPolicy.StartingSurface;
@@ -238,19 +241,22 @@ class TaskSnapshotController {
        final int color = task.getTaskDescription().getBackgroundColor();
        final int statusBarColor = task.getTaskDescription().getStatusBarColor();
        final int navigationBarColor = task.getTaskDescription().getNavigationBarColor();
        final Bitmap b = Bitmap.createBitmap(mainWindow.getFrameLw().width(),
                mainWindow.getFrameLw().height(), ARGB_8888);
        final Canvas c = new Canvas(b);
        c.drawColor(color);
        final LayoutParams attrs = mainWindow.getAttrs();
        final SystemBarBackgroundPainter decorPainter = new SystemBarBackgroundPainter(attrs.flags,
                attrs.privateFlags, attrs.systemUiVisibility, statusBarColor, navigationBarColor);
        final int width = mainWindow.getFrameLw().width();
        final int height = mainWindow.getFrameLw().height();

        final RenderNode node = RenderNode.create("TaskSnapshotController", null);
        node.setLeftTopRightBottom(0, 0, width, height);
        node.setClipToBounds(false);
        final DisplayListCanvas c = node.start(width, height);
        c.drawColor(color);
        decorPainter.setInsets(mainWindow.mContentInsets, mainWindow.mStableInsets);
        decorPainter.drawDecors(c, null /* statusBarExcludeFrame */);
        node.end(c);
        final Bitmap hwBitmap = ThreadedRenderer.createHardwareBitmap(node, width, height);

        // Flush writer.
        c.setBitmap(null);
        final Bitmap hwBitmap = b.copy(HARDWARE, false /* isMutable */);
        return new TaskSnapshot(hwBitmap.createGraphicBufferHandle(),
                topChild.getConfiguration().orientation, mainWindow.mStableInsets,
                false /* reduced */, 1.0f /* scale */);