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 0d196af3873c39d03234d7e5511953845727ec82..92eaa7c10cd98dc16ee04b089eb101ed620aa515 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 |
@@ -43,7 +43,7 @@ public class ContentViewRenderView extends FrameLayout { |
private int mPendingSwapBuffers; |
private boolean mNeedToRender; |
- private ContentView mCurrentContentView; |
+ protected ContentView mCurrentContentView; |
private final Runnable mRenderRunnable = new Runnable() { |
@Override |
@@ -60,7 +60,7 @@ public class ContentViewRenderView extends FrameLayout { |
public ContentViewRenderView(Context context, WindowAndroid rootWindow) { |
super(context); |
assert rootWindow != null; |
- mNativeContentViewRenderView = nativeInit(rootWindow.getNativePointer()); |
+ nativeInit(rootWindow.getNativePointer()); |
assert mNativeContentViewRenderView != 0; |
mSurfaceView = createSurfaceView(getContext()); |
@@ -79,14 +79,7 @@ public class ContentViewRenderView extends FrameLayout { |
@Override |
public void surfaceCreated(SurfaceHolder holder) { |
- setSurfaceViewBackgroundColor(Color.WHITE); |
- |
- assert mNativeContentViewRenderView != 0; |
- nativeSurfaceCreated(mNativeContentViewRenderView); |
- |
- mPendingSwapBuffers = 0; |
- mPendingRenders = 0; |
- |
+ ContentViewRenderView.this.surfaceCreated(); |
onReadyToRender(); |
} |
@@ -105,6 +98,18 @@ public class ContentViewRenderView extends FrameLayout { |
FrameLayout.LayoutParams.MATCH_PARENT)); |
} |
+ @CalledByNative |
+ private void clearNativePtr() { |
+ assert mNativeContentViewRenderView != 0; |
+ mNativeContentViewRenderView = 0; |
+ } |
+ |
+ @CalledByNative |
+ private void setNativePtr(long nativePtr) { |
+ assert mNativeContentViewRenderView == 0; |
+ mNativeContentViewRenderView = nativePtr; |
+ } |
+ |
private class VSyncAdapter implements VSyncManager.Provider, VSyncMonitor.Listener { |
private final VSyncMonitor mVSyncMonitor; |
private boolean mVSyncNotificationEnabled; |
@@ -218,7 +223,7 @@ public class ContentViewRenderView extends FrameLayout { |
if (contentViewCore != null) { |
contentViewCore.onPhysicalBackingSizeChanged(getWidth(), getHeight()); |
- mVSyncAdapter.setVSyncListener(contentViewCore.getVSyncListener(mVSyncAdapter)); |
+ setVSyncListener(contentViewCore); |
} |
} |
@@ -230,6 +235,20 @@ public class ContentViewRenderView extends FrameLayout { |
} |
/** |
+ * Gives inheriting classes a way to carry out tasks on the surfaceCreated() call |
+ * for mSurfaceCallback. |
+ */ |
+ protected void surfaceCreated() { |
+ setSurfaceViewBackgroundColor(Color.WHITE); |
+ |
+ assert mNativeContentViewRenderView != 0; |
+ nativeSurfaceCreated(mNativeContentViewRenderView); |
+ |
+ mPendingSwapBuffers = 0; |
+ mPendingRenders = 0; |
+ } |
+ |
+ /** |
* This method could be subclassed optionally to provide a custom SurfaceView object to |
* this ContentViewRenderView. |
* @param context The context used to create the SurfaceView object. |
@@ -258,6 +277,15 @@ public class ContentViewRenderView extends FrameLayout { |
} |
/** |
+ * Sets the VSyncListener to mVSync adapter to the provided listener from the |
+ * given ContentViewCore. |
+ * @param contentViewCore ContentViewCore instance go get the listener from. |
+ */ |
+ protected void setVSyncListener(ContentViewCore contentViewCore) { |
+ mVSyncAdapter.setVSyncListener(contentViewCore.getVSyncListener(mVSyncAdapter)); |
+ } |
+ |
+ /** |
* Enter or leave overlay video mode. |
* @param enabled Whether overlay mode is enabled. |
*/ |
@@ -306,7 +334,10 @@ public class ContentViewRenderView extends FrameLayout { |
if (mPendingSwapBuffers > 0) mPendingSwapBuffers--; |
} |
- private void render() { |
+ /** |
+ * Calls Composite on the native side, finishing the compositing task for current frame. |
+ */ |
+ protected void render() { |
if (mPendingRenders > 0) mPendingRenders--; |
// Waiting for the content view contents to be ready avoids compositing |
@@ -331,7 +362,7 @@ public class ContentViewRenderView extends FrameLayout { |
} |
} |
- private native long nativeInit(long rootWindowNativePointer); |
+ private native void nativeInit(long rootWindowNativePointer); |
private native void nativeDestroy(long nativeContentViewRenderView); |
private native void nativeSetCurrentContentView(long nativeContentViewRenderView, |
long nativeContentView); |