fixes offscreen rendering issues
This commit is contained in:
parent
d4969783d7
commit
0ad8815bbc
5 changed files with 40 additions and 9 deletions
|
@ -55,6 +55,7 @@
|
||||||
#include "chrome/browser/ssl/security_state_tab_helper.h"
|
#include "chrome/browser/ssl/security_state_tab_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_view_base.h"
|
#include "content/browser/renderer_host/render_widget_host_view_base.h"
|
||||||
|
#include "content/browser/web_contents/web_contents_impl.h"
|
||||||
#include "content/common/view_messages.h"
|
#include "content/common/view_messages.h"
|
||||||
#include "content/public/browser/child_process_security_policy.h"
|
#include "content/public/browser/child_process_security_policy.h"
|
||||||
#include "content/public/browser/favicon_status.h"
|
#include "content/public/browser/favicon_status.h"
|
||||||
|
@ -1726,7 +1727,8 @@ void WebContents::StartPainting() {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
#if defined(ENABLE_OSR)
|
||||||
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
|
const auto* wc_impl =
|
||||||
|
reinterpret_cast<content::WebContentsImpl*>(web_contents());
|
||||||
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
|
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
|
||||||
if (osr_wcv)
|
if (osr_wcv)
|
||||||
osr_wcv->SetPainting(true);
|
osr_wcv->SetPainting(true);
|
||||||
|
@ -1738,7 +1740,8 @@ void WebContents::StopPainting() {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
#if defined(ENABLE_OSR)
|
||||||
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
|
const auto* wc_impl =
|
||||||
|
reinterpret_cast<content::WebContentsImpl*>(web_contents());
|
||||||
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
|
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
|
||||||
if (osr_wcv)
|
if (osr_wcv)
|
||||||
osr_wcv->SetPainting(false);
|
osr_wcv->SetPainting(false);
|
||||||
|
@ -1750,7 +1753,8 @@ bool WebContents::IsPainting() const {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
#if defined(ENABLE_OSR)
|
||||||
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
|
const auto* wc_impl =
|
||||||
|
reinterpret_cast<content::WebContentsImpl*>(web_contents());
|
||||||
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
|
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
|
||||||
|
|
||||||
return osr_wcv && osr_wcv->IsPainting();
|
return osr_wcv && osr_wcv->IsPainting();
|
||||||
|
@ -1764,7 +1768,8 @@ void WebContents::SetFrameRate(int frame_rate) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
#if defined(ENABLE_OSR)
|
||||||
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
|
const auto* wc_impl =
|
||||||
|
reinterpret_cast<content::WebContentsImpl*>(web_contents());
|
||||||
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
|
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
|
||||||
|
|
||||||
if (osr_wcv)
|
if (osr_wcv)
|
||||||
|
@ -1777,7 +1782,8 @@ int WebContents::GetFrameRate() const {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
#if defined(ENABLE_OSR)
|
||||||
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
|
const auto* wc_impl =
|
||||||
|
reinterpret_cast<content::WebContentsImpl*>(web_contents());
|
||||||
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
|
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
|
||||||
|
|
||||||
return osr_wcv ? osr_wcv->GetFrameRate() : 0;
|
return osr_wcv ? osr_wcv->GetFrameRate() : 0;
|
||||||
|
|
|
@ -291,11 +291,14 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
|
||||||
bool is_guest_view_hack = parent_host_view_ != nullptr;
|
bool is_guest_view_hack = parent_host_view_ != nullptr;
|
||||||
#if !defined(OS_MACOSX)
|
#if !defined(OS_MACOSX)
|
||||||
delegated_frame_host_ = base::MakeUnique<content::DelegatedFrameHost>(
|
delegated_frame_host_ = base::MakeUnique<content::DelegatedFrameHost>(
|
||||||
AllocateFrameSinkId(is_guest_view_hack), this);
|
AllocateFrameSinkId(is_guest_view_hack), this,
|
||||||
|
false /* enable_surface_synchronization */);
|
||||||
|
|
||||||
root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
|
root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
local_surface_id_ = local_surface_id_allocator_.GenerateId();
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
CreatePlatformWidget(is_guest_view_hack);
|
CreatePlatformWidget(is_guest_view_hack);
|
||||||
#else
|
#else
|
||||||
|
@ -721,7 +724,7 @@ void OffScreenRenderWidgetHostView::ImeCompositionRangeChanged(
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Size OffScreenRenderWidgetHostView::GetPhysicalBackingSize() const {
|
gfx::Size OffScreenRenderWidgetHostView::GetPhysicalBackingSize() const {
|
||||||
return gfx::ConvertSizeToPixel(scale_factor_, GetRequestedRendererSize());
|
return gfx::ScaleToCeiledSize(GetRequestedRendererSize(), scale_factor_);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Size OffScreenRenderWidgetHostView::GetRequestedRendererSize() const {
|
gfx::Size OffScreenRenderWidgetHostView::GetRequestedRendererSize() const {
|
||||||
|
@ -788,6 +791,10 @@ OffScreenRenderWidgetHostView::DelegatedFrameHostCreateResizeLock() {
|
||||||
return base::MakeUnique<content::CompositorResizeLock>(this, desired_size);
|
return base::MakeUnique<content::CompositorResizeLock>(this, desired_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viz::LocalSurfaceId CefRenderWidgetHostViewOSR::GetLocalSurfaceId() const {
|
||||||
|
return local_surface_id_;
|
||||||
|
}
|
||||||
|
|
||||||
void OffScreenRenderWidgetHostView::OnBeginFrame() {
|
void OffScreenRenderWidgetHostView::OnBeginFrame() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1262,6 +1269,8 @@ void OffScreenRenderWidgetHostView::ResizeRootLayer() {
|
||||||
const gfx::Size& size_in_pixels =
|
const gfx::Size& size_in_pixels =
|
||||||
gfx::ConvertSizeToPixel(scale_factor_, size);
|
gfx::ConvertSizeToPixel(scale_factor_, size);
|
||||||
|
|
||||||
|
local_surface_id_ = local_surface_id_allocator_.GenerateId();
|
||||||
|
|
||||||
GetRootLayer()->SetBounds(gfx::Rect(size));
|
GetRootLayer()->SetBounds(gfx::Rect(size));
|
||||||
GetCompositor()->SetScaleAndSize(scale_factor_, size_in_pixels);
|
GetCompositor()->SetScaleAndSize(scale_factor_, size_in_pixels);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "components/viz/common/frame_sinks/begin_frame_args.h"
|
#include "components/viz/common/frame_sinks/begin_frame_args.h"
|
||||||
#include "components/viz/common/frame_sinks/begin_frame_source.h"
|
#include "components/viz/common/frame_sinks/begin_frame_source.h"
|
||||||
#include "components/viz/common/quads/compositor_frame.h"
|
#include "components/viz/common/quads/compositor_frame.h"
|
||||||
|
#include "components/viz/common/surfaces/local_surface_id_allocator.h"
|
||||||
#include "content/browser/frame_host/render_widget_host_view_guest.h"
|
#include "content/browser/frame_host/render_widget_host_view_guest.h"
|
||||||
#include "content/browser/renderer_host/compositor_resize_lock.h"
|
#include "content/browser/renderer_host/compositor_resize_lock.h"
|
||||||
#include "content/browser/renderer_host/delegated_frame_host.h"
|
#include "content/browser/renderer_host/delegated_frame_host.h"
|
||||||
|
@ -179,6 +180,7 @@ class OffScreenRenderWidgetHostView
|
||||||
bool DelegatedFrameCanCreateResizeLock() const override;
|
bool DelegatedFrameCanCreateResizeLock() const override;
|
||||||
std::unique_ptr<content::CompositorResizeLock>
|
std::unique_ptr<content::CompositorResizeLock>
|
||||||
DelegatedFrameHostCreateResizeLock() override;
|
DelegatedFrameHostCreateResizeLock() override;
|
||||||
|
viz::LocalSurfaceId GetLocalSurfaceId() const override;
|
||||||
void OnBeginFrame() override;
|
void OnBeginFrame() override;
|
||||||
// CompositorResizeLockClient implementation.
|
// CompositorResizeLockClient implementation.
|
||||||
std::unique_ptr<ui::CompositorLock> GetCompositorLock(
|
std::unique_ptr<ui::CompositorLock> GetCompositorLock(
|
||||||
|
@ -274,6 +276,10 @@ class OffScreenRenderWidgetHostView
|
||||||
child_host_view_ = child_view;
|
child_host_view_ = child_view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viz::LocalSurfaceId local_surface_id() const {
|
||||||
|
return local_surface_id_;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetupFrameRate(bool force);
|
void SetupFrameRate(bool force);
|
||||||
void ResizeRootLayer();
|
void ResizeRootLayer();
|
||||||
|
@ -320,6 +326,9 @@ class OffScreenRenderWidgetHostView
|
||||||
|
|
||||||
bool paint_callback_running_;
|
bool paint_callback_running_;
|
||||||
|
|
||||||
|
viz::LocalSurfaceId local_surface_id_;
|
||||||
|
viz::LocalSurfaceIdAllocator local_surface_id_allocator_;
|
||||||
|
|
||||||
std::unique_ptr<ui::Layer> root_layer_;
|
std::unique_ptr<ui::Layer> root_layer_;
|
||||||
std::unique_ptr<ui::Compositor> compositor_;
|
std::unique_ptr<ui::Compositor> compositor_;
|
||||||
std::unique_ptr<content::DelegatedFrameHost> delegated_frame_host_;
|
std::unique_ptr<content::DelegatedFrameHost> delegated_frame_host_;
|
||||||
|
|
|
@ -16,7 +16,10 @@ class MacHelper :
|
||||||
public content::BrowserCompositorMacClient,
|
public content::BrowserCompositorMacClient,
|
||||||
public ui::AcceleratedWidgetMacNSView {
|
public ui::AcceleratedWidgetMacNSView {
|
||||||
public:
|
public:
|
||||||
explicit MacHelper(OffScreenRenderWidgetHostView* view) : view_(view) {}
|
explicit MacHelper(OffScreenRenderWidgetHostView* view) : view_(view) {
|
||||||
|
[this->AcceleratedWidgetGetNSView() setWantsLayer:YES];
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~MacHelper() {}
|
virtual ~MacHelper() {}
|
||||||
|
|
||||||
// content::BrowserCompositorMacClient:
|
// content::BrowserCompositorMacClient:
|
||||||
|
@ -40,6 +43,10 @@ class MacHelper :
|
||||||
|
|
||||||
void BrowserCompositorMacOnBeginFrame() override {}
|
void BrowserCompositorMacOnBeginFrame() override {}
|
||||||
|
|
||||||
|
viz::LocalSurfaceId GetLocalSurfaceId() const override {
|
||||||
|
return view_->local_surface_id();
|
||||||
|
}
|
||||||
|
|
||||||
// ui::AcceleratedWidgetMacNSView:
|
// ui::AcceleratedWidgetMacNSView:
|
||||||
NSView* AcceleratedWidgetGetNSView() const override {
|
NSView* AcceleratedWidgetGetNSView() const override {
|
||||||
return [view_->window()->GetNativeWindow() contentView];
|
return [view_->window()->GetNativeWindow() contentView];
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# If it looks stupid but it works it ain't stupid.
|
# If it looks stupid but it works it ain't stupid.
|
||||||
'variables': {
|
'variables': {
|
||||||
'variables': {
|
'variables': {
|
||||||
'enable_osr%': 0, # FIXME(alexeykuzmin)
|
'enable_osr%': 1, # FIXME(alexeykuzmin)
|
||||||
'enable_pdf_viewer%': 0, # FIXME(deepak1556)
|
'enable_pdf_viewer%': 0, # FIXME(deepak1556)
|
||||||
'enable_run_as_node%': 1,
|
'enable_run_as_node%': 1,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue