Commit 862bef99 authored by jbauman's avatar jbauman Committed by Commit bot

Set content opacity of DFHAndroid surfacelayer based on renderer frame contents.

The browser updates the overlay video mode flag before the renderer can
send a new frame. This means that when switching from fullscreen to
non-fullscreen the browser was expecting the renderer the fill the frame
completely and wasn't drawing the background, but it was accidentally
leaving part of the frame corrupted and uncleared.

BUG=631866
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_precise_blink_rel

Review-Url: https://codereview.chromium.org/2302023003
Cr-Commit-Position: refs/heads/master@{#417131}
parent 803c4d72
...@@ -281,11 +281,6 @@ void BrowserMediaPlayerManager::DidExitFullscreen(bool release_media_player) { ...@@ -281,11 +281,6 @@ void BrowserMediaPlayerManager::DidExitFullscreen(bool release_media_player) {
#else #else
if (WebContentsDelegate* delegate = web_contents_->GetDelegate()) if (WebContentsDelegate* delegate = web_contents_->GetDelegate())
delegate->ExitFullscreenModeForTab(web_contents_); delegate->ExitFullscreenModeForTab(web_contents_);
if (RenderWidgetHostViewAndroid* view_android =
static_cast<RenderWidgetHostViewAndroid*>(
web_contents_->GetRenderWidgetHostView())) {
view_android->SetOverlayVideoMode(false);
}
Send( Send(
new MediaPlayerMsg_DidExitFullscreen(RoutingID(), fullscreen_player_id_)); new MediaPlayerMsg_DidExitFullscreen(RoutingID(), fullscreen_player_id_));
...@@ -331,14 +326,6 @@ void BrowserMediaPlayerManager::SetVideoSurface(gl::ScopedJavaSurface surface) { ...@@ -331,14 +326,6 @@ void BrowserMediaPlayerManager::SetVideoSurface(gl::ScopedJavaSurface surface) {
video_view_->OnVideoSizeChanged(player->GetVideoWidth(), video_view_->OnVideoSizeChanged(player->GetVideoWidth(),
player->GetVideoHeight()); player->GetVideoHeight());
} }
#if !defined(USE_AURA)
if (RenderWidgetHostViewAndroid* view_android =
static_cast<RenderWidgetHostViewAndroid*>(
web_contents_->GetRenderWidgetHostView())) {
view_android->SetOverlayVideoMode(true);
}
#endif
} }
void BrowserMediaPlayerManager::OnMediaMetadataChanged( void BrowserMediaPlayerManager::OnMediaMetadataChanged(
......
...@@ -509,6 +509,7 @@ void CompositorImpl::CreateLayerTreeHost() { ...@@ -509,6 +509,7 @@ void CompositorImpl::CreateLayerTreeHost() {
host_->GetLayerTree()->SetViewportSize(size_); host_->GetLayerTree()->SetViewportSize(size_);
host_->GetLayerTree()->set_has_transparent_background( host_->GetLayerTree()->set_has_transparent_background(
has_transparent_background_); has_transparent_background_);
host_->GetLayerTree()->set_background_color(SK_ColorBLACK);
host_->GetLayerTree()->SetDeviceScaleFactor(device_scale_factor_); host_->GetLayerTree()->SetDeviceScaleFactor(device_scale_factor_);
if (needs_animate_) if (needs_animate_)
......
...@@ -942,6 +942,7 @@ void RenderWidgetHostViewAndroid::InternalSwapCompositorFrame( ...@@ -942,6 +942,7 @@ void RenderWidgetHostViewAndroid::InternalSwapCompositorFrame(
cc::RenderPass* root_pass = cc::RenderPass* root_pass =
frame.delegated_frame_data->render_pass_list.back().get(); frame.delegated_frame_data->render_pass_list.back().get();
current_surface_size_ = root_pass->output_rect.size(); current_surface_size_ = root_pass->output_rect.size();
bool is_transparent = root_pass->has_transparent_background;
cc::CompositorFrameMetadata metadata = frame.metadata.Clone(); cc::CompositorFrameMetadata metadata = frame.metadata.Clone();
...@@ -971,7 +972,7 @@ void RenderWidgetHostViewAndroid::InternalSwapCompositorFrame( ...@@ -971,7 +972,7 @@ void RenderWidgetHostViewAndroid::InternalSwapCompositorFrame(
// As the metadata update may trigger view invalidation, always call it after // As the metadata update may trigger view invalidation, always call it after
// any potential compositor scheduling. // any potential compositor scheduling.
OnFrameMetadataUpdated(std::move(metadata)); OnFrameMetadataUpdated(std::move(metadata), is_transparent);
} }
void RenderWidgetHostViewAndroid::DestroyDelegatedContent() { void RenderWidgetHostViewAndroid::DestroyDelegatedContent() {
...@@ -1028,7 +1029,7 @@ void RenderWidgetHostViewAndroid::SynchronousFrameMetadata( ...@@ -1028,7 +1029,7 @@ void RenderWidgetHostViewAndroid::SynchronousFrameMetadata(
// This is a subset of OnSwapCompositorFrame() used in the synchronous // This is a subset of OnSwapCompositorFrame() used in the synchronous
// compositor flow. // compositor flow.
OnFrameMetadataUpdated(frame_metadata.Clone()); OnFrameMetadataUpdated(frame_metadata.Clone(), false);
// DevTools ScreenCast support for Android WebView. // DevTools ScreenCast support for Android WebView.
WebContents* web_contents = content_view_core_->GetWebContents(); WebContents* web_contents = content_view_core_->GetWebContents();
...@@ -1045,11 +1046,6 @@ void RenderWidgetHostViewAndroid::SynchronousFrameMetadata( ...@@ -1045,11 +1046,6 @@ void RenderWidgetHostViewAndroid::SynchronousFrameMetadata(
} }
} }
void RenderWidgetHostViewAndroid::SetOverlayVideoMode(bool enabled) {
if (delegated_frame_host_)
delegated_frame_host_->SetContentsOpaque(!enabled);
}
bool RenderWidgetHostViewAndroid::SupportsAnimation() const { bool RenderWidgetHostViewAndroid::SupportsAnimation() const {
// The synchronous (WebView) compositor does not have a proper browser // The synchronous (WebView) compositor does not have a proper browser
// compositor with which to drive animations. // compositor with which to drive animations.
...@@ -1154,7 +1150,8 @@ void RenderWidgetHostViewAndroid::SynchronousCopyContents( ...@@ -1154,7 +1150,8 @@ void RenderWidgetHostViewAndroid::SynchronousCopyContents(
} }
void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated( void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated(
const cc::CompositorFrameMetadata& frame_metadata) { const cc::CompositorFrameMetadata& frame_metadata,
bool is_transparent) {
bool is_mobile_optimized = IsMobileOptimizedFrame(frame_metadata); bool is_mobile_optimized = IsMobileOptimizedFrame(frame_metadata);
gesture_provider_.SetDoubleTapSupportForPageEnabled(!is_mobile_optimized); gesture_provider_.SetDoubleTapSupportForPageEnabled(!is_mobile_optimized);
...@@ -1181,7 +1178,8 @@ void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated( ...@@ -1181,7 +1178,8 @@ void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated(
selection_controller_->OnViewportChanged(viewport_rect); selection_controller_->OnViewportChanged(viewport_rect);
} }
UpdateBackgroundColor(frame_metadata.root_background_color); UpdateBackgroundColor(is_transparent ? SK_ColorTRANSPARENT
: frame_metadata.root_background_color);
// All offsets and sizes are in CSS pixels. // All offsets and sizes are in CSS pixels.
content_view_core_->UpdateFrameInfo( content_view_core_->UpdateFrameInfo(
......
...@@ -241,8 +241,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid ...@@ -241,8 +241,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid
void SynchronousFrameMetadata(cc::CompositorFrameMetadata frame_metadata); void SynchronousFrameMetadata(cc::CompositorFrameMetadata frame_metadata);
void SetOverlayVideoMode(bool enabled);
static void OnContextLost(); static void OnContextLost();
private: private:
...@@ -253,8 +251,8 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid ...@@ -253,8 +251,8 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid
void SendReclaimCompositorResources(uint32_t output_surface_id, void SendReclaimCompositorResources(uint32_t output_surface_id,
bool is_swap_ack); bool is_swap_ack);
void OnFrameMetadataUpdated( void OnFrameMetadataUpdated(const cc::CompositorFrameMetadata& frame_metadata,
const cc::CompositorFrameMetadata& frame_metadata); bool is_transparent);
void ShowInternal(); void ShowInternal();
void HideInternal(); void HideInternal();
......
...@@ -45,7 +45,8 @@ void RequireCallback(cc::SurfaceManager* manager, ...@@ -45,7 +45,8 @@ void RequireCallback(cc::SurfaceManager* manager,
scoped_refptr<cc::SurfaceLayer> CreateSurfaceLayer( scoped_refptr<cc::SurfaceLayer> CreateSurfaceLayer(
cc::SurfaceManager* surface_manager, cc::SurfaceManager* surface_manager,
cc::SurfaceId surface_id, cc::SurfaceId surface_id,
const gfx::Size surface_size) { const gfx::Size surface_size,
bool surface_opaque) {
// manager must outlive compositors using it. // manager must outlive compositors using it.
scoped_refptr<cc::SurfaceLayer> layer = cc::SurfaceLayer::Create( scoped_refptr<cc::SurfaceLayer> layer = cc::SurfaceLayer::Create(
base::Bind(&SatisfyCallback, base::Unretained(surface_manager)), base::Bind(&SatisfyCallback, base::Unretained(surface_manager)),
...@@ -53,7 +54,7 @@ scoped_refptr<cc::SurfaceLayer> CreateSurfaceLayer( ...@@ -53,7 +54,7 @@ scoped_refptr<cc::SurfaceLayer> CreateSurfaceLayer(
layer->SetSurfaceId(surface_id, 1.f, surface_size); layer->SetSurfaceId(surface_id, 1.f, surface_size);
layer->SetBounds(surface_size); layer->SetBounds(surface_size);
layer->SetIsDrawable(true); layer->SetIsDrawable(true);
layer->SetContentsOpaque(true); layer->SetContentsOpaque(surface_opaque);
return layer; return layer;
} }
...@@ -122,7 +123,9 @@ void DelegatedFrameHostAndroid::SubmitCompositorFrame( ...@@ -122,7 +123,9 @@ void DelegatedFrameHostAndroid::SubmitCompositorFrame(
frame.metadata.bottom_controls_height || frame.metadata.bottom_controls_height ||
current_frame_->bottom_controls_shown_ratio != current_frame_->bottom_controls_shown_ratio !=
frame.metadata.bottom_controls_shown_ratio || frame.metadata.bottom_controls_shown_ratio ||
current_frame_->viewport_selection != frame.metadata.selection) { current_frame_->viewport_selection != frame.metadata.selection ||
current_frame_->has_transparent_background !=
root_pass->has_transparent_background) {
DestroyDelegatedContent(); DestroyDelegatedContent();
DCHECK(!content_layer_); DCHECK(!content_layer_);
DCHECK(!current_frame_); DCHECK(!current_frame_);
...@@ -139,11 +142,14 @@ void DelegatedFrameHostAndroid::SubmitCompositorFrame( ...@@ -139,11 +142,14 @@ void DelegatedFrameHostAndroid::SubmitCompositorFrame(
frame.metadata.bottom_controls_height; frame.metadata.bottom_controls_height;
current_frame_->bottom_controls_shown_ratio = current_frame_->bottom_controls_shown_ratio =
frame.metadata.bottom_controls_shown_ratio; frame.metadata.bottom_controls_shown_ratio;
current_frame_->has_transparent_background =
root_pass->has_transparent_background;
current_frame_->viewport_selection = frame.metadata.selection; current_frame_->viewport_selection = frame.metadata.selection;
content_layer_ = content_layer_ =
CreateSurfaceLayer(surface_manager_, current_frame_->surface_id, CreateSurfaceLayer(surface_manager_, current_frame_->surface_id,
current_frame_->surface_size); current_frame_->surface_size,
!current_frame_->has_transparent_background);
view_->GetLayer()->AddChild(content_layer_); view_->GetLayer()->AddChild(content_layer_);
UpdateBackgroundLayer(); UpdateBackgroundLayer();
} }
...@@ -165,7 +171,8 @@ void DelegatedFrameHostAndroid::RequestCopyOfSurface( ...@@ -165,7 +171,8 @@ void DelegatedFrameHostAndroid::RequestCopyOfSurface(
scoped_refptr<cc::Layer> readback_layer = scoped_refptr<cc::Layer> readback_layer =
CreateSurfaceLayer(surface_manager_, current_frame_->surface_id, CreateSurfaceLayer(surface_manager_, current_frame_->surface_id,
current_frame_->surface_size); current_frame_->surface_size,
!current_frame_->has_transparent_background);
readback_layer->SetHideLayerAndSubtree(true); readback_layer->SetHideLayerAndSubtree(true);
compositor->AttachLayerForReadback(readback_layer); compositor->AttachLayerForReadback(readback_layer);
std::unique_ptr<cc::CopyOutputRequest> copy_output_request = std::unique_ptr<cc::CopyOutputRequest> copy_output_request =
...@@ -206,12 +213,6 @@ void DelegatedFrameHostAndroid::UpdateBackgroundColor(SkColor color) { ...@@ -206,12 +213,6 @@ void DelegatedFrameHostAndroid::UpdateBackgroundColor(SkColor color) {
background_layer_->SetBackgroundColor(color); background_layer_->SetBackgroundColor(color);
} }
void DelegatedFrameHostAndroid::SetContentsOpaque(bool opaque) {
if (!content_layer_)
return;
content_layer_->SetContentsOpaque(opaque);
}
void DelegatedFrameHostAndroid::UpdateContainerSizeinDIP( void DelegatedFrameHostAndroid::UpdateContainerSizeinDIP(
const gfx::Size& size_in_dip) { const gfx::Size& size_in_dip) {
container_size_in_dip_ = size_in_dip; container_size_in_dip_ = size_in_dip;
......
...@@ -62,8 +62,6 @@ class UI_ANDROID_EXPORT DelegatedFrameHostAndroid ...@@ -62,8 +62,6 @@ class UI_ANDROID_EXPORT DelegatedFrameHostAndroid
void UpdateBackgroundColor(SkColor color); void UpdateBackgroundColor(SkColor color);
void SetContentsOpaque(bool opaque);
void UpdateContainerSizeinDIP(const gfx::Size& size_in_dip); void UpdateContainerSizeinDIP(const gfx::Size& size_in_dip);
private: private:
...@@ -92,6 +90,7 @@ class UI_ANDROID_EXPORT DelegatedFrameHostAndroid ...@@ -92,6 +90,7 @@ class UI_ANDROID_EXPORT DelegatedFrameHostAndroid
float bottom_controls_height; float bottom_controls_height;
float bottom_controls_shown_ratio; float bottom_controls_shown_ratio;
cc::Selection<gfx::SelectionBound> viewport_selection; cc::Selection<gfx::SelectionBound> viewport_selection;
bool has_transparent_background;
}; };
std::unique_ptr<FrameData> current_frame_; std::unique_ptr<FrameData> current_frame_;
......
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