| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/renderer_host/offscreen_canvas_frame_receiver_impl.h" | |
| 6 | |
| 7 #include "cc/surfaces/surface.h" | |
| 8 #include "cc/surfaces/surface_manager.h" | |
| 9 #include "content/browser/compositor/surface_utils.h" | |
| 10 #include "mojo/public/cpp/bindings/strong_binding.h" | |
| 11 | |
| 12 namespace content { | |
| 13 | |
| 14 OffscreenCanvasFrameReceiverImpl::OffscreenCanvasFrameReceiverImpl() {} | |
| 15 | |
| 16 OffscreenCanvasFrameReceiverImpl::~OffscreenCanvasFrameReceiverImpl() { | |
| 17 if (surface_factory_) { | |
| 18 if (!GetSurfaceManager()) { | |
| 19 // Inform SurfaceFactory that SurfaceManager's no longer alive to | |
| 20 // avoid its destruction error. | |
| 21 surface_factory_->DidDestroySurfaceManager(); | |
| 22 } else { | |
| 23 GetSurfaceManager()->InvalidateSurfaceClientId(surface_id_.client_id()); | |
| 24 } | |
| 25 surface_factory_->Destroy(surface_id_); | |
| 26 } | |
| 27 } | |
| 28 | |
| 29 // static | |
| 30 void OffscreenCanvasFrameReceiverImpl::Create( | |
| 31 blink::mojom::OffscreenCanvasFrameReceiverRequest request) { | |
| 32 mojo::MakeStrongBinding(base::MakeUnique<OffscreenCanvasFrameReceiverImpl>(), | |
| 33 std::move(request)); | |
| 34 } | |
| 35 | |
| 36 void OffscreenCanvasFrameReceiverImpl::SubmitCompositorFrame( | |
| 37 const cc::SurfaceId& surface_id, | |
| 38 cc::CompositorFrame frame) { | |
| 39 if (!surface_factory_) { | |
| 40 cc::SurfaceManager* manager = GetSurfaceManager(); | |
| 41 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(manager, this); | |
| 42 surface_factory_->Create(surface_id); | |
| 43 | |
| 44 GetSurfaceManager()->RegisterSurfaceClientId(surface_id.client_id()); | |
| 45 } | |
| 46 if (surface_id_.is_null()) { | |
| 47 surface_id_ = surface_id; | |
| 48 } | |
| 49 surface_factory_->SubmitCompositorFrame(surface_id, std::move(frame), | |
| 50 base::Closure()); | |
| 51 } | |
| 52 | |
| 53 // TODO(619136): Implement cc::SurfaceFactoryClient functions for resources | |
| 54 // return. | |
| 55 void OffscreenCanvasFrameReceiverImpl::ReturnResources( | |
| 56 const cc::ReturnedResourceArray& resources) {} | |
| 57 | |
| 58 void OffscreenCanvasFrameReceiverImpl::WillDrawSurface( | |
| 59 const cc::SurfaceId& id, | |
| 60 const gfx::Rect& damage_rect) {} | |
| 61 | |
| 62 void OffscreenCanvasFrameReceiverImpl::SetBeginFrameSource( | |
| 63 cc::BeginFrameSource* begin_frame_source) {} | |
| 64 | |
| 65 } // namespace content | |
| OLD | NEW |