Commit 1b0eca2c authored by Thoren Paulson's avatar Thoren Paulson Committed by Commit Bot

Wait an extra frame to remove surface background.

In ContentViewRenderView, waiting an extra frame to remove the
background prevents flashes of black from Android's default Surface
content, and flashes of the compositor's default background.

Bug: internal b/73804884
Test: repro bug
Change-Id: Ib221403890200be6e842e0d85780d18db859d159
Reviewed-on: https://chromium-review.googlesource.com/1041185Reviewed-by: default avatarBo <boliu@chromium.org>
Commit-Queue: Thoren Paulson <thoren@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555807}
parent 66da0224
...@@ -114,6 +114,12 @@ void ContentViewRenderView::SetOverlayVideoMode( ...@@ -114,6 +114,12 @@ void ContentViewRenderView::SetOverlayVideoMode(
compositor_->SetNeedsComposite(); compositor_->SetNeedsComposite();
} }
void ContentViewRenderView::SetNeedsComposite(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj) {
compositor_->SetNeedsComposite();
}
void ContentViewRenderView::UpdateLayerTreeHost() { void ContentViewRenderView::UpdateLayerTreeHost() {
// TODO(wkorman): Rename Layout to UpdateLayerTreeHost in all Android // TODO(wkorman): Rename Layout to UpdateLayerTreeHost in all Android
// Compositor related classes. // Compositor related classes.
......
...@@ -48,6 +48,8 @@ class ContentViewRenderView : public CompositorClient { ...@@ -48,6 +48,8 @@ class ContentViewRenderView : public CompositorClient {
void SetOverlayVideoMode(JNIEnv* env, void SetOverlayVideoMode(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj, const base::android::JavaParamRef<jobject>& obj,
bool enabled); bool enabled);
void SetNeedsComposite(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
// CompositorClient implementation // CompositorClient implementation
void UpdateLayerTreeHost() override; void UpdateLayerTreeHost() override;
......
...@@ -37,6 +37,8 @@ public class ContentViewRenderView extends FrameLayout { ...@@ -37,6 +37,8 @@ public class ContentViewRenderView extends FrameLayout {
private int mWidth; private int mWidth;
private int mHeight; private int mHeight;
private int mFramesUntilHideBackground;
/** /**
* Constructs a new ContentViewRenderView. * Constructs a new ContentViewRenderView.
* This should be called and the {@link ContentViewRenderView} should be added to the view * This should be called and the {@link ContentViewRenderView} should be added to the view
...@@ -74,8 +76,8 @@ public class ContentViewRenderView extends FrameLayout { ...@@ -74,8 +76,8 @@ public class ContentViewRenderView extends FrameLayout {
@Override @Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
assert mNativeContentViewRenderView != 0; assert mNativeContentViewRenderView != 0;
nativeSurfaceChanged(mNativeContentViewRenderView, nativeSurfaceChanged(
format, width, height, holder.getSurface()); mNativeContentViewRenderView, format, width, height, holder.getSurface());
if (mWebContents != null) { if (mWebContents != null) {
nativeOnPhysicalBackingSizeChanged( nativeOnPhysicalBackingSizeChanged(
mNativeContentViewRenderView, mWebContents, width, height); mNativeContentViewRenderView, mWebContents, width, height);
...@@ -95,6 +97,8 @@ public class ContentViewRenderView extends FrameLayout { ...@@ -95,6 +97,8 @@ public class ContentViewRenderView extends FrameLayout {
mSurfaceView.setVisibility(mSurfaceView.getVisibility()); mSurfaceView.setVisibility(mSurfaceView.getVisibility());
onReadyToRender(); onReadyToRender();
mFramesUntilHideBackground = 2;
} }
@Override @Override
...@@ -208,21 +212,36 @@ public class ContentViewRenderView extends FrameLayout { ...@@ -208,21 +212,36 @@ public class ContentViewRenderView extends FrameLayout {
@CalledByNative @CalledByNative
private void didSwapFrame() { private void didSwapFrame() {
if (mSurfaceView.getBackground() != null) { // When a new surface is created, wait a couple frames to show it to
post(new Runnable() { // prevent flashes of incomplete frames.
@Override public void run() { if (mFramesUntilHideBackground > 1) {
mSurfaceView.setBackgroundResource(0); mFramesUntilHideBackground--;
} // Make sure another frame is always rendered.
}); requestRender();
} else {
if (mSurfaceView.getBackground() != null) {
post(new Runnable() {
@Override
public void run() {
mSurfaceView.setBackgroundResource(0);
}
});
}
} }
} }
private void requestRender() {
if (mNativeContentViewRenderView != 0)
nativeSetNeedsComposite(mNativeContentViewRenderView);
}
private native long nativeInit(WindowAndroid rootWindow); private native long nativeInit(WindowAndroid rootWindow);
private native void nativeDestroy(long nativeContentViewRenderView); private native void nativeDestroy(long nativeContentViewRenderView);
private native void nativeSetCurrentWebContents( private native void nativeSetCurrentWebContents(
long nativeContentViewRenderView, WebContents webContents); long nativeContentViewRenderView, WebContents webContents);
private native void nativeOnPhysicalBackingSizeChanged( private native void nativeOnPhysicalBackingSizeChanged(
long nativeContentViewRenderView, WebContents webContents, int width, int height); long nativeContentViewRenderView, WebContents webContents, int width, int height);
private native void nativeSetNeedsComposite(long nativeContentViewRenderView);
private native void nativeSurfaceCreated(long nativeContentViewRenderView); private native void nativeSurfaceCreated(long nativeContentViewRenderView);
private native void nativeSurfaceDestroyed(long nativeContentViewRenderView); private native void nativeSurfaceDestroyed(long nativeContentViewRenderView);
private native void nativeSurfaceChanged(long nativeContentViewRenderView, private native void nativeSurfaceChanged(long nativeContentViewRenderView,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment