From 2f2022afa1eb85018368398bd150e9575fc099c9 Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Tue, 11 Oct 2011 06:41:59 -0700 Subject: Make notification panel delete-all animation smoother Making the notfication delete-all animation smoother by carefully choreographing the various parts of it. The problem with the previous animation was that there was simply too much going on at the same time, causing things like layout and recreating display-lists in the middle of animations that became choppy as a result. This approach swipes all items off quickly, then scrolls the shade up to the top, making both sets of animations smoother as a result. Fixes #5431207: Notification delete-all should be smoother Change-Id: Iefe8ab5d661e05adcd10379dab85227d17904450 --- core/java/android/view/ViewRootImpl.java | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'core/java/android/view/ViewRootImpl.java') diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 7eae739..081e267 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -108,6 +108,7 @@ public final class ViewRootImpl extends Handler implements ViewParent, private static final boolean DEBUG_TRACKBALL = false || LOCAL_LOGV; private static final boolean DEBUG_IMF = false || LOCAL_LOGV; private static final boolean DEBUG_CONFIGURATION = false || LOCAL_LOGV; + private static final boolean DEBUG_FPS = false; private static final boolean WATCH_POINTER = false; /** @@ -274,6 +275,11 @@ public final class ViewRootImpl extends Handler implements ViewParent, private Thread mRenderProfiler; private volatile boolean mRenderProfilingEnabled; + // Variables to track frames per second, enabled via DEBUG_FPS flag + private long mFpsStartTime = -1; + private long mFpsPrevTime = -1; + private int mFpsNumFrames; + /** * see {@link #playSoundEffect(int)} */ @@ -1766,12 +1772,42 @@ public final class ViewRootImpl extends Handler implements ViewParent, } } + /** + * Called from draw() when DEBUG_FPS is enabled + */ + private void trackFPS() { + // Tracks frames per second drawn. First value in a series of draws may be bogus + // because it down not account for the intervening idle time + long nowTime = System.currentTimeMillis(); + if (mFpsStartTime < 0) { + mFpsStartTime = mFpsPrevTime = nowTime; + mFpsNumFrames = 0; + } else { + ++mFpsNumFrames; + String thisHash = Integer.toHexString(System.identityHashCode(this)); + long frameTime = nowTime - mFpsPrevTime; + long totalTime = nowTime - mFpsStartTime; + Log.v(TAG, "0x" + thisHash + "\tFrame time:\t" + frameTime); + mFpsPrevTime = nowTime; + if (totalTime > 1000) { + float fps = (float) mFpsNumFrames * 1000 / totalTime; + Log.v(TAG, "0x" + thisHash + "\tFPS:\t" + fps); + mFpsStartTime = nowTime; + mFpsNumFrames = 0; + } + } + } + private void draw(boolean fullRedrawNeeded) { Surface surface = mSurface; if (surface == null || !surface.isValid()) { return; } + if (DEBUG_FPS) { + trackFPS(); + } + if (!sFirstDrawComplete) { synchronized (sFirstDrawHandlers) { sFirstDrawComplete = true; -- cgit v1.1