summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authoryusufo@chromium.org <yusufo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-12 03:29:58 +0000
committeryusufo@chromium.org <yusufo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-12 03:31:17 +0000
commit090cf2ce996242327f73d1b4af888f174cefc237 (patch)
tree42a6e2b83ee20f524f41c380f94644759f5ba6a7 /content
parentd61c2474e613b45f011dcf1bde88166434fc1c88 (diff)
downloadchromium_src-090cf2ce996242327f73d1b4af888f174cefc237.zip
chromium_src-090cf2ce996242327f73d1b4af888f174cefc237.tar.gz
chromium_src-090cf2ce996242327f73d1b4af888f174cefc237.tar.bz2
Get rid of delayed runnable and change visibility instead for ContentViewRenderView
A better fix to not missing any callbacks during Java initialization is setting the SurfaceView visibility to VISIBLE only after libraries has loaded. This change removes the delayedRunnable setup and adds an assert to make sure we dont have a valid surface before native load. BUG=401581 Review URL: https://codereview.chromium.org/462783002 Cr-Commit-Position: refs/heads/master@{#288901} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288901 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentViewRenderView.java73
1 files changed, 4 insertions, 69 deletions
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 758c8ca..97949f3 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
@@ -16,9 +16,6 @@ import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.ui.base.WindowAndroid;
-import java.util.ArrayList;
-import java.util.List;
-
/***
* This view is used by a ContentView to render its content.
* Call {@link #setCurrentContentViewCore(ContentViewCore)} with the contentViewCore that should be
@@ -30,7 +27,6 @@ public class ContentViewRenderView extends FrameLayout {
// The native side of this object.
private long mNativeContentViewRenderView;
private SurfaceHolder.Callback mSurfaceCallback;
- private List<DelayedSurfaceRunnable> mDelayedSurfaceRunnableList;
private final SurfaceView mSurfaceView;
protected ContentViewCore mContentViewCore;
@@ -38,39 +34,6 @@ public class ContentViewRenderView extends FrameLayout {
private ContentReadbackHandler mContentReadbackHandler;
/**
- * Constructing the SurfaceView early sends surface created notifications
- * before the native library is loaded. This runnable sends the same signals after
- * the library is loaded.
- */
- private class DelayedSurfaceRunnable implements Runnable {
- private final SurfaceHolder mHolder;
- private final int mFormat;
- private final int mWidth;
- private final int mHeight;
-
- /**
- * see https://developer.android.com/reference/android/view/SurfaceHolder.Callback.html#
- * surfaceChanged(android.view.SurfaceHolder, int, int, int)
- */
- public DelayedSurfaceRunnable(SurfaceHolder holder, int format, int width, int height) {
- mHolder = holder;
- mFormat = format;
- mWidth = width;
- mHeight = height;
- }
-
- @Override
- public void run() {
- assert mNativeContentViewRenderView != 0;
- nativeSurfaceChanged(mNativeContentViewRenderView, mFormat, mWidth, mHeight,
- mHolder.getSurface());
- if (mContentViewCore != null) {
- mContentViewCore.onPhysicalBackingSizeChanged(mWidth, mHeight);
- }
- }
- }
-
- /**
* Constructs a new ContentViewRenderView.
* This should be called and the {@link ContentViewRenderView} should be added to the view
* hierarchy before the first draw to avoid a black flash that is seen every time a
@@ -84,34 +47,11 @@ public class ContentViewRenderView extends FrameLayout {
mSurfaceView.setZOrderMediaOverlay(true);
setSurfaceViewBackgroundColor(Color.WHITE);
-
- // Add a placeholder callback which will keep track of the last surfaceChanged call if we
- // get any until the native libraries have been loaded.
- mSurfaceCallback = new SurfaceHolder.Callback() {
- @Override
- public void surfaceDestroyed(SurfaceHolder holder) {
- mDelayedSurfaceRunnableList = null;
- }
-
- @Override
- public void surfaceCreated(SurfaceHolder holder) {
- mDelayedSurfaceRunnableList =
- new ArrayList<ContentViewRenderView.DelayedSurfaceRunnable>();
- }
-
- @Override
- public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
- mDelayedSurfaceRunnableList.add(
- new DelayedSurfaceRunnable(holder, format, width, height));
- return;
- }
- };
- mSurfaceView.getHolder().addCallback(mSurfaceCallback);
-
addView(mSurfaceView,
new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT));
+ mSurfaceView.setVisibility(GONE);
}
/**
@@ -120,10 +60,11 @@ public class ContentViewRenderView extends FrameLayout {
* @param rootWindow The {@link WindowAndroid} this render view should be linked to.
*/
public void onNativeLibraryLoaded(WindowAndroid rootWindow) {
+ assert !mSurfaceView.getHolder().getSurface().isValid() :
+ "Surface created before native library loaded.";
assert rootWindow != null;
mNativeContentViewRenderView = nativeInit(rootWindow.getNativePointer());
assert mNativeContentViewRenderView != 0;
- mSurfaceView.getHolder().removeCallback(mSurfaceCallback);
mSurfaceCallback = new SurfaceHolder.Callback() {
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
@@ -151,6 +92,7 @@ public class ContentViewRenderView extends FrameLayout {
}
};
mSurfaceView.getHolder().addCallback(mSurfaceCallback);
+ mSurfaceView.setVisibility(VISIBLE);
mContentReadbackHandler = new ContentReadbackHandler() {
@Override
@@ -159,13 +101,6 @@ public class ContentViewRenderView extends FrameLayout {
}
};
mContentReadbackHandler.initNativeContentReadbackHandler();
- if (mDelayedSurfaceRunnableList != null) {
- nativeSurfaceCreated(mNativeContentViewRenderView);
- for (int i = 0; i < mDelayedSurfaceRunnableList.size(); i++) {
- mDelayedSurfaceRunnableList.get(i).run();
- }
- mDelayedSurfaceRunnableList = null;
- }
}
/**