Fixing ColorFade animation in landscape mode

Bug: b/277612338
Test: manual testing

Test steps:
Increase animation duration: set DisplayPowerController2.COLOR_FADE_OFF_ANIMATION_DURATION_MILLIS value to e.g 2000 (2s.)
Set ColorFade.MODE_FADE mode: Hardcode  DisplayPowerController2.mColorFadeFadesConfig = true
Set ColorFade.MODE_COOL_DOWN mode: Hardcode  DisplayPowerController2.mColorFadeFadesConfig = false

Tested MODE_FADE/MODE_COOL_DOWN on tablet/phone

Test steps:
1) lauch application suppoting both portait and landscape modes (e.g Chrome)
2) Rotate device to portait mode
3) Turn on and Turn off device using power button
4) Verify off animation plays
5) Rotate device to landscape mode
8) Turn on and Turn off device using power button
9) Verify off animation plays
10) Verify that animation play (in ColorFade.MODE_FADE animation rotates, in ColorFade.MODE_COOL_DOWN animation statys locked)

Change-Id: I950d8b6c3c36037d49eadb1e164391a53482ce97
This commit is contained in:
Oleg Petsjonkin
2023-04-25 15:03:21 +00:00
parent 66a64d2303
commit f74a62ac21
2 changed files with 15 additions and 7 deletions

View File

@@ -191,7 +191,7 @@ final class ColorFade {
}
if (!(createEglContext(isProtected) && createEglSurface(isProtected, isWideColor)
&& setScreenshotTextureAndSetViewport(hardwareBuffer))) {
&& setScreenshotTextureAndSetViewport(hardwareBuffer, displayInfo.rotation))) {
dismiss();
return false;
}
@@ -500,7 +500,8 @@ final class ColorFade {
}
private boolean setScreenshotTextureAndSetViewport(
ScreenCapture.ScreenshotHardwareBuffer screenshotBuffer) {
ScreenCapture.ScreenshotHardwareBuffer screenshotBuffer,
@Surface.Rotation int rotation) {
if (!attachEglContext()) {
return false;
}
@@ -525,14 +526,22 @@ final class ColorFade {
s.release();
st.release();
}
// if screen is rotated, map texture starting different corner
int indexDelta = (rotation == Surface.ROTATION_90) ? 2
: (rotation == Surface.ROTATION_180) ? 4
: (rotation == Surface.ROTATION_270) ? 6 : 0;
// Set up texture coordinates for a quad.
// We might need to change this if the texture ends up being
// a different size from the display for some reason.
mTexCoordBuffer.put(0, 0f); mTexCoordBuffer.put(1, 0f);
mTexCoordBuffer.put(2, 0f); mTexCoordBuffer.put(3, 1f);
mTexCoordBuffer.put(4, 1f); mTexCoordBuffer.put(5, 1f);
mTexCoordBuffer.put(6, 1f); mTexCoordBuffer.put(7, 0f);
mTexCoordBuffer.put(indexDelta, 0f);
mTexCoordBuffer.put(indexDelta + 1, 0f);
mTexCoordBuffer.put((indexDelta + 2) % 8, 0f);
mTexCoordBuffer.put((indexDelta + 3) % 8, 1f);
mTexCoordBuffer.put((indexDelta + 4) % 8, 1f);
mTexCoordBuffer.put((indexDelta + 5) % 8, 1f);
mTexCoordBuffer.put((indexDelta + 6) % 8, 1f);
mTexCoordBuffer.put((indexDelta + 7) % 8, 0f);
// Set up our viewport.
GLES20.glViewport(0, 0, mDisplayWidth, mDisplayHeight);

View File

@@ -2548,7 +2548,6 @@ public final class DisplayManagerService extends SystemService {
final DisplayInfo displayInfo = logicalDisplay.getDisplayInfoLocked();
captureArgs = new ScreenCapture.DisplayCaptureArgs.Builder(token)
.setSize(displayInfo.getNaturalWidth(), displayInfo.getNaturalHeight())
.setUseIdentityTransform(true)
.setCaptureSecureLayers(true)
.setAllowProtected(true)
.build();