summaryrefslogtreecommitdiffstats
path: root/ui/android
diff options
context:
space:
mode:
authorpeter@chromium.org <peter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-26 15:24:20 +0000
committerpeter@chromium.org <peter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-26 15:24:20 +0000
commit7deb76581d6d65e3ca18bc28211ca0d465118bae (patch)
tree5fa0cfa34386a5866e25453be0d913984adc35f0 /ui/android
parentca6d162cbd4052637549cd18445c2d755a333b56 (diff)
downloadchromium_src-7deb76581d6d65e3ca18bc28211ca0d465118bae.zip
chromium_src-7deb76581d6d65e3ca18bc28211ca0d465118bae.tar.gz
chromium_src-7deb76581d6d65e3ca18bc28211ca0d465118bae.tar.bz2
Revert of Remove burst mode from VSyncMonitor. (https://codereview.chromium.org/346813002/)
Reason for revert: Four of the introduced tests time out on Android. VSyncMonitorTest#testVSyncActivationFromIdleAllowJBVSync VSyncMonitorTest#testVSyncActivationFromIdleDisallowJBVSync VSyncMonitorTest#testVSyncPeriodAllowJBVSync VSyncMonitorTest#testVSyncPeriodDisallowJBVSync The log output can be seen here: http://build.chromium.org/p/chromium.linux/builders/Android%20Tests%20%28dbg%29/builds/21188/steps/contentshell_instrumentation_tests/logs/stdio This failure could be observed in the try-bot results as part of the patch. Please do not use NOTRY unless you're absolutely certain that the failures are unrelated. Original issue's description: > Remove burst mode from VSyncMonitor. > > Extra vsyncs after each rendering cause 1% more power consumption. > > NOTRY=true > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=279997 TBR=tedchoc@chromium.org,sievers@chromium.org,aruslan@chromium.org,brianderson@chromium.org,skyostil@google.com,skyostil@chromium.org,bulach@chromium.org,miguelg@chromium.org,yfriedman@chromium.org,newt@chromium.org,egor.starkov@samsung.com NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/358473006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280012 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/android')
-rw-r--r--ui/android/java/src/org/chromium/ui/VSyncMonitor.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/ui/android/java/src/org/chromium/ui/VSyncMonitor.java b/ui/android/java/src/org/chromium/ui/VSyncMonitor.java
index 935df01..5805585 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 @@ import org.chromium.base.TraceEvent;
/**
* 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 @@ public class VSyncMonitor {
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 @@ public class VSyncMonitor {
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 @@ public class VSyncMonitor {
.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 @@ public class VSyncMonitor {
* 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 @@ public class VSyncMonitor {
assert mHaveRequestInFlight;
mHaveRequestInFlight = false;
mLastVSyncCpuTimeNano = currentTimeNanos;
+ if (mTriggerNextVSyncCount >= 0) {
+ mTriggerNextVSyncCount--;
+ postCallback();
+ }
if (mListener != null) {
mListener.onVSync(this, frameTimeNanos / NANOSECONDS_PER_MICROSECOND);
}