upgrades offscreen rendering to latest chromium

This commit is contained in:
Gellert Hegyi 2017-10-19 21:04:21 +02:00 committed by Cheng Zhao
parent c9b7fc2922
commit 5d79dbc9a1
5 changed files with 29 additions and 28 deletions

View file

@ -84,12 +84,16 @@ void OffScreenOutputDevice::SetActive(bool active, bool paint) {
return;
active_ = active;
if (active_ && paint)
if (!active_ && !pending_damage_rect_.IsEmpty() && paint)
OnPaint(gfx::Rect(viewport_pixel_size_));
}
void OffScreenOutputDevice::OnPaint(const gfx::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_));
if (rect.IsEmpty())

View file

@ -35,6 +35,7 @@ class OffScreenOutputDevice : public cc::SoftwareOutputDevice {
std::unique_ptr<SkCanvas> canvas_;
std::unique_ptr<SkBitmap> bitmap_;
gfx::Rect pending_damage_rect_;
DISALLOW_COPY_AND_ASSIGN(OffScreenOutputDevice);
};

View file

@ -16,7 +16,7 @@
#include "base/time/time.h"
#include "cc/output/copy_output_request.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/render_widget_host_delegate.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
@ -378,9 +378,8 @@ void OffScreenRenderWidgetHostView::SendBeginFrame(
DCHECK(begin_frame_args.IsValid());
begin_frame_number_++;
render_widget_host_->Send(new ViewMsg_BeginFrame(
render_widget_host_->GetRoutingID(),
begin_frame_args));
if (renderer_compositor_frame_sink_)
renderer_compositor_frame_sink_->OnBeginFrame(begin_frame_args);
}
bool OffScreenRenderWidgetHostView::OnMessageReceived(
@ -528,7 +527,7 @@ void OffScreenRenderWidgetHostView::UnlockMouse() {
}
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;
if (GetDelegatedFrameHost()) {
GetDelegatedFrameHost()->DidCreateNewRendererCompositorFrameSink(
@ -537,7 +536,7 @@ void OffScreenRenderWidgetHostView::DidCreateNewRendererCompositorFrameSink(
}
void OffScreenRenderWidgetHostView::SubmitCompositorFrame(
const cc::LocalSurfaceId& local_surface_id,
const viz::LocalSurfaceId& local_surface_id,
cc::CompositorFrame frame) {
TRACE_EVENT0("electron",
"OffScreenRenderWidgetHostView::SubmitCompositorFrame");
@ -778,8 +777,7 @@ OffScreenRenderWidgetHostView::DelegatedFrameHostCreateResizeLock() {
return base::MakeUnique<content::CompositorResizeLock>(this, desired_size);
}
void
OffScreenRenderWidgetHostView::OnBeginFrame(const cc::BeginFrameArgs& args) {
void OffScreenRenderWidgetHostView::OnBeginFrame() {
}
std::unique_ptr<ui::CompositorLock>
@ -796,7 +794,7 @@ void OffScreenRenderWidgetHostView::CompositorResizeLockEnded() {
bool OffScreenRenderWidgetHostView::TransformPointToLocalCoordSpace(
const gfx::Point& point,
const cc::SurfaceId& original_surface,
const viz::SurfaceId& original_surface,
gfx::Point* transformed_point) {
// Transformations use physical pixels rather than DIP, so conversion
// is necessary.
@ -1014,7 +1012,7 @@ void OffScreenRenderWidgetHostView::OnPaint(
void OffScreenRenderWidgetHostView::OnPopupPaint(
const gfx::Rect& damage_rect, const SkBitmap& bitmap) {
if (popup_host_view_ && popup_bitmap_.get())
bitmap.deepCopyTo(popup_bitmap_.get());
popup_bitmap_.reset(new SkBitmap(bitmap));
InvalidateBounds(popup_host_view_->popup_position_);
}
@ -1055,10 +1053,11 @@ void OffScreenRenderWidgetHostView::WasResized() {
}
void OffScreenRenderWidgetHostView::ProcessKeyboardEvent(
const content::NativeWebKeyboardEvent& event) {
const content::NativeWebKeyboardEvent& event,
const ui::LatencyInfo& latency) {
if (!render_widget_host_)
return;
render_widget_host_->ForwardKeyboardEvent(event);
render_widget_host_->ForwardKeyboardEventWithLatencyInfo(event, latency);
}
void OffScreenRenderWidgetHostView::ProcessMouseEvent(
@ -1254,7 +1253,7 @@ void OffScreenRenderWidgetHostView::ResizeRootLayer() {
GetCompositor()->SetScaleAndSize(scale_factor_, size_in_pixels);
}
cc::FrameSinkId OffScreenRenderWidgetHostView::AllocateFrameSinkId(
viz::FrameSinkId OffScreenRenderWidgetHostView::AllocateFrameSinkId(
bool is_guest_view_hack) {
// GuestViews have two RenderWidgetHostViews and so we need to make sure
// we don't have FrameSinkId collisions.
@ -1264,7 +1263,7 @@ cc::FrameSinkId OffScreenRenderWidgetHostView::AllocateFrameSinkId(
content::ImageTransportFactory::GetInstance();
return is_guest_view_hack
? factory->GetContextFactoryPrivate()->AllocateFrameSinkId()
: cc::FrameSinkId(base::checked_cast<uint32_t>(
: viz::FrameSinkId(base::checked_cast<uint32_t>(
render_widget_host_->GetProcess()->GetID()),
base::checked_cast<uint32_t>(
render_widget_host_->GetRoutingID()));

View file

@ -116,9 +116,9 @@ class OffScreenRenderWidgetHostView
// content::RenderWidgetHostViewBase:
void DidCreateNewRendererCompositorFrameSink(
cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink)
cc::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink)
override;
void SubmitCompositorFrame(const cc::LocalSurfaceId& local_surface_id,
void SubmitCompositorFrame(const viz::LocalSurfaceId& local_surface_id,
cc::CompositorFrame frame) override;
void ClearCompositorFrame(void) override;
@ -176,7 +176,7 @@ class OffScreenRenderWidgetHostView
bool DelegatedFrameCanCreateResizeLock() const override;
std::unique_ptr<content::CompositorResizeLock>
DelegatedFrameHostCreateResizeLock() override;
void OnBeginFrame(const cc::BeginFrameArgs& args) override;
void OnBeginFrame() override;
// CompositorResizeLockClient implementation.
std::unique_ptr<ui::CompositorLock> GetCompositorLock(
ui::CompositorLockClient* client) override;
@ -185,7 +185,7 @@ class OffScreenRenderWidgetHostView
bool TransformPointToLocalCoordSpace(
const gfx::Point& point,
const cc::SurfaceId& original_surface,
const viz::SurfaceId& original_surface,
gfx::Point* transformed_point) override;
bool TransformPointToCoordSpaceForView(
const gfx::Point& point,
@ -237,7 +237,8 @@ class OffScreenRenderWidgetHostView
void WasResized();
void ProcessKeyboardEvent(
const content::NativeWebKeyboardEvent& event) override;
const content::NativeWebKeyboardEvent& event,
const ui::LatencyInfo& latency) override;
void ProcessMouseEvent(const blink::WebMouseEvent& event,
const ui::LatencyInfo& latency) override;
void ProcessMouseWheelEvent(const blink::WebMouseWheelEvent& event,
@ -274,7 +275,7 @@ class OffScreenRenderWidgetHostView
void SetupFrameRate(bool force);
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
// opaqueness changes.
@ -337,7 +338,7 @@ class OffScreenRenderWidgetHostView
std::string selected_text_;
#endif
cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink_;
cc::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink_;
SkColor background_color_;

View file

@ -38,12 +38,8 @@ class MacHelper :
return color;
}
void BrowserCompositorMacSendBeginFrame(
const cc::BeginFrameArgs& args) override {
view_->render_widget_host()->Send(
new ViewMsg_BeginFrame(view_->render_widget_host()->GetRoutingID(),
args));
}
void BrowserCompositorMacOnBeginFrame() override {}
// ui::AcceleratedWidgetMacNSView:
NSView* AcceleratedWidgetGetNSView() const override {
return [view_->window()->GetNativeWindow() contentView];