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(
compositor_->SetNeedsComposite();
}
void ContentViewRenderView::SetNeedsComposite(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj) {
compositor_->SetNeedsComposite();
}
void ContentViewRenderView::UpdateLayerTreeHost() {
// TODO(wkorman): Rename Layout to UpdateLayerTreeHost in all Android
// Compositor related classes.
......
......@@ -48,6 +48,8 @@ class ContentViewRenderView : public CompositorClient {
void SetOverlayVideoMode(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
bool enabled);
void SetNeedsComposite(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
// CompositorClient implementation
void UpdateLayerTreeHost() override;
......
......@@ -37,6 +37,8 @@ public class ContentViewRenderView extends FrameLayout {
private int mWidth;
private int mHeight;
private int mFramesUntilHideBackground;
/**
* Constructs a new ContentViewRenderView.
* This should be called and the {@link ContentViewRenderView} should be added to the view
......@@ -74,8 +76,8 @@ public class ContentViewRenderView extends FrameLayout {
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
assert mNativeContentViewRenderView != 0;
nativeSurfaceChanged(mNativeContentViewRenderView,
format, width, height, holder.getSurface());
nativeSurfaceChanged(
mNativeContentViewRenderView, format, width, height, holder.getSurface());
if (mWebContents != null) {
nativeOnPhysicalBackingSizeChanged(
mNativeContentViewRenderView, mWebContents, width, height);
......@@ -95,6 +97,8 @@ public class ContentViewRenderView extends FrameLayout {
mSurfaceView.setVisibility(mSurfaceView.getVisibility());
onReadyToRender();
mFramesUntilHideBackground = 2;
}
@Override
......@@ -208,21 +212,36 @@ public class ContentViewRenderView extends FrameLayout {
@CalledByNative
private void didSwapFrame() {
if (mSurfaceView.getBackground() != null) {
post(new Runnable() {
@Override public void run() {
mSurfaceView.setBackgroundResource(0);
}
});
// When a new surface is created, wait a couple frames to show it to
// prevent flashes of incomplete frames.
if (mFramesUntilHideBackground > 1) {
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 void nativeDestroy(long nativeContentViewRenderView);
private native void nativeSetCurrentWebContents(
long nativeContentViewRenderView, WebContents webContents);
private native void nativeOnPhysicalBackingSizeChanged(
long nativeContentViewRenderView, WebContents webContents, int width, int height);
private native void nativeSetNeedsComposite(long nativeContentViewRenderView);
private native void nativeSurfaceCreated(long nativeContentViewRenderView);
private native void nativeSurfaceDestroyed(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