| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/renderer_host/offscreen_canvas_frame_receiver_impl.h" | 5 #include "content/browser/renderer_host/offscreen_canvas_frame_receiver_impl.h" |
| 6 | 6 |
| 7 #include "cc/surfaces/surface.h" | 7 #include "cc/surfaces/surface.h" |
| 8 #include "cc/surfaces/surface_manager.h" | 8 #include "cc/surfaces/surface_manager.h" |
| 9 #include "content/browser/compositor/surface_utils.h" | 9 #include "content/browser/compositor/surface_utils.h" |
| 10 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 | 12 |
| 13 // static | 13 // static |
| 14 void OffscreenCanvasFrameReceiverImpl::Create( | 14 void OffscreenCanvasFrameReceiverImpl::Create( |
| 15 mojo::InterfaceRequest<blink::mojom::OffscreenCanvasFrameReceiver> | 15 mojo::InterfaceRequest<blink::mojom::OffscreenCanvasFrameReceiver> |
| 16 request) { | 16 request) { |
| 17 // |binding_| will take ownership of OffscreenCanvasFrameReceiverImpl | 17 // |binding_| will take ownership of OffscreenCanvasFrameReceiverImpl |
| 18 new OffscreenCanvasFrameReceiverImpl(std::move(request)); | 18 new OffscreenCanvasFrameReceiverImpl(std::move(request)); |
| 19 } | 19 } |
| 20 | 20 |
| 21 OffscreenCanvasFrameReceiverImpl::OffscreenCanvasFrameReceiverImpl( | 21 OffscreenCanvasFrameReceiverImpl::OffscreenCanvasFrameReceiverImpl( |
| 22 mojo::InterfaceRequest<blink::mojom::OffscreenCanvasFrameReceiver> request) | 22 mojo::InterfaceRequest<blink::mojom::OffscreenCanvasFrameReceiver> request) |
| 23 : binding_(this, std::move(request)) {} | 23 : binding_(this, std::move(request)) {} |
| 24 | 24 |
| 25 OffscreenCanvasFrameReceiverImpl::~OffscreenCanvasFrameReceiverImpl() {} | 25 OffscreenCanvasFrameReceiverImpl::~OffscreenCanvasFrameReceiverImpl() { |
| 26 if (surface_factory_) { |
| 27 if (!GetSurfaceManager()) { |
| 28 // Inform SurfaceFactory that SurfaceManager's no longer alive to |
| 29 // avoid its destruction error. |
| 30 surface_factory_->DidDestroySurfaceManager(); |
| 31 } else { |
| 32 GetSurfaceManager()->InvalidateSurfaceClientId(surface_id_.client_id()); |
| 33 } |
| 34 surface_factory_->Destroy(surface_id_); |
| 35 } |
| 36 } |
| 26 | 37 |
| 27 void OffscreenCanvasFrameReceiverImpl::SubmitCompositorFrame( | 38 void OffscreenCanvasFrameReceiverImpl::SubmitCompositorFrame( |
| 28 const cc::SurfaceId& surface_id, | 39 const cc::SurfaceId& surface_id, |
| 29 cc::CompositorFrame frame) { | 40 cc::CompositorFrame frame) { |
| 30 cc::Surface* surface = GetSurfaceManager()->GetSurfaceForId(surface_id); | 41 if (!surface_factory_) { |
| 31 if (surface) { | 42 cc::SurfaceManager* manager = GetSurfaceManager(); |
| 32 surface->QueueFrame(std::move(frame), base::Closure()); | 43 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(manager, this); |
| 44 surface_factory_->Create(surface_id); |
| 45 |
| 46 GetSurfaceManager()->RegisterSurfaceClientId(surface_id.client_id()); |
| 47 } |
| 48 if (surface_id_.is_null()) { |
| 49 surface_id_ = surface_id; |
| 33 } | 50 } |
| 34 // If surface doet not exist, drop the frame. | 51 surface_factory_->SubmitCompositorFrame(surface_id, std::move(frame), |
| 52 base::Closure()); |
| 35 } | 53 } |
| 36 | 54 |
| 55 // TODO(619136): Implement cc::SurfaceFactoryClient functions for resources |
| 56 // return. |
| 57 void OffscreenCanvasFrameReceiverImpl::ReturnResources( |
| 58 const cc::ReturnedResourceArray& resources) {} |
| 59 |
| 60 void OffscreenCanvasFrameReceiverImpl::WillDrawSurface( |
| 61 const cc::SurfaceId& id, |
| 62 const gfx::Rect& damage_rect) {} |
| 63 |
| 64 void OffscreenCanvasFrameReceiverImpl::SetBeginFrameSource( |
| 65 cc::BeginFrameSource* begin_frame_source) {} |
| 66 |
| 37 } // namespace content | 67 } // namespace content |
| OLD | NEW |