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_compositor_frame_sink.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 OffscreenCanvasCompositorFrameSink::OffscreenCanvasCompositorFrameSink( |
| 15 const cc::SurfaceId& surface_id, |
| 16 cc::mojom::MojoCompositorFrameSinkClientPtr client) |
| 17 : surface_id_(surface_id), client_(std::move(client)) {} |
| 18 |
| 19 OffscreenCanvasCompositorFrameSink::~OffscreenCanvasCompositorFrameSink() { |
| 20 if (surface_factory_) { |
| 21 if (!GetSurfaceManager()) { |
| 22 // Inform SurfaceFactory that SurfaceManager's no longer alive to |
| 23 // avoid its destruction error. |
| 24 surface_factory_->DidDestroySurfaceManager(); |
| 25 } else { |
| 26 GetSurfaceManager()->InvalidateSurfaceClientId(surface_id_.client_id()); |
| 27 } |
| 28 surface_factory_->Destroy(surface_id_); |
| 29 } |
| 30 } |
| 31 |
| 32 // static |
| 33 void OffscreenCanvasCompositorFrameSink::Create( |
| 34 const cc::SurfaceId& surface_id, |
| 35 cc::mojom::MojoCompositorFrameSinkClientPtr client, |
| 36 cc::mojom::MojoCompositorFrameSinkRequest request) { |
| 37 mojo::MakeStrongBinding(base::MakeUnique<OffscreenCanvasCompositorFrameSink>( |
| 38 surface_id, std::move(client)), |
| 39 std::move(request)); |
| 40 } |
| 41 |
| 42 void OffscreenCanvasCompositorFrameSink::SubmitCompositorFrame( |
| 43 cc::CompositorFrame frame, |
| 44 const SubmitCompositorFrameCallback& callback) { |
| 45 if (!surface_factory_) { |
| 46 cc::SurfaceManager* manager = GetSurfaceManager(); |
| 47 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(manager, this); |
| 48 surface_factory_->Create(surface_id_); |
| 49 |
| 50 GetSurfaceManager()->RegisterSurfaceClientId(surface_id_.client_id()); |
| 51 } |
| 52 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), |
| 53 callback); |
| 54 } |
| 55 |
| 56 void OffscreenCanvasCompositorFrameSink::SetNeedsBeginFrame( |
| 57 bool needs_begin_frame) { |
| 58 NOTIMPLEMENTED(); |
| 59 } |
| 60 |
| 61 void OffscreenCanvasCompositorFrameSink::ReturnResources( |
| 62 const cc::ReturnedResourceArray& resources) { |
| 63 client_->ReturnResources(resources); |
| 64 } |
| 65 |
| 66 void OffscreenCanvasCompositorFrameSink::WillDrawSurface( |
| 67 const cc::SurfaceId& id, |
| 68 const gfx::Rect& damage_rect) {} |
| 69 |
| 70 void OffscreenCanvasCompositorFrameSink::SetBeginFrameSource( |
| 71 cc::BeginFrameSource* begin_frame_source) {} |
| 72 |
| 73 } // namespace content |
OLD | NEW |