Chromium Code Reviews| Index: ui/android/java/src/org/chromium/ui/base/WindowAndroid.java |
| diff --git a/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java b/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java |
| index 309b7355c2d2df6f104b0628030cd42c8b824398..547e582cecb11fa81bf1a71a81d906b26835ee63 100644 |
| --- a/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java |
| +++ b/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java |
| @@ -17,6 +17,7 @@ import android.widget.Toast; |
| import org.chromium.base.CalledByNative; |
| import org.chromium.base.JNINamespace; |
| +import org.chromium.ui.VSyncMonitor; |
| import java.lang.ref.WeakReference; |
| import java.util.HashMap; |
| @@ -30,6 +31,8 @@ public class WindowAndroid { |
| // Native pointer to the c++ WindowAndroid object. |
| private long mNativeWindowAndroid = 0; |
| + private final VSyncMonitor mVSyncMonitor; |
| + private VSyncClient mVSyncClient = null; |
| // A string used as a key to store intent errors in a bundle |
| static final String WINDOW_CALLBACK_ERRORS = "window_callback_errors"; |
| @@ -45,6 +48,15 @@ public class WindowAndroid { |
| // the Android lint warning "UseSparseArrays". |
| protected HashMap<Integer, String> mIntentErrors; |
| + private final VSyncMonitor.Listener mVSyncListener = new VSyncMonitor.Listener() { |
| + @Override public void onVSync(VSyncMonitor monitor, |
|
David Trainor- moved to gerrit
2014/04/16 06:18:20
new line after @Override (not 100% sure on if this
no sievers
2014/04/25 22:23:33
Done.
|
| + long vsyncTimeMicros) { |
|
David Trainor- moved to gerrit
2014/04/16 06:18:20
does this fit on the above line?
no sievers
2014/04/25 22:23:33
Done.
|
| + if (mVSyncClient != null) |
| + mVSyncClient.onVSync(vsyncTimeMicros); |
|
David Trainor- moved to gerrit
2014/04/16 06:18:20
{} around this or move it to the above line
no sievers
2014/04/25 22:23:33
Done.
|
| + nativeOnVSync(mNativeWindowAndroid, vsyncTimeMicros); |
|
David Trainor- moved to gerrit
2014/04/16 06:18:20
assert mNativeWindowAndroid != 0 or if check?
no sievers
2014/04/25 22:23:33
Done.
|
| + } |
| + }; |
| + |
| /** |
| * @param context The application context. |
| */ |
| @@ -54,6 +66,7 @@ public class WindowAndroid { |
| mApplicationContext = context; |
| mOutstandingIntents = new SparseArray<IntentCallback>(); |
| mIntentErrors = new HashMap<Integer, String>(); |
| + mVSyncMonitor = new VSyncMonitor(context, mVSyncListener); |
| } |
| /** |
| @@ -216,6 +229,31 @@ public class WindowAndroid { |
| } |
| /** |
| + * An interface to receive VSync notifications from the window. |
| + * The one and only client is set with setVSyncClient(client). |
| + */ |
| + public interface VSyncClient { |
| + public void onVSync(long vsyncTimeMicros); |
|
David Trainor- moved to gerrit
2014/04/16 06:18:20
Javadoc on this method. Don't need public on inte
no sievers
2014/04/25 22:23:33
Done.
|
| + } |
| + |
| + /** |
| + * Sets the VSyncClient. |
| + */ |
| + public void setVSyncClient(VSyncClient client) { |
|
David Trainor- moved to gerrit
2014/04/16 06:18:20
Fix javadoc (@param client xyz)
no sievers
2014/04/25 22:23:33
Done.
|
| + assert mVSyncClient == null || client == null; |
|
Sami
2014/04/16 17:26:54
++Indent (here and below)
no sievers
2014/04/25 22:23:33
Done.
|
| + mVSyncClient = client; |
| + } |
| + |
| + @CalledByNative |
|
David Trainor- moved to gerrit
2014/04/16 06:18:20
Move below javadoc
no sievers
2014/04/25 22:23:33
Done.
|
| + /** |
| + * Request a VSync callback. |
| + * VSyncClient.onVSync() will be called at least once. |
| + */ |
| + public void requestVSyncUpdate() { |
| + mVSyncMonitor.requestUpdate(); |
| + } |
| + |
| + /** |
| * An interface that intent callback objects have to implement. |
| */ |
| public interface IntentCallback { |
| @@ -257,7 +295,7 @@ public class WindowAndroid { |
| */ |
| public long getNativePointer() { |
| if (mNativeWindowAndroid == 0) { |
| - mNativeWindowAndroid = nativeInit(); |
| + mNativeWindowAndroid = nativeInit(mVSyncMonitor.getVSyncPeriodInMicroseconds()); |
| } |
| return mNativeWindowAndroid; |
| } |
| @@ -271,7 +309,8 @@ public class WindowAndroid { |
| return null; |
| } |
| - private native long nativeInit(); |
| + private native long nativeInit(long vsyncPeriod); |
| + private native void nativeOnVSync(long nativeWindowAndroid, long vsyncTimeMicros); |
| private native void nativeDestroy(long nativeWindowAndroid); |
| } |