| Index: content/browser/renderer_host/offscreen_canvas_surface_impl.cc
|
| diff --git a/content/browser/renderer_host/offscreen_canvas_surface_impl.cc b/content/browser/renderer_host/offscreen_canvas_surface_impl.cc
|
| index 29679540fa365f8c20961cffd571b7762c55ddf2..c03b8d94037ac95026b6b7f91d97e1aed4154d5d 100644
|
| --- a/content/browser/renderer_host/offscreen_canvas_surface_impl.cc
|
| +++ b/content/browser/renderer_host/offscreen_canvas_surface_impl.cc
|
| @@ -12,12 +12,16 @@
|
| #include "content/browser/compositor/surface_utils.h"
|
| #include "content/browser/renderer_host/offscreen_canvas_surface_manager.h"
|
| #include "content/public/browser/browser_thread.h"
|
| -#include "mojo/public/cpp/bindings/strong_binding.h"
|
|
|
| namespace content {
|
|
|
| -OffscreenCanvasSurfaceImpl::OffscreenCanvasSurfaceImpl()
|
| - : id_allocator_(new cc::SurfaceIdAllocator()) {}
|
| +OffscreenCanvasSurfaceImpl::OffscreenCanvasSurfaceImpl(
|
| + const cc::FrameSinkId& frame_sink_id,
|
| + blink::mojom::OffscreenCanvasSurfaceClientPtr client)
|
| + : client_(std::move(client)), frame_sink_id_(frame_sink_id) {
|
| + OffscreenCanvasSurfaceManager::GetInstance()
|
| + ->RegisterOffscreenCanvasSurfaceInstance(frame_sink_id_, this);
|
| +}
|
|
|
| OffscreenCanvasSurfaceImpl::~OffscreenCanvasSurfaceImpl() {
|
| if (frame_sink_id_.is_valid()) {
|
| @@ -28,34 +32,30 @@ OffscreenCanvasSurfaceImpl::~OffscreenCanvasSurfaceImpl() {
|
|
|
| // static
|
| void OffscreenCanvasSurfaceImpl::Create(
|
| - mojo::InterfaceRequest<blink::mojom::OffscreenCanvasSurface> request) {
|
| - mojo::MakeStrongBinding(base::MakeUnique<OffscreenCanvasSurfaceImpl>(),
|
| - std::move(request));
|
| + const cc::FrameSinkId& frame_sink_id,
|
| + blink::mojom::OffscreenCanvasSurfaceClientPtr client,
|
| + blink::mojom::OffscreenCanvasSurfaceRequest request) {
|
| + std::unique_ptr<OffscreenCanvasSurfaceImpl> impl =
|
| + base::MakeUnique<OffscreenCanvasSurfaceImpl>(frame_sink_id,
|
| + std::move(client));
|
| + OffscreenCanvasSurfaceImpl* surface_service = impl.get();
|
| + surface_service->binding_ =
|
| + mojo::MakeStrongBinding(std::move(impl), std::move(request));
|
| }
|
|
|
| -void OffscreenCanvasSurfaceImpl::GetSurfaceId(GetSurfaceIdCallback callback) {
|
| - DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| - if (frame_sink_id_.is_valid()) {
|
| - // This IPC should be only called once for each HTMLCanvasElement. In this
|
| - // case, frame_sink_id_ is still unset.
|
| - // As the browser makes no assumption of correct behavior of renderer, in
|
| - // an unwanted situation when this function is invoked twice, we need to
|
| - // unregister the instance from manager.
|
| - OffscreenCanvasSurfaceManager::GetInstance()
|
| - ->UnregisterOffscreenCanvasSurfaceInstance(frame_sink_id_);
|
| - mojo::ReportBadMessage(
|
| - "The same OffscreenCanvasSurfaceImpl is registered to "
|
| - "OffscreenCanvasSurfaceManager twice.");
|
| +void OffscreenCanvasSurfaceImpl::OnSurfaceCreated(
|
| + const cc::SurfaceId& surface_id,
|
| + const gfx::Size& frame_size,
|
| + float device_scale_factor) {
|
| + DCHECK_EQ(surface_id.frame_sink_id(), frame_sink_id_);
|
| + if (!current_local_frame_id_.is_valid() ||
|
| + surface_id.local_frame_id() != current_local_frame_id_) {
|
| + current_local_frame_id_ = surface_id.local_frame_id();
|
| + if (client_) {
|
| + client_->OnSurfaceCreated(surface_id, frame_size.width(),
|
| + frame_size.height(), device_scale_factor);
|
| + }
|
| }
|
| -
|
| - frame_sink_id_ = AllocateFrameSinkId();
|
| - cc::SurfaceId surface_id =
|
| - cc::SurfaceId(frame_sink_id_, id_allocator_->GenerateId());
|
| -
|
| - OffscreenCanvasSurfaceManager::GetInstance()
|
| - ->RegisterOffscreenCanvasSurfaceInstance(frame_sink_id_, this);
|
| -
|
| - std::move(callback).Run(surface_id);
|
| }
|
|
|
| void OffscreenCanvasSurfaceImpl::Require(const cc::SurfaceId& surface_id,
|
|
|