summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/ViewRootImpl.java
diff options
context:
space:
mode:
authorChet Haase <chet@google.com>2011-10-18 13:45:00 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-10-18 13:45:00 -0700
commit87bc53de2adf479ad5a5e226bf3d8fd31af6dc21 (patch)
tree3263f7de99691f1cd305efa6ef4a5402e3d866c8 /core/java/android/view/ViewRootImpl.java
parent07848843b23e10e4728fa779cc79fc38a341cf6b (diff)
parent2f2022afa1eb85018368398bd150e9575fc099c9 (diff)
downloadframeworks_base-87bc53de2adf479ad5a5e226bf3d8fd31af6dc21.zip
frameworks_base-87bc53de2adf479ad5a5e226bf3d8fd31af6dc21.tar.gz
frameworks_base-87bc53de2adf479ad5a5e226bf3d8fd31af6dc21.tar.bz2
Merge "Make notification panel delete-all animation smoother" into ics-mr0
Diffstat (limited to 'core/java/android/view/ViewRootImpl.java')
-rw-r--r--core/java/android/view/ViewRootImpl.java36
1 files changed, 36 insertions, 0 deletions
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;