upgrades offscreen rendering to latest chromium
This commit is contained in:
parent
c9b7fc2922
commit
5d79dbc9a1
5 changed files with 29 additions and 28 deletions
|
@ -84,12 +84,16 @@ void OffScreenOutputDevice::SetActive(bool active, bool paint) {
|
||||||
return;
|
return;
|
||||||
active_ = active;
|
active_ = active;
|
||||||
|
|
||||||
if (active_ && paint)
|
if (!active_ && !pending_damage_rect_.IsEmpty() && paint)
|
||||||
OnPaint(gfx::Rect(viewport_pixel_size_));
|
OnPaint(gfx::Rect(viewport_pixel_size_));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffScreenOutputDevice::OnPaint(const gfx::Rect& damage_rect) {
|
void OffScreenOutputDevice::OnPaint(const gfx::Rect& damage_rect) {
|
||||||
gfx::Rect rect = damage_rect;
|
gfx::Rect rect = damage_rect;
|
||||||
|
if (!pending_damage_rect_.IsEmpty()) {
|
||||||
|
rect.Union(pending_damage_rect_);
|
||||||
|
pending_damage_rect_.SetRect(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
rect.Intersect(gfx::Rect(viewport_pixel_size_));
|
rect.Intersect(gfx::Rect(viewport_pixel_size_));
|
||||||
if (rect.IsEmpty())
|
if (rect.IsEmpty())
|
||||||
|
|
|
@ -35,6 +35,7 @@ class OffScreenOutputDevice : public cc::SoftwareOutputDevice {
|
||||||
|
|
||||||
std::unique_ptr<SkCanvas> canvas_;
|
std::unique_ptr<SkCanvas> canvas_;
|
||||||
std::unique_ptr<SkBitmap> bitmap_;
|
std::unique_ptr<SkBitmap> bitmap_;
|
||||||
|
gfx::Rect pending_damage_rect_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(OffScreenOutputDevice);
|
DISALLOW_COPY_AND_ASSIGN(OffScreenOutputDevice);
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include "base/time/time.h"
|
#include "base/time/time.h"
|
||||||
#include "cc/output/copy_output_request.h"
|
#include "cc/output/copy_output_request.h"
|
||||||
#include "cc/scheduler/delay_based_time_source.h"
|
#include "cc/scheduler/delay_based_time_source.h"
|
||||||
#include "components/viz/display_compositor/gl_helper.h"
|
#include "components/viz/common/gl_helper.h"
|
||||||
#include "content/browser/renderer_host/compositor_resize_lock.h"
|
#include "content/browser/renderer_host/compositor_resize_lock.h"
|
||||||
#include "content/browser/renderer_host/render_widget_host_delegate.h"
|
#include "content/browser/renderer_host/render_widget_host_delegate.h"
|
||||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||||
|
@ -378,9 +378,8 @@ void OffScreenRenderWidgetHostView::SendBeginFrame(
|
||||||
DCHECK(begin_frame_args.IsValid());
|
DCHECK(begin_frame_args.IsValid());
|
||||||
begin_frame_number_++;
|
begin_frame_number_++;
|
||||||
|
|
||||||
render_widget_host_->Send(new ViewMsg_BeginFrame(
|
if (renderer_compositor_frame_sink_)
|
||||||
render_widget_host_->GetRoutingID(),
|
renderer_compositor_frame_sink_->OnBeginFrame(begin_frame_args);
|
||||||
begin_frame_args));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OffScreenRenderWidgetHostView::OnMessageReceived(
|
bool OffScreenRenderWidgetHostView::OnMessageReceived(
|
||||||
|
@ -528,7 +527,7 @@ void OffScreenRenderWidgetHostView::UnlockMouse() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffScreenRenderWidgetHostView::DidCreateNewRendererCompositorFrameSink(
|
void OffScreenRenderWidgetHostView::DidCreateNewRendererCompositorFrameSink(
|
||||||
cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink) {
|
cc::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink) {
|
||||||
renderer_compositor_frame_sink_ = renderer_compositor_frame_sink;
|
renderer_compositor_frame_sink_ = renderer_compositor_frame_sink;
|
||||||
if (GetDelegatedFrameHost()) {
|
if (GetDelegatedFrameHost()) {
|
||||||
GetDelegatedFrameHost()->DidCreateNewRendererCompositorFrameSink(
|
GetDelegatedFrameHost()->DidCreateNewRendererCompositorFrameSink(
|
||||||
|
@ -537,7 +536,7 @@ void OffScreenRenderWidgetHostView::DidCreateNewRendererCompositorFrameSink(
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffScreenRenderWidgetHostView::SubmitCompositorFrame(
|
void OffScreenRenderWidgetHostView::SubmitCompositorFrame(
|
||||||
const cc::LocalSurfaceId& local_surface_id,
|
const viz::LocalSurfaceId& local_surface_id,
|
||||||
cc::CompositorFrame frame) {
|
cc::CompositorFrame frame) {
|
||||||
TRACE_EVENT0("electron",
|
TRACE_EVENT0("electron",
|
||||||
"OffScreenRenderWidgetHostView::SubmitCompositorFrame");
|
"OffScreenRenderWidgetHostView::SubmitCompositorFrame");
|
||||||
|
@ -778,8 +777,7 @@ OffScreenRenderWidgetHostView::DelegatedFrameHostCreateResizeLock() {
|
||||||
return base::MakeUnique<content::CompositorResizeLock>(this, desired_size);
|
return base::MakeUnique<content::CompositorResizeLock>(this, desired_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void OffScreenRenderWidgetHostView::OnBeginFrame() {
|
||||||
OffScreenRenderWidgetHostView::OnBeginFrame(const cc::BeginFrameArgs& args) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<ui::CompositorLock>
|
std::unique_ptr<ui::CompositorLock>
|
||||||
|
@ -796,7 +794,7 @@ void OffScreenRenderWidgetHostView::CompositorResizeLockEnded() {
|
||||||
|
|
||||||
bool OffScreenRenderWidgetHostView::TransformPointToLocalCoordSpace(
|
bool OffScreenRenderWidgetHostView::TransformPointToLocalCoordSpace(
|
||||||
const gfx::Point& point,
|
const gfx::Point& point,
|
||||||
const cc::SurfaceId& original_surface,
|
const viz::SurfaceId& original_surface,
|
||||||
gfx::Point* transformed_point) {
|
gfx::Point* transformed_point) {
|
||||||
// Transformations use physical pixels rather than DIP, so conversion
|
// Transformations use physical pixels rather than DIP, so conversion
|
||||||
// is necessary.
|
// is necessary.
|
||||||
|
@ -1014,7 +1012,7 @@ void OffScreenRenderWidgetHostView::OnPaint(
|
||||||
void OffScreenRenderWidgetHostView::OnPopupPaint(
|
void OffScreenRenderWidgetHostView::OnPopupPaint(
|
||||||
const gfx::Rect& damage_rect, const SkBitmap& bitmap) {
|
const gfx::Rect& damage_rect, const SkBitmap& bitmap) {
|
||||||
if (popup_host_view_ && popup_bitmap_.get())
|
if (popup_host_view_ && popup_bitmap_.get())
|
||||||
bitmap.deepCopyTo(popup_bitmap_.get());
|
popup_bitmap_.reset(new SkBitmap(bitmap));
|
||||||
InvalidateBounds(popup_host_view_->popup_position_);
|
InvalidateBounds(popup_host_view_->popup_position_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1055,10 +1053,11 @@ void OffScreenRenderWidgetHostView::WasResized() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffScreenRenderWidgetHostView::ProcessKeyboardEvent(
|
void OffScreenRenderWidgetHostView::ProcessKeyboardEvent(
|
||||||
const content::NativeWebKeyboardEvent& event) {
|
const content::NativeWebKeyboardEvent& event,
|
||||||
|
const ui::LatencyInfo& latency) {
|
||||||
if (!render_widget_host_)
|
if (!render_widget_host_)
|
||||||
return;
|
return;
|
||||||
render_widget_host_->ForwardKeyboardEvent(event);
|
render_widget_host_->ForwardKeyboardEventWithLatencyInfo(event, latency);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffScreenRenderWidgetHostView::ProcessMouseEvent(
|
void OffScreenRenderWidgetHostView::ProcessMouseEvent(
|
||||||
|
@ -1254,7 +1253,7 @@ void OffScreenRenderWidgetHostView::ResizeRootLayer() {
|
||||||
GetCompositor()->SetScaleAndSize(scale_factor_, size_in_pixels);
|
GetCompositor()->SetScaleAndSize(scale_factor_, size_in_pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc::FrameSinkId OffScreenRenderWidgetHostView::AllocateFrameSinkId(
|
viz::FrameSinkId OffScreenRenderWidgetHostView::AllocateFrameSinkId(
|
||||||
bool is_guest_view_hack) {
|
bool is_guest_view_hack) {
|
||||||
// GuestViews have two RenderWidgetHostViews and so we need to make sure
|
// GuestViews have two RenderWidgetHostViews and so we need to make sure
|
||||||
// we don't have FrameSinkId collisions.
|
// we don't have FrameSinkId collisions.
|
||||||
|
@ -1264,7 +1263,7 @@ cc::FrameSinkId OffScreenRenderWidgetHostView::AllocateFrameSinkId(
|
||||||
content::ImageTransportFactory::GetInstance();
|
content::ImageTransportFactory::GetInstance();
|
||||||
return is_guest_view_hack
|
return is_guest_view_hack
|
||||||
? factory->GetContextFactoryPrivate()->AllocateFrameSinkId()
|
? factory->GetContextFactoryPrivate()->AllocateFrameSinkId()
|
||||||
: cc::FrameSinkId(base::checked_cast<uint32_t>(
|
: viz::FrameSinkId(base::checked_cast<uint32_t>(
|
||||||
render_widget_host_->GetProcess()->GetID()),
|
render_widget_host_->GetProcess()->GetID()),
|
||||||
base::checked_cast<uint32_t>(
|
base::checked_cast<uint32_t>(
|
||||||
render_widget_host_->GetRoutingID()));
|
render_widget_host_->GetRoutingID()));
|
||||||
|
|
|
@ -116,9 +116,9 @@ class OffScreenRenderWidgetHostView
|
||||||
|
|
||||||
// content::RenderWidgetHostViewBase:
|
// content::RenderWidgetHostViewBase:
|
||||||
void DidCreateNewRendererCompositorFrameSink(
|
void DidCreateNewRendererCompositorFrameSink(
|
||||||
cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink)
|
cc::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink)
|
||||||
override;
|
override;
|
||||||
void SubmitCompositorFrame(const cc::LocalSurfaceId& local_surface_id,
|
void SubmitCompositorFrame(const viz::LocalSurfaceId& local_surface_id,
|
||||||
cc::CompositorFrame frame) override;
|
cc::CompositorFrame frame) override;
|
||||||
|
|
||||||
void ClearCompositorFrame(void) override;
|
void ClearCompositorFrame(void) override;
|
||||||
|
@ -176,7 +176,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;
|
||||||
void OnBeginFrame(const cc::BeginFrameArgs& args) override;
|
void OnBeginFrame() override;
|
||||||
// CompositorResizeLockClient implementation.
|
// CompositorResizeLockClient implementation.
|
||||||
std::unique_ptr<ui::CompositorLock> GetCompositorLock(
|
std::unique_ptr<ui::CompositorLock> GetCompositorLock(
|
||||||
ui::CompositorLockClient* client) override;
|
ui::CompositorLockClient* client) override;
|
||||||
|
@ -185,7 +185,7 @@ class OffScreenRenderWidgetHostView
|
||||||
|
|
||||||
bool TransformPointToLocalCoordSpace(
|
bool TransformPointToLocalCoordSpace(
|
||||||
const gfx::Point& point,
|
const gfx::Point& point,
|
||||||
const cc::SurfaceId& original_surface,
|
const viz::SurfaceId& original_surface,
|
||||||
gfx::Point* transformed_point) override;
|
gfx::Point* transformed_point) override;
|
||||||
bool TransformPointToCoordSpaceForView(
|
bool TransformPointToCoordSpaceForView(
|
||||||
const gfx::Point& point,
|
const gfx::Point& point,
|
||||||
|
@ -237,7 +237,8 @@ class OffScreenRenderWidgetHostView
|
||||||
void WasResized();
|
void WasResized();
|
||||||
|
|
||||||
void ProcessKeyboardEvent(
|
void ProcessKeyboardEvent(
|
||||||
const content::NativeWebKeyboardEvent& event) override;
|
const content::NativeWebKeyboardEvent& event,
|
||||||
|
const ui::LatencyInfo& latency) override;
|
||||||
void ProcessMouseEvent(const blink::WebMouseEvent& event,
|
void ProcessMouseEvent(const blink::WebMouseEvent& event,
|
||||||
const ui::LatencyInfo& latency) override;
|
const ui::LatencyInfo& latency) override;
|
||||||
void ProcessMouseWheelEvent(const blink::WebMouseWheelEvent& event,
|
void ProcessMouseWheelEvent(const blink::WebMouseWheelEvent& event,
|
||||||
|
@ -274,7 +275,7 @@ class OffScreenRenderWidgetHostView
|
||||||
void SetupFrameRate(bool force);
|
void SetupFrameRate(bool force);
|
||||||
void ResizeRootLayer();
|
void ResizeRootLayer();
|
||||||
|
|
||||||
cc::FrameSinkId AllocateFrameSinkId(bool is_guest_view_hack);
|
viz::FrameSinkId AllocateFrameSinkId(bool is_guest_view_hack);
|
||||||
|
|
||||||
// Applies background color without notifying the RenderWidget about
|
// Applies background color without notifying the RenderWidget about
|
||||||
// opaqueness changes.
|
// opaqueness changes.
|
||||||
|
@ -337,7 +338,7 @@ class OffScreenRenderWidgetHostView
|
||||||
std::string selected_text_;
|
std::string selected_text_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink_;
|
cc::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink_;
|
||||||
|
|
||||||
SkColor background_color_;
|
SkColor background_color_;
|
||||||
|
|
||||||
|
|
|
@ -38,12 +38,8 @@ class MacHelper :
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserCompositorMacSendBeginFrame(
|
void BrowserCompositorMacOnBeginFrame() override {}
|
||||||
const cc::BeginFrameArgs& args) override {
|
|
||||||
view_->render_widget_host()->Send(
|
|
||||||
new ViewMsg_BeginFrame(view_->render_widget_host()->GetRoutingID(),
|
|
||||||
args));
|
|
||||||
}
|
|
||||||
// ui::AcceleratedWidgetMacNSView:
|
// ui::AcceleratedWidgetMacNSView:
|
||||||
NSView* AcceleratedWidgetGetNSView() const override {
|
NSView* AcceleratedWidgetGetNSView() const override {
|
||||||
return [view_->window()->GetNativeWindow() contentView];
|
return [view_->window()->GetNativeWindow() contentView];
|
||||||
|
|
Loading…
Reference in a new issue