Apply a scale animation into the transition between aod and lock screen.
Apply a scale animation to the transition, we cuurently do the scale by
changing the viewport according to reveal value.
Bug: 124822340
Test: Manually set wallpaper, switch between aod and lock screen.
Change-Id: Ifcc5d274e21618a9ea86670c2c2eaef5c0322019
diff --git a/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageWallpaperRenderer.java b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageWallpaperRenderer.java
index 7295008..9df6ba5 100644
--- a/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageWallpaperRenderer.java
+++ b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageWallpaperRenderer.java
@@ -29,6 +29,7 @@
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.util.Log;
+import android.util.MathUtils;
import com.android.systemui.ImageWallpaper;
import com.android.systemui.ImageWallpaper.ImageGLView;
@@ -43,6 +44,8 @@
public class ImageWallpaperRenderer implements GLSurfaceView.Renderer,
ImageWallpaper.WallpaperStatusListener, ImageRevealHelper.RevealStateListener {
private static final String TAG = ImageWallpaperRenderer.class.getSimpleName();
+ private static final float SCALE_VIEWPORT_MIN = 0.98f;
+ private static final float SCALE_VIEWPORT_MAX = 1f;
private final WallpaperManager mWallpaperManager;
private final ImageGLProgram mProgram;
@@ -52,6 +55,8 @@
private final ImageGLView mGLView;
private float mXOffset = 0f;
private float mYOffset = 0f;
+ private int mWidth = 0;
+ private int mHeight = 0;
public ImageWallpaperRenderer(Context context, ImageGLView glView) {
mWallpaperManager = context.getSystemService(WallpaperManager.class);
@@ -87,6 +92,8 @@
Log.d(TAG, "onSurfaceChanged: width=" + width + ", height=" + height
+ ", xOffset=" + mXOffset + ", yOffset=" + mYOffset);
}
+ mWidth = width;
+ mHeight = height;
mWallpaper.adjustTextureCoordinates(mWallpaperManager.getBitmap(),
width, height, mXOffset, mYOffset);
}
@@ -102,10 +109,21 @@
glUniform1f(mWallpaper.getHandle(ImageGLWallpaper.U_PER85), per85);
glUniform1f(mWallpaper.getHandle(ImageGLWallpaper.U_REVEAL), reveal);
+ scaleViewport(reveal);
mWallpaper.useTexture();
mWallpaper.draw();
}
+ private void scaleViewport(float reveal) {
+ // Interpolation between SCALE_VIEWPORT_MAX and SCALE_VIEWPORT_MIN by reveal.
+ float vpScaled = MathUtils.lerp(SCALE_VIEWPORT_MAX, SCALE_VIEWPORT_MIN, reveal);
+ // Calculate the offset amount from the lower left corner.
+ float offset = (SCALE_VIEWPORT_MAX - vpScaled) / 2;
+ // Change the viewport.
+ glViewport((int) (mWidth * offset), (int) (mHeight * offset),
+ (int) (mWidth * vpScaled), (int) (mHeight * vpScaled));
+ }
+
@Override
public void onAmbientModeChanged(boolean inAmbientMode, long duration) {
mImageRevealHelper.updateAwake(!inAmbientMode, duration);