Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2306)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 11959036: Implement vsync notification on Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 3257751734aa2cf60b6481bb20d4be808ba1c685..528044933d9a0da3a2ce6f05e18dd47221cf6bd3 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
@@ -177,6 +177,45 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
void onPinchGestureEnd();
}
+ private VSyncManager.Provider mVSyncProvider;
+ private VSyncManager.Listener mVSyncListener;
+ private int mVSyncSubscriberCount;
+
+ public VSyncManager.Listener getVSyncListener(VSyncManager.Provider vsyncProvider) {
+ mVSyncProvider = vsyncProvider;
+ mVSyncListener = new VSyncManager.Listener() {
+ @Override
+ public void updateVSync(long tickTimeMicros, long intervalMicros) {
+ if (mNativeContentViewCore != 0) {
+ nativeUpdateVSyncParameters(mNativeContentViewCore, tickTimeMicros,
+ intervalMicros);
+ }
+ }
+
+ @Override
+ public void onVSync(long frameTimeMicros) {
+ if (mNativeContentViewCore != 0) {
+ nativeOnVSync(mNativeContentViewCore, frameTimeMicros);
+ }
+ }
+ };
+ return mVSyncListener;
+ }
+
+ @CalledByNative
+ void setVSyncNotificationEnabled(boolean enabled) {
+ mVSyncSubscriberCount += enabled ? 1 : -1;
+ assert mVSyncSubscriberCount >= 0;
+ if (mVSyncProvider != null) {
+ mVSyncProvider.setVSyncNotificationEnabled(mVSyncListener, mVSyncSubscriberCount > 0);
+ }
+ }
+
+ @CalledByNative
+ private void resetVSyncNotification() {
+ while (mVSyncSubscriberCount > 0) setVSyncNotificationEnabled(false);
+ }
+
private final Context mContext;
private ViewGroup mContainerView;
private InternalAccessDelegate mContainerViewInternals;
@@ -649,6 +688,7 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
if (mNativeContentViewCore != 0) {
nativeOnJavaContentViewCoreDestroyed(mNativeContentViewCore);
}
+ resetVSyncNotification();
mNativeContentViewCore = 0;
mContentSettings = null;
mJavaScriptInterfaces.clear();
@@ -2611,17 +2651,6 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
}
/**
- * Update of the latest vsync parameters.
- * @param tickTimeMicros The latest vsync tick time in microseconds.
- * @param intervalMicros The vsync interval in microseconds.
- */
- public void updateVSync(long tickTimeMicros, long intervalMicros) {
- if (mNativeContentViewCore != 0) {
- nativeUpdateVSyncParameters(mNativeContentViewCore, tickTimeMicros, intervalMicros);
- }
- }
-
- /**
* @return The cached copy of render positions and scales.
*/
public RenderCoordinates getRenderCoordinates() {
@@ -2814,6 +2843,8 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
private native void nativeUpdateVSyncParameters(int nativeContentViewCoreImpl,
long timebaseMicros, long intervalMicros);
+ private native void nativeOnVSync(int nativeContentViewCoreImpl, long frameTimeMicros);
+
private native boolean nativePopulateBitmapFromCompositor(int nativeContentViewCoreImpl,
Bitmap bitmap);

Powered by Google App Engine
This is Rietveld 408576698