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

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

Issue 358473006: Revert of Remove burst mode from VSyncMonitor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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
« no previous file with comments | « content/public/android/javatests/src/org/chromium/content/browser/VSyncMonitorTest.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 935df011032876d5cf303a6af140b3e8a54f95ab..58055857901045caf862fef636e24d4a291d7cd0 100644
--- a/ui/android/java/src/org/chromium/ui/VSyncMonitor.java
+++ b/ui/android/java/src/org/chromium/ui/VSyncMonitor.java
@@ -15,6 +15,9 @@
/**
* Notifies clients of the default displays's vertical sync pulses.
+ * This class works in "burst" mode: once the update is requested, the listener will be
+ * called MAX_VSYNC_COUNT times on the vertical sync pulses (on JB) or on every refresh
+ * period (on ICS, see below), unless stop() is called.
* On ICS, VSyncMonitor relies on setVSyncPointForICS() being called to set a reasonable
* approximation of a vertical sync starting point; see also http://crbug.com/156397.
*/
@@ -23,6 +26,7 @@
private static final long NANOSECONDS_PER_SECOND = 1000000000;
private static final long NANOSECONDS_PER_MILLISECOND = 1000000;
private static final long NANOSECONDS_PER_MICROSECOND = 1000;
+ public static final int MAX_AUTO_ONVSYNC_COUNT = 5;
/**
* VSync listener class
@@ -42,6 +46,7 @@
private final long mRefreshPeriodNano;
private boolean mHaveRequestInFlight;
+ private int mTriggerNextVSyncCount;
// Choreographer is used to detect vsync on >= JB.
private final Choreographer mChoreographer;
@@ -79,6 +84,7 @@
.getDefaultDisplay().getRefreshRate();
if (refreshRate <= 0) refreshRate = 60;
mRefreshPeriodNano = (long) (NANOSECONDS_PER_SECOND / refreshRate);
+ mTriggerNextVSyncCount = 0;
if (enableJBVSync && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
// Use Choreographer on JB+ to get notified of vsync.
@@ -139,13 +145,16 @@
* after this function is called.
*/
public void stop() {
+ mTriggerNextVSyncCount = 0;
}
/**
* Request to be notified of the closest display vsync events.
* Listener.onVSync() will be called soon after the upcoming vsync pulses.
+ * It will be called at most MAX_AUTO_ONVSYNC_COUNT times unless requestUpdate() is called.
*/
public void requestUpdate() {
+ mTriggerNextVSyncCount = MAX_AUTO_ONVSYNC_COUNT;
postCallback();
}
@@ -165,6 +174,10 @@
assert mHaveRequestInFlight;
mHaveRequestInFlight = false;
mLastVSyncCpuTimeNano = currentTimeNanos;
+ if (mTriggerNextVSyncCount >= 0) {
+ mTriggerNextVSyncCount--;
+ postCallback();
+ }
if (mListener != null) {
mListener.onVSync(this, frameTimeNanos / NANOSECONDS_PER_MICROSECOND);
}
« no previous file with comments | « content/public/android/javatests/src/org/chromium/content/browser/VSyncMonitorTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698