moves setsize call to osr renderwidgethostview

This commit is contained in:
gellert 2016-09-16 20:43:07 +02:00
parent fec5a7d67a
commit 37de2301f7
3 changed files with 14 additions and 9 deletions

View file

@ -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() {

View file

@ -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

View file

@ -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);