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 "content/browser/renderer_host/offscreen_canvas_surface_manager.h" | |
10 #include "mojo/public/cpp/bindings/strong_binding.h" | 11 #include "mojo/public/cpp/bindings/strong_binding.h" |
11 | 12 |
12 namespace content { | 13 namespace content { |
13 | 14 |
14 OffscreenCanvasCompositorFrameSink::OffscreenCanvasCompositorFrameSink( | 15 OffscreenCanvasCompositorFrameSink::OffscreenCanvasCompositorFrameSink( |
15 const cc::SurfaceId& surface_id, | 16 const cc::SurfaceId& surface_id, |
16 cc::mojom::MojoCompositorFrameSinkClientPtr client) | 17 cc::mojom::MojoCompositorFrameSinkClientPtr client) |
17 : surface_id_(surface_id), client_(std::move(client)) { | 18 : surface_id_(surface_id), client_(std::move(client)), weak_factory_(this) { |
Fady Samuel
2016/11/11 23:33:16
Don't store this SurfaceId maybe?
Store a const F
xlai (Olivia)
2016/11/14 15:13:19
I'm going to do it in the next CL. Because right n
| |
18 cc::SurfaceManager* manager = GetSurfaceManager(); | 19 cc::SurfaceManager* manager = GetSurfaceManager(); |
19 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>( | 20 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>( |
20 surface_id_.frame_sink_id(), manager, this); | 21 surface_id_.frame_sink_id(), manager, this); |
21 manager->RegisterFrameSinkId(surface_id_.frame_sink_id()); | 22 manager->RegisterFrameSinkId(surface_id_.frame_sink_id()); |
22 surface_factory_->Create(surface_id_.local_frame_id()); | 23 surface_factory_->Create(surface_id_.local_frame_id()); |
24 | |
25 OffscreenCanvasSurfaceManager::GetInstance() | |
26 ->RegisterCompositorFrameSinkInstance(surface_id_.frame_sink_id(), this); | |
23 } | 27 } |
24 | 28 |
25 OffscreenCanvasCompositorFrameSink::~OffscreenCanvasCompositorFrameSink() { | 29 OffscreenCanvasCompositorFrameSink::~OffscreenCanvasCompositorFrameSink() { |
26 cc::SurfaceManager* manager = GetSurfaceManager(); | 30 cc::SurfaceManager* manager = GetSurfaceManager(); |
27 if (!manager) { | 31 if (!manager) { |
28 // Inform SurfaceFactory that SurfaceManager's no longer alive to | 32 // Inform SurfaceFactory that SurfaceManager's no longer alive to |
29 // avoid its destruction error. | 33 // avoid its destruction error. |
30 surface_factory_->DidDestroySurfaceManager(); | 34 surface_factory_->DidDestroySurfaceManager(); |
31 } else { | 35 } else { |
32 manager->InvalidateFrameSinkId(surface_id_.frame_sink_id()); | 36 manager->InvalidateFrameSinkId(surface_id_.frame_sink_id()); |
33 } | 37 } |
34 surface_factory_->Destroy(surface_id_.local_frame_id()); | 38 surface_factory_->Destroy(surface_id_.local_frame_id()); |
39 | |
40 OffscreenCanvasSurfaceManager::GetInstance() | |
41 ->UnregisterCompositorFrameSinkInstance(surface_id_.frame_sink_id()); | |
35 } | 42 } |
36 | 43 |
37 // static | 44 // static |
38 void OffscreenCanvasCompositorFrameSink::Create( | 45 void OffscreenCanvasCompositorFrameSink::Create( |
39 const cc::SurfaceId& surface_id, | 46 const cc::SurfaceId& surface_id, |
40 cc::mojom::MojoCompositorFrameSinkClientPtr client, | 47 cc::mojom::MojoCompositorFrameSinkClientPtr client, |
41 cc::mojom::MojoCompositorFrameSinkRequest request) { | 48 cc::mojom::MojoCompositorFrameSinkRequest request) { |
42 mojo::MakeStrongBinding(base::MakeUnique<OffscreenCanvasCompositorFrameSink>( | 49 mojo::MakeStrongBinding(base::MakeUnique<OffscreenCanvasCompositorFrameSink>( |
43 surface_id, std::move(client)), | 50 surface_id, std::move(client)), |
44 std::move(request)); | 51 std::move(request)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 client_->DidReceiveCompositorFrameAck(); | 93 client_->DidReceiveCompositorFrameAck(); |
87 DCHECK_GT(ack_pending_count_, 0); | 94 DCHECK_GT(ack_pending_count_, 0); |
88 if (!surface_returned_resources_.empty()) { | 95 if (!surface_returned_resources_.empty()) { |
89 client_->ReclaimResources(surface_returned_resources_); | 96 client_->ReclaimResources(surface_returned_resources_); |
90 surface_returned_resources_.clear(); | 97 surface_returned_resources_.clear(); |
91 } | 98 } |
92 ack_pending_count_--; | 99 ack_pending_count_--; |
93 } | 100 } |
94 | 101 |
95 } // namespace content | 102 } // namespace content |
OLD | NEW |