Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix first frame on rotation animation for Tegra
Modify rotation animation to use a screenshot instead of a black screen.

Change-Id: I71563680f5d7cb355dd50b8873fa1b420a131512
  • Loading branch information
Roach2010 authored and LorDClockaN committed Jul 7, 2012
1 parent 957d8da commit 24efe15
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion services/java/com/android/server/wm/ScreenRotationAnimation.java
Expand Up @@ -62,6 +62,7 @@ class ScreenRotationAnimation {

public ScreenRotationAnimation(Context context, SurfaceSession session,
boolean inTransaction, int originalWidth, int originalHeight, int originalRotation) {
boolean isTegra = android.os.SystemProperties.get("ro.board.platform","").equals("tegra");
mContext = context;

// Screenshot does NOT include rotation!
Expand Down Expand Up @@ -99,7 +100,7 @@ public ScreenRotationAnimation(Context context, SurfaceSession session,
try {
try {
mSurface = new Surface(session, 0, "FreezeSurface",
-1, mWidth, mHeight, PixelFormat.OPAQUE, Surface.FX_SURFACE_SCREENSHOT | Surface.HIDDEN);
-1, mWidth, mHeight, PixelFormat.OPAQUE, isTegra ? 0 : (Surface.FX_SURFACE_SCREENSHOT | Surface.HIDDEN));
if (mSurface == null || !mSurface.isValid()) {
// Screenshot failed, punt.
mSurface = null;
Expand All @@ -116,6 +117,35 @@ public ScreenRotationAnimation(Context context, SurfaceSession session,
" FREEZE " + mSurface + ": CREATE");

setRotation(originalRotation);

if (isTegra) {
Rect rect = new Rect(0, 0, mWidth, mHeight);
Canvas canvas = null;

try {
canvas = mSurface.lockCanvas(rect);
} catch (IllegalArgumentException e) {
Slog.w(TAG, "Unable to lock surface", e);
} catch (Surface.OutOfResourcesException e) {
Slog.w(TAG, "Unable to lock surface", e);
}

Bitmap screenshot = Surface.screenshot(0, 0);
if (canvas == null || screenshot == null) {
Slog.w(TAG, "Null surface canvas");
mSurface.destroy();
mSurface = null;
return;
}

Paint paint = new Paint(0);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));

canvas.drawBitmap(screenshot, 0, 0, paint);
mSurface.unlockCanvasAndPost(canvas);

}

} finally {
if (!inTransaction) {
Surface.closeTransaction();
Expand Down

0 comments on commit 24efe15

Please sign in to comment.