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 550b738e086a0c8ae0daa663b14d65b4061a3103..3369e038d3b553d467004f3800e6e9b7ccb4a532 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 |
@@ -9,7 +9,6 @@ import android.graphics.Bitmap; |
import android.graphics.Canvas; |
import android.graphics.Color; |
import android.graphics.PixelFormat; |
-import android.os.Handler; |
import android.view.Surface; |
import android.view.SurfaceHolder; |
import android.view.SurfaceView; |
@@ -17,7 +16,6 @@ import android.widget.FrameLayout; |
import org.chromium.base.CalledByNative; |
import org.chromium.base.JNINamespace; |
-import org.chromium.base.TraceEvent; |
import org.chromium.ui.base.WindowAndroid; |
/*** |
@@ -27,29 +25,14 @@ import org.chromium.ui.base.WindowAndroid; |
* Note that only one ContentViewCore can be shown at a time. |
*/ |
@JNINamespace("content") |
-public class ContentViewRenderView extends FrameLayout implements WindowAndroid.VSyncClient { |
- private static final int MAX_SWAP_BUFFER_COUNT = 2; |
- |
+public class ContentViewRenderView extends FrameLayout { |
// The native side of this object. |
private long mNativeContentViewRenderView; |
private final SurfaceHolder.Callback mSurfaceCallback; |
private final SurfaceView mSurfaceView; |
- private final WindowAndroid mRootWindow; |
- |
- private int mPendingRenders; |
- private int mPendingSwapBuffers; |
- private boolean mNeedToRender; |
- |
private ContentViewCore mContentViewCore; |
- private final Runnable mRenderRunnable = new Runnable() { |
- @Override |
- public void run() { |
- render(); |
- } |
- }; |
- |
/** |
* Constructs a new ContentViewRenderView that should be can to a view hierarchy. |
* Native code should add/remove the layers to be rendered through the ContentViewLayerRenderer. |
@@ -61,8 +44,6 @@ public class ContentViewRenderView extends FrameLayout implements WindowAndroid. |
mNativeContentViewRenderView = nativeInit(rootWindow.getNativePointer()); |
assert mNativeContentViewRenderView != 0; |
- mRootWindow = rootWindow; |
- rootWindow.setVSyncClient(this); |
mSurfaceView = createSurfaceView(getContext()); |
mSurfaceView.setZOrderMediaOverlay(true); |
mSurfaceCallback = new SurfaceHolder.Callback() { |
@@ -84,9 +65,6 @@ public class ContentViewRenderView extends FrameLayout implements WindowAndroid. |
assert mNativeContentViewRenderView != 0; |
nativeSurfaceCreated(mNativeContentViewRenderView); |
- mPendingSwapBuffers = 0; |
- mPendingRenders = 0; |
- |
onReadyToRender(); |
} |
@@ -104,19 +82,6 @@ public class ContentViewRenderView extends FrameLayout implements WindowAndroid. |
FrameLayout.LayoutParams.MATCH_PARENT)); |
} |
- @Override |
- public void onVSync(long vsyncTimeMicros) { |
- if (mNeedToRender) { |
- if (mPendingSwapBuffers + mPendingRenders <= MAX_SWAP_BUFFER_COUNT) { |
- mNeedToRender = false; |
- mPendingRenders++; |
- render(); |
- } else { |
- TraceEvent.instant("ContentViewRenderView:bail"); |
- } |
- } |
- } |
- |
/** |
* Sets the background color of the surface view. This method is necessary because the |
* background color of ContentViewRenderView itself is covered by the background of |
@@ -134,7 +99,6 @@ public class ContentViewRenderView extends FrameLayout implements WindowAndroid. |
* native resource can be freed. |
*/ |
public void destroy() { |
- mRootWindow.setVSyncClient(null); |
mSurfaceView.getHolder().removeCallback(mSurfaceCallback); |
nativeDestroy(mNativeContentViewRenderView); |
mNativeContentViewRenderView = 0; |
@@ -209,60 +173,13 @@ public class ContentViewRenderView extends FrameLayout implements WindowAndroid. |
} |
@CalledByNative |
- private void requestRender() { |
- boolean rendererHasFrame = |
- mContentViewCore != null && mContentViewCore.consumePendingRendererFrame(); |
- |
- if (rendererHasFrame && mPendingSwapBuffers + mPendingRenders < MAX_SWAP_BUFFER_COUNT) { |
- TraceEvent.instant("requestRender:now"); |
- mNeedToRender = false; |
- mPendingRenders++; |
- |
- // The handler can be null if we are detached from the window. Calling |
- // {@link View#post(Runnable)} properly handles this case, but we lose the front of |
- // queue behavior. That is okay for this edge case. |
- Handler handler = getHandler(); |
- if (handler != null) { |
- handler.postAtFrontOfQueue(mRenderRunnable); |
- } else { |
- post(mRenderRunnable); |
- } |
- } else if (mPendingRenders <= 0) { |
- assert mPendingRenders == 0; |
- TraceEvent.instant("requestRender:later"); |
- mNeedToRender = true; |
- mRootWindow.requestVSyncUpdate(); |
- } |
- } |
- |
- @CalledByNative |
- private void onSwapBuffersCompleted() { |
- TraceEvent.instant("onSwapBuffersCompleted"); |
- |
- if (mPendingSwapBuffers == MAX_SWAP_BUFFER_COUNT && mNeedToRender) requestRender(); |
- if (mPendingSwapBuffers > 0) mPendingSwapBuffers--; |
- } |
- |
- private void render() { |
- if (mPendingRenders > 0) mPendingRenders--; |
- |
- // Waiting for the content view contents to be ready avoids compositing |
- // when the surface texture is still empty. |
- if (mContentViewCore == null || !mContentViewCore.isReady()) { |
Sami
2014/04/16 15:16:30
I think we still need this isReady() check in one
no sievers
2014/05/09 00:30:05
Should be taken care of by crrev.com/268530 now.
|
- return; |
- } |
- |
- boolean didDraw = nativeComposite(mNativeContentViewRenderView); |
- if (didDraw) { |
- mPendingSwapBuffers++; |
- if (mSurfaceView.getBackground() != null) { |
- post(new Runnable() { |
- @Override |
- public void run() { |
- mSurfaceView.setBackgroundResource(0); |
- } |
- }); |
- } |
+ private void onSwapBuffersPosted() { |
+ if (mSurfaceView.getBackground() != null) { |
+ post(new Runnable() { |
+ @Override public void run() { |
+ mSurfaceView.setBackgroundResource(0); |
+ } |
+ }); |
} |
} |
@@ -274,7 +191,6 @@ public class ContentViewRenderView extends FrameLayout implements WindowAndroid. |
private native void nativeSurfaceDestroyed(long nativeContentViewRenderView); |
private native void nativeSurfaceChanged(long nativeContentViewRenderView, |
int format, int width, int height, Surface surface); |
- private native boolean nativeComposite(long nativeContentViewRenderView); |
private native boolean nativeCompositeToBitmap(long nativeContentViewRenderView, Bitmap bitmap); |
private native void nativeSetOverlayVideoMode(long nativeContentViewRenderView, |
boolean enabled); |