Skip to content

Commit

Permalink
Remove burst mode from VSyncMonitor.
Browse files Browse the repository at this point in the history
Extra vsyncs after each rendering cause 1% more power consumption.

NOTRY=true

Review URL: https://codereview.chromium.org/346813002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279997 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
egor.starkov@samsung.com committed Jun 26, 2014
1 parent 994fdb2 commit ab76b14
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 14 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ Douglas F. Turner <doug.turner@gmail.com>
Eduardo Lima (Etrunko) <eduardo.lima@intel.com>
Edward Crossman <tedoc2000@gmail.com>
Eero Häkkinen <e.hakkinen@partner.samsung.com>
Egor Starkov <egor.starkov@samsung.com>
Ehsan Akhgari <ehsan.akhgari@gmail.com>
Elan Ruusamäe <elan.ruusamae@gmail.com>
Eric Ahn <byungwook.ahn@gmail.com>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public VSyncMonitor call() {
private void performVSyncPeriodTest(boolean enableJBVSync) throws InterruptedException {
// Collect roughly one second of data on a 60 fps display.
collectAndCheckVSync(enableJBVSync, 60, true);
collectAndCheckVSync(enableJBVSync, VSyncMonitor.MAX_AUTO_ONVSYNC_COUNT, false);
collectAndCheckVSync(enableJBVSync, 60, false);
}

private void collectAndCheckVSync(
Expand Down
13 changes: 0 additions & 13 deletions ui/android/java/src/org/chromium/ui/VSyncMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@

/**
* 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.
*/
Expand All @@ -26,7 +23,6 @@ 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
Expand All @@ -46,7 +42,6 @@ public interface Listener {
private final long mRefreshPeriodNano;

private boolean mHaveRequestInFlight;
private int mTriggerNextVSyncCount;

// Choreographer is used to detect vsync on >= JB.
private final Choreographer mChoreographer;
Expand Down Expand Up @@ -84,7 +79,6 @@ public VSyncMonitor(Context context, VSyncMonitor.Listener listener, boolean ena
.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.
Expand Down Expand Up @@ -145,16 +139,13 @@ private boolean isVSyncSignalAvailable() {
* 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();
}

Expand All @@ -174,10 +165,6 @@ private void onVSyncCallback(long frameTimeNanos, long currentTimeNanos) {
assert mHaveRequestInFlight;
mHaveRequestInFlight = false;
mLastVSyncCpuTimeNano = currentTimeNanos;
if (mTriggerNextVSyncCount >= 0) {
mTriggerNextVSyncCount--;
postCallback();
}
if (mListener != null) {
mListener.onVSync(this, frameTimeNanos / NANOSECONDS_PER_MICROSECOND);
}
Expand Down

0 comments on commit ab76b14

Please sign in to comment.