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

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

Issue 11959036: Implement vsync notification on Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years, 9 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/ContentViewRenderView.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewRenderView.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewRenderView.java
index 781899daca98681801a1cdf3cb247955714899a7..4c2aff71b92df12d9e1e0dae3c0d0e31e6b82b76 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewRenderView.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewRenderView.java
@@ -19,7 +19,8 @@ import org.chromium.base.JNINamespace;
* Note that only one ContentView can be shown at a time.
*/
@JNINamespace("content")
-public class ContentViewRenderView extends FrameLayout {
+public class ContentViewRenderView extends FrameLayout
+ implements ContentViewCore.VSyncProvider {
// The native side of this object.
private int mNativeContentViewRenderView = 0;
@@ -29,6 +30,7 @@ public class ContentViewRenderView extends FrameLayout {
private ContentView mCurrentContentView;
private final VSyncMonitor mVSyncMonitor;
+ private boolean mVSyncNotificationEnabled;
// The VSyncMonitor gives the timebase for the actual vsync, but we don't want render until
// we have had a chance for input events to propagate to the compositor thread. This takes
@@ -74,13 +76,18 @@ public class ContentViewRenderView extends FrameLayout {
@Override
public void onVSync(VSyncMonitor monitor, long vsyncTimeMicros) {
if (mCurrentContentView == null) return;
- // Compensate for input event lag. Input events are delivered immediately on
- // pre-JB releases, so this adjustment is only done for later versions.
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
- vsyncTimeMicros += INPUT_EVENT_LAG_FROM_VSYNC_MICROSECONDS;
+ if (mVSyncNotificationEnabled) {
+ mCurrentContentView.getContentViewCore().sendVSync(vsyncTimeMicros);
+ mVSyncMonitor.requestUpdate();
+ } else {
+ // Compensate for input event lag. Input events are delivered immediately on
+ // pre-JB releases, so this adjustment is only done for later versions.
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ vsyncTimeMicros += INPUT_EVENT_LAG_FROM_VSYNC_MICROSECONDS;
+ }
+ mCurrentContentView.getContentViewCore().updateVSync(vsyncTimeMicros,
+ mVSyncMonitor.getVSyncPeriodInMicroseconds());
}
- mCurrentContentView.getContentViewCore().updateVSync(vsyncTimeMicros,
- mVSyncMonitor.getVSyncPeriodInMicroseconds());
}
});
@@ -108,6 +115,7 @@ public class ContentViewRenderView extends FrameLayout {
mCurrentContentView = contentView;
mCurrentContentView.getContentViewCore().onPhysicalBackingSizeChanged(
getWidth(), getHeight());
+ mCurrentContentView.getContentViewCore().setVSyncProvider(this);
mVSyncMonitor.requestUpdate();
}
@@ -125,6 +133,12 @@ public class ContentViewRenderView extends FrameLayout {
return mSurfaceView.getHolder().getSurface() != null;
}
+ @Override
+ public void setVSyncNotificationEnabled(ContentViewCore contentViewCore, boolean enabled) {
+ if (enabled && !mVSyncNotificationEnabled) mVSyncMonitor.requestUpdate();
+ mVSyncNotificationEnabled = enabled;
+ }
+
private static native int nativeInit();
private native void nativeDestroy(int nativeContentViewRenderView);
private native void nativeSetCurrentContentView(int nativeContentViewRenderView,

Powered by Google App Engine
This is Rietveld 408576698