fixes offscreen rendering issues

This commit is contained in:
Gellert Hegyi 2018-03-17 23:26:41 +01:00 коммит произвёл Aleksei Kuzmin
Родитель d4969783d7
Коммит 0ad8815bbc
5 изменённых файлов: 40 добавлений и 9 удалений

Просмотреть файл

@ -55,6 +55,7 @@
#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_view_base.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/view_messages.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/favicon_status.h"
@ -1726,7 +1727,8 @@ void WebContents::StartPainting() {
return;
#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());
if (osr_wcv)
osr_wcv->SetPainting(true);
@ -1738,7 +1740,8 @@ void WebContents::StopPainting() {
return;
#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());
if (osr_wcv)
osr_wcv->SetPainting(false);
@ -1750,7 +1753,8 @@ bool WebContents::IsPainting() const {
return false;
#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());
return osr_wcv && osr_wcv->IsPainting();
@ -1764,7 +1768,8 @@ void WebContents::SetFrameRate(int frame_rate) {
return;
#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());
if (osr_wcv)
@ -1777,7 +1782,8 @@ int WebContents::GetFrameRate() const {
return 0;
#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());
return osr_wcv ? osr_wcv->GetFrameRate() : 0;

Просмотреть файл

@ -291,11 +291,14 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
bool is_guest_view_hack = parent_host_view_ != nullptr;
#if !defined(OS_MACOSX)
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));
#endif
local_surface_id_ = local_surface_id_allocator_.GenerateId();
#if defined(OS_MACOSX)
CreatePlatformWidget(is_guest_view_hack);
#else
@ -721,7 +724,7 @@ void OffScreenRenderWidgetHostView::ImeCompositionRangeChanged(
}
gfx::Size OffScreenRenderWidgetHostView::GetPhysicalBackingSize() const {
return gfx::ConvertSizeToPixel(scale_factor_, GetRequestedRendererSize());
return gfx::ScaleToCeiledSize(GetRequestedRendererSize(), scale_factor_);
}
gfx::Size OffScreenRenderWidgetHostView::GetRequestedRendererSize() const {
@ -788,6 +791,10 @@ OffScreenRenderWidgetHostView::DelegatedFrameHostCreateResizeLock() {
return base::MakeUnique<content::CompositorResizeLock>(this, desired_size);
}
viz::LocalSurfaceId CefRenderWidgetHostViewOSR::GetLocalSurfaceId() const {
return local_surface_id_;
}
void OffScreenRenderWidgetHostView::OnBeginFrame() {
}
@ -1262,6 +1269,8 @@ void OffScreenRenderWidgetHostView::ResizeRootLayer() {
const gfx::Size& size_in_pixels =
gfx::ConvertSizeToPixel(scale_factor_, size);
local_surface_id_ = local_surface_id_allocator_.GenerateId();
GetRootLayer()->SetBounds(gfx::Rect(size));
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_source.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/renderer_host/compositor_resize_lock.h"
#include "content/browser/renderer_host/delegated_frame_host.h"
@ -179,6 +180,7 @@ class OffScreenRenderWidgetHostView
bool DelegatedFrameCanCreateResizeLock() const override;
std::unique_ptr<content::CompositorResizeLock>
DelegatedFrameHostCreateResizeLock() override;
viz::LocalSurfaceId GetLocalSurfaceId() const override;
void OnBeginFrame() override;
// CompositorResizeLockClient implementation.
std::unique_ptr<ui::CompositorLock> GetCompositorLock(
@ -274,6 +276,10 @@ class OffScreenRenderWidgetHostView
child_host_view_ = child_view;
}
viz::LocalSurfaceId local_surface_id() const {
return local_surface_id_;
}
private:
void SetupFrameRate(bool force);
void ResizeRootLayer();
@ -320,6 +326,9 @@ class OffScreenRenderWidgetHostView
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::Compositor> compositor_;
std::unique_ptr<content::DelegatedFrameHost> delegated_frame_host_;

Просмотреть файл

@ -16,7 +16,10 @@ class MacHelper :
public content::BrowserCompositorMacClient,
public ui::AcceleratedWidgetMacNSView {
public:
explicit MacHelper(OffScreenRenderWidgetHostView* view) : view_(view) {}
explicit MacHelper(OffScreenRenderWidgetHostView* view) : view_(view) {
[this->AcceleratedWidgetGetNSView() setWantsLayer:YES];
}
virtual ~MacHelper() {}
// content::BrowserCompositorMacClient:
@ -40,6 +43,10 @@ class MacHelper :
void BrowserCompositorMacOnBeginFrame() override {}
viz::LocalSurfaceId GetLocalSurfaceId() const override {
return view_->local_surface_id();
}
// ui::AcceleratedWidgetMacNSView:
NSView* AcceleratedWidgetGetNSView() const override {
return [view_->window()->GetNativeWindow() contentView];

Просмотреть файл

@ -2,7 +2,7 @@
# If it looks stupid but it works it ain't stupid.
'variables': {
'variables': {
'enable_osr%': 0, # FIXME(alexeykuzmin)
'enable_osr%': 1, # FIXME(alexeykuzmin)
'enable_pdf_viewer%': 0, # FIXME(deepak1556)
'enable_run_as_node%': 1,
},