Refactor osr_render_widget_host_view

This commit is contained in:
Cheng Zhao 2016-08-03 13:46:34 +09:00
parent ea8ea1543f
commit 4d85c1a557
5 changed files with 132 additions and 161 deletions

View file

@ -6,27 +6,25 @@
#include <vector> #include <vector>
#include "third_party/WebKit/public/platform/WebScreenInfo.h" #include "base/callback_helpers.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/single_thread_task_runner.h"
#include "base/time/time.h"
#include "cc/output/copy_output_request.h"
#include "cc/scheduler/delay_based_time_source.h"
#include "components/display_compositor/gl_helper.h" #include "components/display_compositor/gl_helper.h"
#include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_delegate.h" #include "content/browser/renderer_host/render_widget_host_delegate.h"
#include "content/public/browser/render_widget_host_view_frame_subscriber.h"
#include "ui/events/latency_info.h"
#include "content/common/view_messages.h" #include "content/common/view_messages.h"
#include "ui/gfx/geometry/dip_util.h" #include "content/public/browser/browser_thread.h"
#include "base/memory/ptr_util.h"
#include "content/public/browser/context_factory.h" #include "content/public/browser/context_factory.h"
#include "base/single_thread_task_runner.h" #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
#include "ui/compositor/layer.h" #include "ui/compositor/layer.h"
#include "ui/compositor/layer_type.h" #include "ui/compositor/layer_type.h"
#include "base/callback_helpers.h" #include "ui/events/latency_info.h"
#include "base/location.h" #include "ui/gfx/geometry/dip_util.h"
#include "base/time/time.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/views/widget/widget.h"
#include "cc/output/copy_output_request.h"
#include "cc/scheduler/delay_based_time_source.h"
#include "content/public/browser/browser_thread.h"
const float kDefaultScaleFactor = 1.0; const float kDefaultScaleFactor = 1.0;
@ -336,38 +334,33 @@ class AtomBeginFrameTimer : public cc::DelayBasedTimeSourceClient {
}; };
OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView( OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
const bool transparent, content::RenderWidgetHost* host, bool transparent,
NativeWindow* native_window): content::RenderWidgetHost* host,
render_widget_host_(content::RenderWidgetHostImpl::From(host)), NativeWindow* native_window)
native_window_(native_window), : render_widget_host_(content::RenderWidgetHostImpl::From(host)),
software_output_device_(NULL), native_window_(native_window),
frame_rate_(60), software_output_device_(nullptr),
frame_rate_threshold_ms_(0), frame_rate_(60),
transparent_(transparent), frame_rate_threshold_ms_(0),
scale_factor_(kDefaultScaleFactor), last_time_(base::Time::Now()),
is_showing_(!render_widget_host_->is_hidden()), transparent_(transparent),
size_(native_window->GetSize()), scale_factor_(kDefaultScaleFactor),
painting_(true), is_showing_(!render_widget_host_->is_hidden()),
delegated_frame_host_(new content::DelegatedFrameHost(this)), size_(native_window->GetSize()),
compositor_widget_(gfx::kNullAcceleratedWidget), painting_(true),
weak_ptr_factory_(this) { root_layer_(new ui::Layer(ui::LAYER_SOLID_COLOR)),
delegated_frame_host_(new content::DelegatedFrameHost(this)),
weak_ptr_factory_(this) {
DCHECK(render_widget_host_); DCHECK(render_widget_host_);
render_widget_host_->SetView(this); render_widget_host_->SetView(this);
last_time_ = base::Time::Now();
root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
CreatePlatformWidget(); CreatePlatformWidget();
#endif #else
#if !defined(OS_MACOSX)
compositor_widget_ = native_window_->GetAcceleratedWidget();
compositor_.reset( compositor_.reset(
new ui::Compositor(content::GetContextFactory(), new ui::Compositor(content::GetContextFactory(),
base::ThreadTaskRunnerHandle::Get())); base::ThreadTaskRunnerHandle::Get()));
compositor_->SetAcceleratedWidget(compositor_widget_); compositor_->SetAcceleratedWidget(native_window_->GetAcceleratedWidget());
#endif #endif
compositor_->SetDelegate(this); compositor_->SetDelegate(this);
compositor_->SetRootLayer(root_layer_.get()); compositor_->SetRootLayer(root_layer_.get());
@ -383,32 +376,6 @@ OffScreenRenderWidgetHostView::~OffScreenRenderWidgetHostView() {
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
DestroyPlatformWidget(); DestroyPlatformWidget();
#endif #endif
if (copy_frame_generator_.get())
copy_frame_generator_.reset(NULL);
delegated_frame_host_.reset(NULL);
compositor_.reset(NULL);
root_layer_.reset(NULL);
}
void OffScreenRenderWidgetHostView::ResizeRootLayer() {
SetupFrameRate(false);
const float orgScaleFactor = scale_factor_;
const bool scaleFactorDidChange = (orgScaleFactor != scale_factor_);
gfx::Size size = GetViewBounds().size();
if (!scaleFactorDidChange && size == root_layer_->bounds().size())
return;
const gfx::Size& size_in_pixels =
gfx::ConvertSizeToPixel(scale_factor_, size);
root_layer_->SetBounds(gfx::Rect(size));
compositor_->SetScaleAndSize(scale_factor_, size_in_pixels);
} }
void OffScreenRenderWidgetHostView::OnBeginFrameTimerTick() { void OffScreenRenderWidgetHostView::OnBeginFrameTimerTick() {
@ -418,8 +385,8 @@ void OffScreenRenderWidgetHostView::OnBeginFrameTimerTick() {
SendBeginFrame(frame_time, vsync_period); SendBeginFrame(frame_time, vsync_period);
} }
void OffScreenRenderWidgetHostView::SendBeginFrame(base::TimeTicks frame_time, void OffScreenRenderWidgetHostView::SendBeginFrame(
base::TimeDelta vsync_period) { base::TimeTicks frame_time, base::TimeDelta vsync_period) {
base::TimeTicks display_time = frame_time + vsync_period; base::TimeTicks display_time = frame_time + vsync_period;
base::TimeDelta estimated_browser_composite_time = base::TimeDelta estimated_browser_composite_time =
@ -448,11 +415,6 @@ bool OffScreenRenderWidgetHostView::OnMessageReceived(
return handled; return handled;
} }
void OffScreenRenderWidgetHostView::SetPaintCallback(
const OnPaintCallback& callback) {
callback_ = callback;
}
void OffScreenRenderWidgetHostView::InitAsChild(gfx::NativeView) { void OffScreenRenderWidgetHostView::InitAsChild(gfx::NativeView) {
} }
@ -483,7 +445,7 @@ gfx::NativeView OffScreenRenderWidgetHostView::GetNativeView() const {
} }
gfx::NativeViewAccessible gfx::NativeViewAccessible
OffScreenRenderWidgetHostView::GetNativeViewAccessible() { OffScreenRenderWidgetHostView::GetNativeViewAccessible() {
return gfx::NativeViewAccessible(); return gfx::NativeViewAccessible();
} }
@ -608,7 +570,6 @@ void OffScreenRenderWidgetHostView::ClearCompositorFrame() {
void OffScreenRenderWidgetHostView::InitAsPopup( void OffScreenRenderWidgetHostView::InitAsPopup(
content::RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { content::RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) {
printf("popup, parent: %p\n", parent_host_view);
} }
void OffScreenRenderWidgetHostView::InitAsFullscreen( void OffScreenRenderWidgetHostView::InitAsFullscreen(
@ -779,13 +740,8 @@ void OffScreenRenderWidgetHostView::DelegatedFrameHostUpdateVSyncParameters(
render_widget_host_->UpdateVSyncParameters(timebase, interval); render_widget_host_->UpdateVSyncParameters(timebase, interval);
} }
bool OffScreenRenderWidgetHostView::InstallTransparency() { void OffScreenRenderWidgetHostView::SetBeginFrameSource(
if (transparent_) { cc::BeginFrameSource* source) {
SetBackgroundColor(SkColor());
compositor_->SetHostHasTransparentBackground(true);
return true;
}
return false;
} }
std::unique_ptr<cc::SoftwareOutputDevice> std::unique_ptr<cc::SoftwareOutputDevice>
@ -801,6 +757,19 @@ std::unique_ptr<cc::SoftwareOutputDevice>
return base::WrapUnique(software_output_device_); return base::WrapUnique(software_output_device_);
} }
bool OffScreenRenderWidgetHostView::InstallTransparency() {
if (transparent_) {
SetBackgroundColor(SkColor());
compositor_->SetHostHasTransparentBackground(true);
return true;
}
return false;
}
bool OffScreenRenderWidgetHostView::IsAutoResizeEnabled() const {
return false;
}
void OffScreenRenderWidgetHostView::OnSetNeedsBeginFrames(bool enabled) { void OffScreenRenderWidgetHostView::OnSetNeedsBeginFrames(bool enabled) {
SetupFrameRate(false); SetupFrameRate(false);
@ -811,36 +780,9 @@ void OffScreenRenderWidgetHostView::OnSetNeedsBeginFrames(bool enabled) {
} }
} }
void OffScreenRenderWidgetHostView::SetupFrameRate(bool force) { void OffScreenRenderWidgetHostView::SetPaintCallback(
if (!force && frame_rate_threshold_ms_ != 0) const OnPaintCallback& callback) {
return; callback_ = callback;
frame_rate_threshold_ms_ = 1000 / frame_rate_;
compositor_->vsync_manager()->SetAuthoritativeVSyncInterval(
base::TimeDelta::FromMilliseconds(frame_rate_threshold_ms_));
if (copy_frame_generator_.get()) {
copy_frame_generator_->set_frame_rate_threshold_ms(
frame_rate_threshold_ms_);
}
if (begin_frame_timer_.get()) {
begin_frame_timer_->SetFrameRateThresholdMs(frame_rate_threshold_ms_);
} else {
begin_frame_timer_.reset(new AtomBeginFrameTimer(
frame_rate_threshold_ms_,
base::Bind(&OffScreenRenderWidgetHostView::OnBeginFrameTimerTick,
weak_ptr_factory_.GetWeakPtr())));
}
}
void OffScreenRenderWidgetHostView::SetBeginFrameSource(
cc::BeginFrameSource* source) {
}
bool OffScreenRenderWidgetHostView::IsAutoResizeEnabled() const {
return false;
} }
void OffScreenRenderWidgetHostView::OnPaint( void OffScreenRenderWidgetHostView::OnPaint(
@ -880,4 +822,46 @@ int OffScreenRenderWidgetHostView::GetFrameRate() const {
return frame_rate_; return frame_rate_;
} }
void OffScreenRenderWidgetHostView::SetupFrameRate(bool force) {
if (!force && frame_rate_threshold_ms_ != 0)
return;
frame_rate_threshold_ms_ = 1000 / frame_rate_;
compositor_->vsync_manager()->SetAuthoritativeVSyncInterval(
base::TimeDelta::FromMilliseconds(frame_rate_threshold_ms_));
if (copy_frame_generator_.get()) {
copy_frame_generator_->set_frame_rate_threshold_ms(
frame_rate_threshold_ms_);
}
if (begin_frame_timer_.get()) {
begin_frame_timer_->SetFrameRateThresholdMs(frame_rate_threshold_ms_);
} else {
begin_frame_timer_.reset(new AtomBeginFrameTimer(
frame_rate_threshold_ms_,
base::Bind(&OffScreenRenderWidgetHostView::OnBeginFrameTimerTick,
weak_ptr_factory_.GetWeakPtr())));
}
}
void OffScreenRenderWidgetHostView::ResizeRootLayer() {
SetupFrameRate(false);
const float orgScaleFactor = scale_factor_;
const bool scaleFactorDidChange = (orgScaleFactor != scale_factor_);
gfx::Size size = GetViewBounds().size();
if (!scaleFactorDidChange && size == root_layer_->bounds().size())
return;
const gfx::Size& size_in_pixels =
gfx::ConvertSizeToPixel(scale_factor_, size);
root_layer_->SetBounds(gfx::Rect(size));
compositor_->SetScaleAndSize(scale_factor_, size_in_pixels);
}
} // namespace atom } // namespace atom

View file

@ -43,11 +43,9 @@
#ifdef __OBJC__ #ifdef __OBJC__
@class CALayer; @class CALayer;
@class NSWindow; @class NSWindow;
@class NSTextInputContext;
#else #else
class CALayer; class CALayer;
class NSWindow; class NSWindow;
class NSTextInputContext;
#endif #endif
#endif #endif
@ -56,19 +54,20 @@ namespace atom {
class AtomCopyFrameGenerator; class AtomCopyFrameGenerator;
class AtomBeginFrameTimer; class AtomBeginFrameTimer;
class OffScreenRenderWidgetHostView: class OffScreenRenderWidgetHostView
public content::RenderWidgetHostViewBase, : public content::RenderWidgetHostViewBase,
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
public ui::AcceleratedWidgetMacNSView, public ui::AcceleratedWidgetMacNSView,
#endif #endif
public ui::CompositorDelegate, public ui::CompositorDelegate,
public content::DelegatedFrameHostClient { public content::DelegatedFrameHostClient {
public: public:
OffScreenRenderWidgetHostView(const bool transparent, OffScreenRenderWidgetHostView(bool transparent,
content::RenderWidgetHost*, NativeWindow*); content::RenderWidgetHost* render_widget_host,
~OffScreenRenderWidgetHostView(); NativeWindow* native_window);
~OffScreenRenderWidgetHostView() override;
// content::RenderWidgetHostView // content::RenderWidgetHostView:
bool OnMessageReceived(const IPC::Message&) override; bool OnMessageReceived(const IPC::Message&) override;
void InitAsChild(gfx::NativeView) override; void InitAsChild(gfx::NativeView) override;
content::RenderWidgetHost* GetRenderWidgetHost(void) const override; content::RenderWidgetHost* GetRenderWidgetHost(void) const override;
@ -91,7 +90,6 @@ class OffScreenRenderWidgetHostView:
bool LockMouse(void) override; bool LockMouse(void) override;
void UnlockMouse(void) override; void UnlockMouse(void) override;
bool GetScreenColorProfile(std::vector<char>*) override; bool GetScreenColorProfile(std::vector<char>*) override;
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
ui::AcceleratedWidgetMac* GetAcceleratedWidgetMac() const override; ui::AcceleratedWidgetMac* GetAcceleratedWidgetMac() const override;
void SetActive(bool active) override; void SetActive(bool active) override;
@ -102,7 +100,7 @@ class OffScreenRenderWidgetHostView:
void StopSpeaking() override; void StopSpeaking() override;
#endif // defined(OS_MACOSX) #endif // defined(OS_MACOSX)
// content::RenderWidgetHostViewBase // content::RenderWidgetHostViewBase:
void OnSwapCompositorFrame(uint32_t, std::unique_ptr<cc::CompositorFrame>) void OnSwapCompositorFrame(uint32_t, std::unique_ptr<cc::CompositorFrame>)
override; override;
void ClearCompositorFrame(void) override; void ClearCompositorFrame(void) override;
@ -116,13 +114,11 @@ class OffScreenRenderWidgetHostView:
void RenderProcessGone(base::TerminationStatus, int) override; void RenderProcessGone(base::TerminationStatus, int) override;
void Destroy(void) override; void Destroy(void) override;
void SetTooltipText(const base::string16 &) override; void SetTooltipText(const base::string16 &) override;
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
void SelectionChanged(const base::string16& text, void SelectionChanged(const base::string16& text,
size_t offset, size_t offset,
const gfx::Range& range) override; const gfx::Range& range) override;
#endif #endif
void SelectionBoundsChanged(const ViewHostMsg_SelectionBounds_Params &) void SelectionBoundsChanged(const ViewHostMsg_SelectionBounds_Params &)
override; override;
void CopyFromCompositingSurface(const gfx::Rect &, void CopyFromCompositingSurface(const gfx::Rect &,
@ -149,7 +145,7 @@ class OffScreenRenderWidgetHostView:
gfx::Size GetPhysicalBackingSize() const override; gfx::Size GetPhysicalBackingSize() const override;
gfx::Size GetRequestedRendererSize() const override; gfx::Size GetRequestedRendererSize() const override;
// content::DelegatedFrameHostClient // content::DelegatedFrameHostClient:
int DelegatedFrameHostGetGpuMemoryBufferClientId(void) const; int DelegatedFrameHostGetGpuMemoryBufferClientId(void) const;
ui::Layer *DelegatedFrameHostGetLayer(void) const override; ui::Layer *DelegatedFrameHostGetLayer(void) const override;
bool DelegatedFrameHostIsVisible(void) const override; bool DelegatedFrameHostIsVisible(void) const override;
@ -168,35 +164,32 @@ class OffScreenRenderWidgetHostView:
const base::TimeTicks &, const base::TimeDelta &) override; const base::TimeTicks &, const base::TimeDelta &) override;
void SetBeginFrameSource(cc::BeginFrameSource* source) override; void SetBeginFrameSource(cc::BeginFrameSource* source) override;
bool InstallTransparency(); // ui::CompositorDelegate:
bool IsAutoResizeEnabled() const;
std::unique_ptr<cc::SoftwareOutputDevice> CreateSoftwareOutputDevice( std::unique_ptr<cc::SoftwareOutputDevice> CreateSoftwareOutputDevice(
ui::Compositor* compositor) override; ui::Compositor* compositor) override;
bool InstallTransparency();
bool IsAutoResizeEnabled() const;
void OnSetNeedsBeginFrames(bool enabled); void OnSetNeedsBeginFrames(bool enabled);
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// AcceleratedWidgetMacNSView implementation. // ui::AcceleratedWidgetMacNSView:
NSView* AcceleratedWidgetGetNSView() const override; NSView* AcceleratedWidgetGetNSView() const override;
void AcceleratedWidgetGetVSyncParameters( void AcceleratedWidgetGetVSyncParameters(
base::TimeTicks* timebase, base::TimeDelta* interval) const override; base::TimeTicks* timebase, base::TimeDelta* interval) const override;
void AcceleratedWidgetSwapCompleted() override; void AcceleratedWidgetSwapCompleted() override;
#endif // defined(OS_MACOSX) #endif // defined(OS_MACOSX)
ui::Compositor* compositor() const { return compositor_.get(); }
content::RenderWidgetHostImpl* render_widget_host() const
{ return render_widget_host_; }
void OnBeginFrameTimerTick(); void OnBeginFrameTimerTick();
void SendBeginFrame(base::TimeTicks frame_time, void SendBeginFrame(base::TimeTicks frame_time,
base::TimeDelta vsync_period); base::TimeDelta vsync_period);
#if defined(OS_MACOSX)
void CreatePlatformWidget(); void CreatePlatformWidget();
void DestroyPlatformWidget(); void DestroyPlatformWidget();
#endif
void SetPaintCallback(const OnPaintCallback& callback); void SetPaintCallback(const OnPaintCallback& callback);
void OnPaint(const gfx::Rect& damage_rect, void OnPaint(const gfx::Rect& damage_rect,
const gfx::Size& bitmap_size, const gfx::Size& bitmap_size,
void* bitmap_pixels); void* bitmap_pixels);
@ -206,16 +199,18 @@ class OffScreenRenderWidgetHostView:
void SetFrameRate(int frame_rate); void SetFrameRate(int frame_rate);
int GetFrameRate() const; int GetFrameRate() const;
private:
ui::Compositor* compositor() const { return compositor_.get(); }
content::RenderWidgetHostImpl* render_widget_host() const
{ return render_widget_host_; }
private:
void SetupFrameRate(bool force); void SetupFrameRate(bool force);
void ResizeRootLayer(); void ResizeRootLayer();
// Weak ptrs.
content::RenderWidgetHostImpl* render_widget_host_; content::RenderWidgetHostImpl* render_widget_host_;
NativeWindow* native_window_; NativeWindow* native_window_;
std::unique_ptr<AtomCopyFrameGenerator> copy_frame_generator_;
std::unique_ptr<AtomBeginFrameTimer> begin_frame_timer_;
OffScreenOutputDevice* software_output_device_; OffScreenOutputDevice* software_output_device_;
OnPaintCallback callback_; OnPaintCallback callback_;
@ -232,32 +227,24 @@ private:
gfx::Size size_; gfx::Size size_;
bool painting_; bool painting_;
std::unique_ptr<content::DelegatedFrameHost> delegated_frame_host_;
std::unique_ptr<ui::Compositor> compositor_;
gfx::AcceleratedWidget compositor_widget_;
std::unique_ptr<ui::Layer> root_layer_; std::unique_ptr<ui::Layer> root_layer_;
std::unique_ptr<ui::Compositor> compositor_;
std::unique_ptr<content::DelegatedFrameHost> delegated_frame_host_;
std::unique_ptr<AtomCopyFrameGenerator> copy_frame_generator_;
std::unique_ptr<AtomBeginFrameTimer> begin_frame_timer_;
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
NSWindow* window_; NSWindow* window_;
CALayer* background_layer_; CALayer* background_layer_;
std::unique_ptr<content::BrowserCompositorMac> browser_compositor_; std::unique_ptr<content::BrowserCompositorMac> browser_compositor_;
NSTextInputContext* text_input_context_osr_mac_;
// Selected text on the renderer. // Selected text on the renderer.
std::string selected_text_; std::string selected_text_;
// The current composition character range and its bounds.
gfx::Range composition_range_;
std::vector<gfx::Rect> composition_bounds_;
// The current caret bounds.
gfx::Rect caret_rect_;
// The current first selection bounds.
gfx::Rect first_selection_rect_;
#endif #endif
base::WeakPtrFactory<OffScreenRenderWidgetHostView> weak_ptr_factory_; base::WeakPtrFactory<OffScreenRenderWidgetHostView> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(OffScreenRenderWidgetHostView); DISALLOW_COPY_AND_ASSIGN(OffScreenRenderWidgetHostView);
}; };

View file

@ -10,8 +10,7 @@
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h" #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
ui::AcceleratedWidgetMac* ui::AcceleratedWidgetMac*
atom::OffScreenRenderWidgetHostView::GetAcceleratedWidgetMac() atom::OffScreenRenderWidgetHostView::GetAcceleratedWidgetMac() const {
const {
if (browser_compositor_) if (browser_compositor_)
return browser_compositor_->accelerated_widget_mac(); return browser_compositor_->accelerated_widget_mac();
return nullptr; return nullptr;

View file

@ -6,9 +6,9 @@
namespace atom { namespace atom {
OffScreenWebContentsView::OffScreenWebContentsView(bool transparent): OffScreenWebContentsView::OffScreenWebContentsView(bool transparent)
transparent_(transparent), : transparent_(transparent),
web_contents_(nullptr) { web_contents_(nullptr) {
} }
OffScreenWebContentsView::~OffScreenWebContentsView() { OffScreenWebContentsView::~OffScreenWebContentsView() {
@ -67,7 +67,7 @@ content::RenderWidgetHostViewBase*
content::RenderWidgetHost* render_widget_host, bool is_guest_view_hack) { content::RenderWidgetHost* render_widget_host, bool is_guest_view_hack) {
auto relay = NativeWindowRelay::FromWebContents(web_contents_); auto relay = NativeWindowRelay::FromWebContents(web_contents_);
view_ = new OffScreenRenderWidgetHostView(transparent_, render_widget_host, view_ = new OffScreenRenderWidgetHostView(transparent_, render_widget_host,
relay->window.get()); relay->window.get());
return view_; return view_;
} }
@ -76,7 +76,7 @@ content::RenderWidgetHostViewBase*
content::RenderWidgetHost* render_widget_host) { content::RenderWidgetHost* render_widget_host) {
auto relay = NativeWindowRelay::FromWebContents(web_contents_); auto relay = NativeWindowRelay::FromWebContents(web_contents_);
view_ = new OffScreenRenderWidgetHostView(transparent_, render_widget_host, view_ = new OffScreenRenderWidgetHostView(transparent_, render_widget_host,
relay->window.get()); relay->window.get());
return view_; return view_;
} }

View file

@ -63,6 +63,7 @@ class OffScreenWebContentsView : public content::WebContentsView,
private: private:
const bool transparent_; const bool transparent_;
// Weak refs.
OffScreenRenderWidgetHostView* view_; OffScreenRenderWidgetHostView* view_;
content::WebContents* web_contents_; content::WebContents* web_contents_;
}; };