Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Unified Diff: ui/android/java/src/org/chromium/ui/VSyncMonitor.java

Issue 611313003: Use estimated vsync period on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/android/java/src/org/chromium/ui/VSyncMonitor.java
diff --git a/ui/android/java/src/org/chromium/ui/VSyncMonitor.java b/ui/android/java/src/org/chromium/ui/VSyncMonitor.java
index af8f87b5ffd898c832a1fa2f0db7cd590e50ca89..13f9d01e6bf78f2a4d26a51dfb337f8f56f47905 100644
--- a/ui/android/java/src/org/chromium/ui/VSyncMonitor.java
+++ b/ui/android/java/src/org/chromium/ui/VSyncMonitor.java
@@ -41,7 +41,7 @@ public class VSyncMonitor {
private Listener mListener;
// Display refresh rate as reported by the system.
- private final long mRefreshPeriodNano;
+ private long mRefreshPeriodNano;
private boolean mHaveRequestInFlight;
@@ -89,6 +89,14 @@ public class VSyncMonitor {
@Override
public void doFrame(long frameTimeNanos) {
TraceEvent.begin("VSync");
+ // Display.getRefreshRate() is unreliable on some platforms.
Sami 2014/09/30 16:04:14 Can we make this logic conditional on whether getR
jmanko 2014/10/01 09:36:51 Acknowledged.
+ // Adjust refresh period- initial value is based on Display.getRefreshRate(),
+ // after that it asymptotically approaches the real value.
+ // Last refresh duration is capped at 30 fps
+ long lastRefreshDurationNano =
+ Math.min(frameTimeNanos - mGoodStartingPointNano,
+ 34 * NANOSECONDS_PER_MILLISECOND);
+ mRefreshPeriodNano = (mRefreshPeriodNano + lastRefreshDurationNano) / 2;
Sami 2014/09/30 16:04:14 Instead of capping arbitrarily, can we just update
jmanko 2014/10/01 09:36:51 You mean something like this? long lastRefreshDura
Sami 2014/10/01 09:39:34 That would work. Please also make the |34 * NANOSE
no sievers 2014/10/01 17:48:09 Can't this be done easier and in a more robust way
mGoodStartingPointNano = frameTimeNanos;
onVSyncCallback(frameTimeNanos, getCurrentNanoTime());
TraceEvent.end("VSync");
@@ -132,7 +140,7 @@ public class VSyncMonitor {
/**
* Determine whether a true vsync signal is available on this platform.
*/
- private boolean isVSyncSignalAvailable() {
+ public boolean isVSyncSignalAvailable() {
return mChoreographer != null;
}

Powered by Google App Engine
This is Rietveld 408576698