| Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
|
| index 88785c177e4d7083df2badb0f07f756141072d1b..fa92f71f4490ee767d2dbde9554bbfdeac171d1b 100644
|
| --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
|
| +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
|
| @@ -293,7 +293,7 @@ import java.util.Map;
|
| };
|
|
|
| if (mVSyncSubscriberCount > 0) {
|
| - // setVSyncNotificationEnabled(true) is called before getVSyncListener.
|
| + // addVSyncSubscriber() is called before getVSyncListener.
|
| vsyncProvider.registerVSyncListener(mVSyncListener);
|
| mVSyncListenerRegistered = true;
|
| }
|
| @@ -302,27 +302,35 @@ import java.util.Map;
|
| }
|
|
|
| @CalledByNative
|
| - void setVSyncNotificationEnabled(boolean enabled) {
|
| - if (!isVSyncNotificationEnabled() && enabled) {
|
| + void addVSyncSubscriber() {
|
| + if (!isVSyncNotificationEnabled()) {
|
| mDidSignalVSyncUsingInputEvent = false;
|
| }
|
| if (mVSyncProvider != null) {
|
| - if (!mVSyncListenerRegistered && enabled) {
|
| + if (!mVSyncListenerRegistered) {
|
| mVSyncProvider.registerVSyncListener(mVSyncListener);
|
| mVSyncListenerRegistered = true;
|
| - } else if (mVSyncSubscriberCount == 1 && !enabled) {
|
| + }
|
| + }
|
| + mVSyncSubscriberCount++;
|
| + }
|
| +
|
| + @CalledByNative
|
| + void removeVSyncSubscriber() {
|
| + if (mVSyncProvider != null) {
|
| + if (mVSyncSubscriberCount == 1) {
|
| assert mVSyncListenerRegistered;
|
| mVSyncProvider.unregisterVSyncListener(mVSyncListener);
|
| mVSyncListenerRegistered = false;
|
| }
|
| }
|
| - mVSyncSubscriberCount += enabled ? 1 : -1;
|
| + mVSyncSubscriberCount--;
|
| assert mVSyncSubscriberCount >= 0;
|
| }
|
|
|
| @CalledByNative
|
| private void resetVSyncNotification() {
|
| - while (isVSyncNotificationEnabled()) setVSyncNotificationEnabled(false);
|
| + while (isVSyncNotificationEnabled()) removeVSyncSubscriber();
|
| mVSyncSubscriberCount = 0;
|
| mVSyncListenerRegistered = false;
|
| mNeedAnimate = false;
|
| @@ -336,7 +344,7 @@ import java.util.Map;
|
| private void setNeedsAnimate() {
|
| if (!mNeedAnimate) {
|
| mNeedAnimate = true;
|
| - setVSyncNotificationEnabled(true);
|
| + addVSyncSubscriber();
|
| }
|
| }
|
|
|
| @@ -3096,7 +3104,7 @@ import java.util.Map;
|
| private void animateIfNecessary(long frameTimeMicros) {
|
| if (mNeedAnimate) {
|
| mNeedAnimate = onAnimate(frameTimeMicros);
|
| - if (!mNeedAnimate) setVSyncNotificationEnabled(false);
|
| + if (!mNeedAnimate) removeVSyncSubscriber();
|
| }
|
| }
|
|
|
|
|