Move more code that uses BQL to use BLAST layer

Test: go/wm-smoke
Bug: 170765639
Change-Id: I107519dfb65fe05cd140bd8dccd0aebe24c1927f
This commit is contained in:
chaviw
2021-03-19 14:04:00 -05:00
parent 8476c06004
commit d9d52789b1
5 changed files with 28 additions and 47 deletions

View File

@@ -6400,8 +6400,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
}
clearThumbnail();
final Transaction transaction = getAnimatingContainer().getPendingTransaction();
mThumbnail = new WindowContainerThumbnail(mWmService.mSurfaceFactory,
transaction, getAnimatingContainer(), thumbnailHeader);
mThumbnail = new WindowContainerThumbnail(transaction, getAnimatingContainer(),
thumbnailHeader);
mThumbnail.startAnimation(transaction, loadThumbnailAnimation(thumbnailHeader));
}
@@ -6430,8 +6430,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
return;
}
final Transaction transaction = getPendingTransaction();
mThumbnail = new WindowContainerThumbnail(mWmService.mSurfaceFactory,
transaction, getTask(), thumbnail);
mThumbnail = new WindowContainerThumbnail(transaction, getTask(), thumbnail);
final Animation animation =
getDisplayContent().mAppTransition.createCrossProfileAppsThumbnailAnimationLocked(
frame);

View File

@@ -154,6 +154,8 @@ import android.content.pm.ActivityInfo.ScreenOrientation;
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.ColorSpace;
import android.graphics.GraphicBuffer;
import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.Rect;
@@ -3821,7 +3823,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
final ActivityRecord activity = mImeLayeringTarget.mActivityRecord;
final SurfaceControl imeSurface = mWmService.mSurfaceControlFactory.apply(null)
.setName("IME-snapshot-surface")
.setBufferSize(buffer.getWidth(), buffer.getHeight())
.setBLASTLayer()
.setFormat(buffer.getFormat())
.setParent(activity.getSurfaceControl())
.setCallsite("DisplayContent.attachAndShowImeScreenshotOnTarget")
@@ -3829,10 +3831,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
// Make IME snapshot as trusted overlay
InputMonitor.setTrustedOverlayInputInfo(imeSurface, t, getDisplayId(),
"IME-snapshot-surface");
Surface surface = mWmService.mSurfaceFactory.get();
surface.copyFrom(imeSurface);
surface.attachAndQueueBufferWithColorSpace(buffer, null);
surface.release();
GraphicBuffer graphicBuffer = GraphicBuffer.createFromHardwareBuffer(buffer);
t.setBuffer(imeSurface, graphicBuffer);
t.setColorSpace(mSurfaceControl, ColorSpace.get(ColorSpace.Named.SRGB));
t.setRelativeLayer(imeSurface, activity.getSurfaceControl(), 1);
t.setPosition(imeSurface, mInputMethodWindow.getDisplayFrame().left,
mInputMethodWindow.getDisplayFrame().top);

View File

@@ -17,8 +17,8 @@ package com.android.server.wm;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_RECENTS_ANIMATIONS;
import android.graphics.GraphicBuffer;
import android.hardware.HardwareBuffer;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.SurfaceSession;
@@ -51,14 +51,14 @@ class TaskScreenshotAnimatable implements SurfaceAnimator.Animatable {
task, mWidth, mHeight);
mSurfaceControl = surfaceControlFactory.apply(new SurfaceSession())
.setName("RecentTaskScreenshotSurface")
.setBufferSize(mWidth, mHeight)
.setBLASTLayer()
.setCallsite("TaskScreenshotAnimatable")
.build();
if (buffer != null) {
final Surface surface = new Surface();
surface.copyFrom(mSurfaceControl);
surface.attachAndQueueBufferWithColorSpace(buffer, screenshotBuffer.getColorSpace());
surface.release();
GraphicBuffer graphicBuffer = GraphicBuffer.createFromHardwareBuffer(buffer);
getPendingTransaction().setBuffer(mSurfaceControl, graphicBuffer);
getPendingTransaction().setColorSpace(mSurfaceControl,
screenshotBuffer.getColorSpace());
final float scale = 1.0f * mTask.getBounds().width() / mWidth;
getPendingTransaction().setMatrix(mSurfaceControl, scale, 0, 0, scale);
}

View File

@@ -28,12 +28,13 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.server.wm.WindowManagerService.MAX_ANIMATION_DURATION;
import android.graphics.ColorSpace;
import android.graphics.GraphicBuffer;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.hardware.HardwareBuffer;
import android.os.Process;
import android.util.proto.ProtoOutputStream;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Builder;
import android.view.SurfaceControl.Transaction;
@@ -43,8 +44,6 @@ import com.android.internal.protolog.common.ProtoLog;
import com.android.server.wm.SurfaceAnimator.Animatable;
import com.android.server.wm.SurfaceAnimator.AnimationType;
import java.util.function.Supplier;
/**
* Represents a surface that is displayed over a subclass of {@link WindowContainer}
*/
@@ -57,30 +56,20 @@ class WindowContainerThumbnail implements Animatable {
private final SurfaceAnimator mSurfaceAnimator;
private final int mWidth;
private final int mHeight;
private final boolean mRelative;
WindowContainerThumbnail(Supplier<Surface> surfaceFactory, Transaction t,
WindowContainer container, HardwareBuffer thumbnailHeader) {
this(surfaceFactory, t, container, thumbnailHeader, false /* relative */);
}
/**
* @param t Transaction to create the thumbnail in.
* @param container The sub-class of {@link WindowContainer} to associate this thumbnail with.
* @param thumbnailHeader A thumbnail or placeholder for thumbnail to initialize with.
* @param relative Whether this thumbnail will be a child of the container (and thus positioned
* relative to it) or not.
*/
WindowContainerThumbnail(Supplier<Surface> surfaceFactory, Transaction t,
WindowContainer container, HardwareBuffer thumbnailHeader, boolean relative) {
this(t, container, thumbnailHeader, relative, surfaceFactory.get(), null);
WindowContainerThumbnail(Transaction t, WindowContainer container,
HardwareBuffer thumbnailHeader) {
this(t, container, thumbnailHeader, null /* animator */);
}
WindowContainerThumbnail(Transaction t, WindowContainer container,
HardwareBuffer thumbnailHeader, boolean relative, Surface drawSurface,
SurfaceAnimator animator) {
HardwareBuffer thumbnailHeader, SurfaceAnimator animator) {
mWindowContainer = container;
mRelative = relative;
if (animator != null) {
mSurfaceAnimator = animator;
} else {
@@ -99,7 +88,7 @@ class WindowContainerThumbnail implements Animatable {
// this to the task.
mSurfaceControl = mWindowContainer.makeChildSurface(mWindowContainer.getTopChild())
.setName("thumbnail anim: " + mWindowContainer.toString())
.setBufferSize(mWidth, mHeight)
.setBLASTLayer()
.setFormat(PixelFormat.TRANSLUCENT)
.setMetadata(METADATA_WINDOW_TYPE, mWindowContainer.getWindowingMode())
.setMetadata(METADATA_OWNER_UID, Process.myUid())
@@ -108,18 +97,14 @@ class WindowContainerThumbnail implements Animatable {
ProtoLog.i(WM_SHOW_TRANSACTIONS, " THUMBNAIL %s: CREATE", mSurfaceControl);
// Transfer the thumbnail to the surface
drawSurface.copyFrom(mSurfaceControl);
drawSurface.attachAndQueueBufferWithColorSpace(thumbnailHeader, null);
drawSurface.release();
GraphicBuffer graphicBuffer = GraphicBuffer.createFromHardwareBuffer(thumbnailHeader);
t.setBuffer(mSurfaceControl, graphicBuffer);
t.setColorSpace(mSurfaceControl, ColorSpace.get(ColorSpace.Named.SRGB));
t.show(mSurfaceControl);
// We parent the thumbnail to the container, and just place it on top of anything else in
// the container.
t.setLayer(mSurfaceControl, Integer.MAX_VALUE);
if (relative) {
t.reparent(mSurfaceControl, mWindowContainer.getSurfaceControl());
}
}
void startAnimation(Transaction t, Animation anim) {
@@ -194,9 +179,6 @@ class WindowContainerThumbnail implements Animatable {
@Override
public void onAnimationLeashCreated(Transaction t, SurfaceControl leash) {
t.setLayer(leash, Integer.MAX_VALUE);
if (mRelative) {
t.reparent(leash, mWindowContainer.getSurfaceControl());
}
}
@Override

View File

@@ -18,14 +18,13 @@ package com.android.server.wm;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.when;
import static org.mockito.ArgumentMatchers.any;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
import android.hardware.HardwareBuffer;
import android.platform.test.annotations.Presubmit;
import android.view.Surface;
import androidx.test.filters.FlakyTest;
import androidx.test.filters.SmallTest;
@@ -51,8 +50,8 @@ public class WindowContainerThumbnailTest extends WindowTestsBase {
when(mockAr.getPendingTransaction()).thenReturn(new StubTransaction());
when(mockAr.makeChildSurface(any())).thenReturn(new MockSurfaceControlBuilder());
when(mockAr.makeSurface()).thenReturn(new MockSurfaceControlBuilder());
return new WindowContainerThumbnail(new StubTransaction(), mockAr,
buffer, false, mock(Surface.class), mock(SurfaceAnimator.class));
return new WindowContainerThumbnail(new StubTransaction(), mockAr, buffer,
mock(SurfaceAnimator.class));
}
@Test