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