From 37de2301f7ff09f10c619b46d632098d07aa623e Mon Sep 17 00:00:00 2001 From: gellert Date: Fri, 16 Sep 2016 20:43:07 +0200 Subject: [PATCH] moves setsize call to osr renderwidgethostview --- atom/browser/native_window.cc | 8 -------- atom/browser/osr/osr_render_widget_host_view.cc | 8 ++++++++ atom/browser/osr/osr_render_widget_host_view.h | 7 ++++++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 4fa853ca13fa..8dbed6d33df1 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -205,14 +205,6 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) { void NativeWindow::SetSize(const gfx::Size& size, bool animate) { SetBounds(gfx::Rect(GetPosition(), size), animate); - - // In offscreen mode call RenderWidgetHostView's SetSize explicitly - const auto view = web_contents()->GetRenderWidgetHostView(); - if (view) { - auto old_size = view->GetViewBounds().size(); - if (old_size != size) - view->SetSize(size); - } } gfx::Size NativeWindow::GetSize() { diff --git a/atom/browser/osr/osr_render_widget_host_view.cc b/atom/browser/osr/osr_render_widget_host_view.cc index da41ac4c88a4..918fced5036b 100644 --- a/atom/browser/osr/osr_render_widget_host_view.cc +++ b/atom/browser/osr/osr_render_widget_host_view.cc @@ -371,6 +371,8 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView( compositor_->SetRootLayer(root_layer_.get()); #endif + native_window_->AddObserver(this); + ResizeRootLayer(); } @@ -916,4 +918,10 @@ void OffScreenRenderWidgetHostView::ResizeRootLayer() { GetCompositor()->SetScaleAndSize(scale_factor_, size_in_pixels); } +void OffScreenRenderWidgetHostView::OnWindowResize() { + // In offscreen mode call RenderWidgetHostView's SetSize explicitly + auto size = native_window_->GetSize(); + SetSize(size); +} + } // namespace atom diff --git a/atom/browser/osr/osr_render_widget_host_view.h b/atom/browser/osr/osr_render_widget_host_view.h index 4ca2685603ed..8ea3003a4e5c 100644 --- a/atom/browser/osr/osr_render_widget_host_view.h +++ b/atom/browser/osr/osr_render_widget_host_view.h @@ -13,6 +13,7 @@ #endif #include "atom/browser/native_window.h" +#include "atom/browser/native_window_observer.h" #include "atom/browser/osr/osr_output_device.h" #include "base/process/kill.h" #include "base/threading/thread.h" @@ -60,7 +61,8 @@ class MacHelper; class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase, public ui::CompositorDelegate, - public content::DelegatedFrameHostClient { + public content::DelegatedFrameHostClient, + public NativeWindowObserver { public: OffScreenRenderWidgetHostView(bool transparent, const OnPaintCallback& callback, @@ -172,6 +174,9 @@ class OffScreenRenderWidgetHostView bool IsAutoResizeEnabled() const; void OnSetNeedsBeginFrames(bool enabled); + // NativeWindowObserver: + void OnWindowResize() override; + void OnBeginFrameTimerTick(); void SendBeginFrame(base::TimeTicks frame_time, base::TimeDelta vsync_period);