| 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 7d9d8a6ac98e53d8ddda213c4bba96a070426e76..af8f87b5ffd898c832a1fa2f0db7cd590e50ca89 100644
|
| --- a/ui/android/java/src/org/chromium/ui/VSyncMonitor.java
|
| +++ b/ui/android/java/src/org/chromium/ui/VSyncMonitor.java
|
| @@ -24,6 +24,8 @@ public class VSyncMonitor {
|
| private static final long NANOSECONDS_PER_MILLISECOND = 1000000;
|
| private static final long NANOSECONDS_PER_MICROSECOND = 1000;
|
|
|
| + private boolean mInsideVSync = false;
|
| +
|
| /**
|
| * VSync listener class
|
| */
|
| @@ -150,16 +152,32 @@ public class VSyncMonitor {
|
| mGoodStartingPointNano = goodStartingPointNano;
|
| }
|
|
|
| + /**
|
| + * @return true if onVSync handler is executing. If onVSync handler
|
| + * introduces invalidations, View#invalidate() should be called. If
|
| + * View#postInvalidateOnAnimation is called instead, the corresponding onDraw
|
| + * will be delayed by one frame. The embedder of VSyncMonitor should check
|
| + * this value if it wants to post an invalidation.
|
| + */
|
| + public boolean isInsideVSync() {
|
| + return mInsideVSync;
|
| + }
|
| +
|
| private long getCurrentNanoTime() {
|
| return System.nanoTime();
|
| }
|
|
|
| private void onVSyncCallback(long frameTimeNanos, long currentTimeNanos) {
|
| assert mHaveRequestInFlight;
|
| + mInsideVSync = true;
|
| mHaveRequestInFlight = false;
|
| mLastVSyncCpuTimeNano = currentTimeNanos;
|
| - if (mListener != null) {
|
| - mListener.onVSync(this, frameTimeNanos / NANOSECONDS_PER_MICROSECOND);
|
| + try {
|
| + if (mListener != null) {
|
| + mListener.onVSync(this, frameTimeNanos / NANOSECONDS_PER_MICROSECOND);
|
| + }
|
| + } finally {
|
| + mInsideVSync = false;
|
| }
|
| }
|
|
|
|
|