fix: fix osr compilation on Windows

This commit is contained in:
Heilig Benedek 2018-08-31 00:44:35 +02:00 committed by Aleksei Kuzmin
parent 8bfad3ace3
commit 1a9e253259
3 changed files with 45 additions and 18 deletions

View file

@ -254,7 +254,8 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
content::RenderWidgetHost* host,
OffScreenRenderWidgetHostView* parent_host_view,
NativeWindow* native_window)
: render_widget_host_(content::RenderWidgetHostImpl::From(host)),
: content::RenderWidgetHostViewBase(host),
render_widget_host_(content::RenderWidgetHostImpl::From(host)),
parent_host_view_(parent_host_view),
native_window_(native_window),
transparent_(transparent),
@ -264,7 +265,7 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
size_(native_window->GetSize()),
painting_(painting),
is_showing_(!render_widget_host_->is_hidden()),
mouse_wheel_phase_handler_(render_widget_host_, this),
mouse_wheel_phase_handler_(this),
weak_ptr_factory_(this) {
DCHECK(render_widget_host_);
bool is_guest_view_hack = parent_host_view_ != nullptr;
@ -283,7 +284,13 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
#if defined(OS_MACOSX)
last_frame_root_background_color_ = SK_ColorTRANSPARENT;
CreatePlatformWidget(is_guest_view_hack);
#else
#endif
bool opaque = SkColorGetA(background_color()) == SK_AlphaOPAQUE;
GetRootLayer()->SetFillsBoundsOpaquely(opaque);
GetRootLayer()->SetColor(background_color());
#if !defined(OS_MACOSX)
// On macOS the ui::Compositor is created/owned by the platform view.
content::ImageTransportFactory* factory =
content::ImageTransportFactory::GetInstance();
@ -397,10 +404,6 @@ void OffScreenRenderWidgetHostView::SetBounds(const gfx::Rect& new_bounds) {
SetSize(new_bounds.size());
}
gfx::Vector2dF OffScreenRenderWidgetHostView::GetLastScrollOffset() const {
return last_scroll_offset_;
}
gfx::NativeView OffScreenRenderWidgetHostView::GetNativeView() const {
return gfx::NativeView();
}
@ -497,6 +500,22 @@ bool OffScreenRenderWidgetHostView::LockMouse() {
void OffScreenRenderWidgetHostView::UnlockMouse() {}
void OffScreenRenderWidgetHostView::TakeFallbackContentFrom(
content::RenderWidgetHostView* view) {
DCHECK(!static_cast<content::RenderWidgetHostViewBase*>(view)
->IsRenderWidgetHostViewChildFrame());
DCHECK(!static_cast<content::RenderWidgetHostViewBase*>(view)
->IsRenderWidgetHostViewGuest());
OffScreenRenderWidgetHostView* view_osr =
static_cast<OffScreenRenderWidgetHostView*>(view);
SetBackgroundColor(view_osr->background_color());
if (GetDelegatedFrameHost() && view_osr->GetDelegatedFrameHost()) {
GetDelegatedFrameHost()->TakeFallbackContentFrom(
view_osr->GetDelegatedFrameHost());
}
host()->GetContentRenderingTimeoutFrom(view_osr->host());
}
void OffScreenRenderWidgetHostView::DidCreateNewRendererCompositorFrameSink(
viz::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink) {
renderer_compositor_frame_sink_ = renderer_compositor_frame_sink;
@ -672,11 +691,6 @@ gfx::Rect OffScreenRenderWidgetHostView::GetBoundsInRootWindow() {
return gfx::Rect(size_);
}
content::RenderWidgetHostImpl*
OffScreenRenderWidgetHostView::GetRenderWidgetHostImpl() const {
return render_widget_host_;
}
viz::SurfaceId OffScreenRenderWidgetHostView::GetCurrentSurfaceId() const {
return GetDelegatedFrameHost()
? GetDelegatedFrameHost()->GetCurrentSurfaceId()
@ -1116,7 +1130,7 @@ void OffScreenRenderWidgetHostView::SendMouseWheelEvent(
blink::WebMouseWheelEvent mouse_wheel_event(event);
mouse_wheel_phase_handler_.SendWheelEndIfNeeded();
mouse_wheel_phase_handler_.SendWheelEndForTouchpadScrollingIfNeeded();
mouse_wheel_phase_handler_.AddPhaseIfNeededAndScheduleEndEvent(
mouse_wheel_event, false);
@ -1291,7 +1305,7 @@ void OffScreenRenderWidgetHostView::ResizeRootLayer(bool force) {
local_surface_id_);
#if defined(OS_MACOSX)
bool resized = browser_compositor_->UpdateNSViewAndDisplay();
bool resized = UpdateNSViewAndDisplay();
#else
bool resized = true;
GetDelegatedFrameHost()->WasResized(local_surface_id_, size,

View file

@ -89,7 +89,6 @@ class OffScreenRenderWidgetHostView
void InitAsChild(gfx::NativeView) override;
void SetSize(const gfx::Size&) override;
void SetBounds(const gfx::Rect&) override;
gfx::Vector2dF GetLastScrollOffset(void) const override;
gfx::NativeView GetNativeView(void) const override;
gfx::NativeViewAccessible GetNativeViewAccessible(void) override;
ui::TextInputClient* GetTextInputClient() override;
@ -106,6 +105,7 @@ class OffScreenRenderWidgetHostView
SkColor background_color() const override;
bool LockMouse(void) override;
void UnlockMouse(void) override;
void TakeFallbackContentFrom(content::RenderWidgetHostView* view) override;
void SetNeedsBeginFrames(bool needs_begin_frames) override;
void SetWantsAnimateOnlyBeginFrames() override;
#if defined(OS_MACOSX)
@ -116,6 +116,7 @@ class OffScreenRenderWidgetHostView
bool IsSpeaking() const override;
bool ShouldContinueToPauseForFrame() override;
void StopSpeaking() override;
bool UpdateNSViewAndDisplay();
#endif // defined(OS_MACOSX)
// content::RenderWidgetHostViewBase:
@ -149,7 +150,6 @@ class OffScreenRenderWidgetHostView
content::RenderWidgetHostViewGuest*) override;
gfx::Vector2d GetOffsetFromRootSurface() override;
gfx::Rect GetBoundsInRootWindow(void) override;
content::RenderWidgetHostImpl* GetRenderWidgetHostImpl() const override;
viz::SurfaceId GetCurrentSurfaceId() const override;
void ImeCompositionRangeChanged(const gfx::Range&,
const std::vector<gfx::Rect>&) override;

View file

@ -10,6 +10,14 @@
#include "content/common/view_messages.h"
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
namespace {
display::Display GetDisplay() {
return display::Screen::GetScreen()->GetDisplayNearestView(nullptr);
}
} // namespace
namespace atom {
class MacHelper : public content::BrowserCompositorMacClient,
@ -33,7 +41,7 @@ class MacHelper : public content::BrowserCompositorMacClient,
return view_->last_frame_root_background_color();
}
void BrowserCompositorMacOnBeginFrame() override {}
void BrowserCompositorMacOnBeginFrame(base::TimeTicks frame_time) override {}
void OnFrameTokenChanged(uint32_t frame_token) override {
view_->render_widget_host()->DidProcessFrame(frame_token);
@ -81,6 +89,11 @@ bool OffScreenRenderWidgetHostView::IsSpeaking() const {
void OffScreenRenderWidgetHostView::StopSpeaking() {}
bool OffScreenRenderWidgetHostView::UpdateNSViewAndDisplay() {
return browser_compositor_->UpdateNSViewAndDisplay(
GetRootLayer()->bounds().size(), GetDisplay());
}
bool OffScreenRenderWidgetHostView::ShouldContinueToPauseForFrame() {
return browser_compositor_->ShouldContinueToPauseForFrame();
}
@ -90,7 +103,7 @@ void OffScreenRenderWidgetHostView::CreatePlatformWidget(
mac_helper_ = new MacHelper(this);
browser_compositor_.reset(new content::BrowserCompositorMac(
mac_helper_, mac_helper_, render_widget_host_->is_hidden(), true,
AllocateFrameSinkId(is_guest_view_hack)));
GetDisplay(), AllocateFrameSinkId(is_guest_view_hack)));
}
void OffScreenRenderWidgetHostView::DestroyPlatformWidget() {