Fix ColorFade would be cut when turn off screen in landscape

The BLAST layer should be wrapped by a container layer so it could be
rotated properly when drawing in landscape mode.

Bug: 186274303
Bug: 188001557
Test: turn off/on screen in landscape to see if ColorFade works fine.
Change-Id: Ide95e1840e74d803c6df4329219698ff36b57b3e
This commit is contained in:
Arthur Hung
2021-05-13 10:06:53 +08:00
parent 9c04f33d2b
commit 8f26b67566

View File

@@ -93,6 +93,7 @@ final class ColorFade {
private int mDisplayHeight; // real height, not rotated
private SurfaceControl mSurfaceControl;
private Surface mSurface;
private SurfaceControl mBLASTSurfaceControl;
private BLASTBufferQueue mBLASTBufferQueue;
private NaturalSurfaceLayout mSurfaceLayout;
private EGLDisplay mEglDisplay;
@@ -576,7 +577,7 @@ final class ColorFade {
if (mMode == MODE_FADE) {
builder.setColorLayer();
} else {
builder.setBLASTLayer();
builder.setContainerLayer();
}
mSurfaceControl = builder.build();
} catch (OutOfResourcesException ex) {
@@ -592,7 +593,14 @@ final class ColorFade {
mTransaction.apply();
if (mMode != MODE_FADE) {
mBLASTBufferQueue = new BLASTBufferQueue("ColorFade", mSurfaceControl,
final SurfaceControl.Builder b = new SurfaceControl.Builder()
.setName("ColorFade BLAST")
.setParent(mSurfaceControl)
.setHidden(false)
.setSecure(isSecure)
.setBLASTLayer();
mBLASTSurfaceControl = b.build();
mBLASTBufferQueue = new BLASTBufferQueue("ColorFade", mBLASTSurfaceControl,
mDisplayWidth, mDisplayHeight, PixelFormat.TRANSLUCENT);
mSurface = mBLASTBufferQueue.createSurface();
}
@@ -723,10 +731,16 @@ final class ColorFade {
mTransaction.remove(mSurfaceControl).apply();
if (mSurface != null) {
mSurface.release();
mBLASTBufferQueue.destroy();
mSurface = null;
}
if (mBLASTSurfaceControl != null) {
mBLASTSurfaceControl.release();
mBLASTSurfaceControl = null;
mBLASTBufferQueue.destroy();
mBLASTBufferQueue = null;
}
mSurfaceControl = null;
mSurfaceVisible = false;
mSurfaceAlpha = 0f;