Chromium Code Reviews| 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..e19a7480a7aa29996f12f8e986b12b85cf680023 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,33 @@ 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 { |
|
boliu
2014/08/20 20:30:00
nit: move finally one one above
|
| + mInsideVSync = false; |
| } |
| } |