diff --git a/shell/browser/osr/osr_render_widget_host_view.cc b/shell/browser/osr/osr_render_widget_host_view.cc index efeecef96127..afe4c5ee5656 100644 --- a/shell/browser/osr/osr_render_widget_host_view.cc +++ b/shell/browser/osr/osr_render_widget_host_view.cc @@ -230,6 +230,7 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView( ResizeRootLayer(false); render_widget_host_->SetView(this); + render_widget_host_->render_frame_metadata_provider()->AddObserver(this); if (content::GpuDataManager::GetInstance()->HardwareAccelerationEnabled()) { video_consumer_ = std::make_unique( @@ -240,7 +241,21 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView( } } +void OffScreenRenderWidgetHostView::OnLocalSurfaceIdChanged( + const cc::RenderFrameMetadata& metadata) { + if (metadata.local_surface_id) { + bool changed = delegated_frame_host_allocator_.UpdateFromChild( + *metadata.local_surface_id); + + if (changed) { + ResizeRootLayer(true); + } + } +} + OffScreenRenderWidgetHostView::~OffScreenRenderWidgetHostView() { + render_widget_host_->render_frame_metadata_provider()->RemoveObserver(this); + // Marking the DelegatedFrameHost as removed from the window hierarchy is // necessary to remove all connections to its old ui::Compositor. if (is_showing_) diff --git a/shell/browser/osr/osr_render_widget_host_view.h b/shell/browser/osr/osr_render_widget_host_view.h index fec8525118c5..b674f7cfbcf6 100644 --- a/shell/browser/osr/osr_render_widget_host_view.h +++ b/shell/browser/osr/osr_render_widget_host_view.h @@ -59,9 +59,11 @@ typedef base::RepeatingCallback OnPaintCallback; typedef base::RepeatingCallback OnPopupPaintCallback; -class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase, - public ui::CompositorDelegate, - public OffscreenViewProxyObserver { +class OffScreenRenderWidgetHostView + : public content::RenderWidgetHostViewBase, + public content::RenderFrameMetadataProvider::Observer, + public ui::CompositorDelegate, + public OffscreenViewProxyObserver { public: OffScreenRenderWidgetHostView(bool transparent, bool painting, @@ -175,6 +177,15 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase, RenderWidgetHostViewBase* target_view, gfx::PointF* transformed_point) override; + // RenderFrameMetadataProvider::Observer: + void OnRenderFrameMetadataChangedBeforeActivation( + const cc::RenderFrameMetadata& metadata) override {} + void OnRenderFrameMetadataChangedAfterActivation( + base::TimeTicks activation_time) override {} + void OnRenderFrameSubmission() override {} + void OnLocalSurfaceIdChanged( + const cc::RenderFrameMetadata& metadata) override; + // ui::CompositorDelegate: bool IsOffscreen() const override; std::unique_ptr CreateHostDisplayClient(