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 "cc/surfaces/compositor_frame_sink_support.h" | 5 #include "cc/surfaces/compositor_frame_sink_support.h" |
6 | 6 |
7 #include "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
8 #include "cc/scheduler/begin_frame_source.h" | 8 #include "cc/scheduler/begin_frame_source.h" |
9 #include "cc/surfaces/compositor_frame_sink_support_client.h" | 9 #include "cc/surfaces/compositor_frame_sink_support_client.h" |
10 #include "cc/surfaces/display.h" | 10 #include "cc/surfaces/display.h" |
11 #include "cc/surfaces/surface.h" | 11 #include "cc/surfaces/framesink_manager.h" |
12 #include "cc/surfaces/surface_manager.h" | 12 #include "cc/surfaces/surface_manager.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 | 15 |
16 CompositorFrameSinkSupport::CompositorFrameSinkSupport( | 16 CompositorFrameSinkSupport::CompositorFrameSinkSupport( |
17 CompositorFrameSinkSupportClient* client, | 17 CompositorFrameSinkSupportClient* client, |
18 SurfaceManager* surface_manager, | 18 SurfaceManager* surface_manager, |
| 19 FrameSinkManager* framesink_manager, |
19 const FrameSinkId& frame_sink_id, | 20 const FrameSinkId& frame_sink_id, |
20 std::unique_ptr<Display> display, | 21 std::unique_ptr<Display> display, |
21 std::unique_ptr<BeginFrameSource> display_begin_frame_source) | 22 std::unique_ptr<BeginFrameSource> display_begin_frame_source) |
22 : client_(client), | 23 : client_(client), |
23 surface_manager_(surface_manager), | 24 surface_manager_(surface_manager), |
| 25 framesink_manager_(framesink_manager), |
24 frame_sink_id_(frame_sink_id), | 26 frame_sink_id_(frame_sink_id), |
25 display_begin_frame_source_(std::move(display_begin_frame_source)), | 27 display_begin_frame_source_(std::move(display_begin_frame_source)), |
26 display_(std::move(display)), | 28 display_(std::move(display)), |
27 surface_factory_(frame_sink_id_, surface_manager_, this), | 29 surface_factory_(frame_sink_id_, surface_manager_, this), |
28 weak_factory_(this) { | 30 weak_factory_(this) { |
29 surface_manager_->RegisterFrameSinkId(frame_sink_id_); | 31 framesink_manager_->RegisterFrameSinkId(frame_sink_id_); |
30 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); | 32 framesink_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); |
31 | 33 |
32 if (display_) { | 34 if (display_) { |
33 display_->Initialize(this, surface_manager_); | 35 display_->Initialize(this, surface_manager_, framesink_manager_); |
34 display_->SetVisible(true); | 36 display_->SetVisible(true); |
35 } | 37 } |
36 } | 38 } |
37 | 39 |
38 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() { | 40 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() { |
39 for (auto& child_frame_sink_id : child_frame_sinks_) { | 41 for (auto& child_frame_sink_id : child_frame_sinks_) { |
40 DCHECK(child_frame_sink_id.is_valid()); | 42 DCHECK(child_frame_sink_id.is_valid()); |
41 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, | 43 framesink_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, |
42 child_frame_sink_id); | 44 child_frame_sink_id); |
43 } | 45 } |
44 // SurfaceFactory's destructor will attempt to return resources which will | 46 // SurfaceFactory's destructor will attempt to return resources which will |
45 // call back into here and access |client_| so we should destroy | 47 // call back into here and access |client_| so we should destroy |
46 // |surface_factory_|'s resources early on. | 48 // |surface_factory_|'s resources early on. |
47 surface_factory_.EvictSurface(); | 49 surface_factory_.EvictSurface(); |
48 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); | 50 framesink_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); |
49 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); | 51 framesink_manager_->InvalidateFrameSinkId(frame_sink_id_); |
50 } | 52 } |
51 | 53 |
52 void CompositorFrameSinkSupport::EvictFrame() { | 54 void CompositorFrameSinkSupport::EvictFrame() { |
53 surface_factory_.EvictSurface(); | 55 surface_factory_.EvictSurface(); |
54 } | 56 } |
55 | 57 |
56 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { | 58 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { |
57 needs_begin_frame_ = needs_begin_frame; | 59 needs_begin_frame_ = needs_begin_frame; |
58 UpdateNeedsBeginFramesInternal(); | 60 UpdateNeedsBeginFramesInternal(); |
59 } | 61 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 client_->DidReceiveCompositorFrameAck(); | 93 client_->DidReceiveCompositorFrameAck(); |
92 if (!surface_returned_resources_.empty()) { | 94 if (!surface_returned_resources_.empty()) { |
93 client_->ReclaimResources(surface_returned_resources_); | 95 client_->ReclaimResources(surface_returned_resources_); |
94 surface_returned_resources_.clear(); | 96 surface_returned_resources_.clear(); |
95 } | 97 } |
96 } | 98 } |
97 | 99 |
98 void CompositorFrameSinkSupport::AddChildFrameSink( | 100 void CompositorFrameSinkSupport::AddChildFrameSink( |
99 const FrameSinkId& child_frame_sink_id) { | 101 const FrameSinkId& child_frame_sink_id) { |
100 child_frame_sinks_.insert(child_frame_sink_id); | 102 child_frame_sinks_.insert(child_frame_sink_id); |
101 surface_manager_->RegisterFrameSinkHierarchy(frame_sink_id_, | 103 framesink_manager_->RegisterFrameSinkHierarchy(frame_sink_id_, |
102 child_frame_sink_id); | 104 child_frame_sink_id); |
103 } | 105 } |
104 | 106 |
105 void CompositorFrameSinkSupport::RemoveChildFrameSink( | 107 void CompositorFrameSinkSupport::RemoveChildFrameSink( |
106 const FrameSinkId& child_frame_sink_id) { | 108 const FrameSinkId& child_frame_sink_id) { |
107 auto it = child_frame_sinks_.find(child_frame_sink_id); | 109 auto it = child_frame_sinks_.find(child_frame_sink_id); |
108 DCHECK(it != child_frame_sinks_.end()); | 110 DCHECK(it != child_frame_sinks_.end()); |
109 DCHECK(it->is_valid()); | 111 DCHECK(it->is_valid()); |
110 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, | 112 framesink_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, |
111 child_frame_sink_id); | 113 child_frame_sink_id); |
112 child_frame_sinks_.erase(it); | 114 child_frame_sinks_.erase(it); |
113 } | 115 } |
114 | 116 |
115 void CompositorFrameSinkSupport::DisplayOutputSurfaceLost() {} | 117 void CompositorFrameSinkSupport::DisplayOutputSurfaceLost() {} |
116 | 118 |
117 void CompositorFrameSinkSupport::DisplayWillDrawAndSwap( | 119 void CompositorFrameSinkSupport::DisplayWillDrawAndSwap( |
118 bool will_draw_and_swap, | 120 bool will_draw_and_swap, |
119 const RenderPassList& render_passes) {} | 121 const RenderPassList& render_passes) {} |
120 | 122 |
121 void CompositorFrameSinkSupport::DisplayDidDrawAndSwap() {} | 123 void CompositorFrameSinkSupport::DisplayDidDrawAndSwap() {} |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 return; | 175 return; |
174 | 176 |
175 added_frame_observer_ = needs_begin_frame_; | 177 added_frame_observer_ = needs_begin_frame_; |
176 if (needs_begin_frame_) | 178 if (needs_begin_frame_) |
177 begin_frame_source_->AddObserver(this); | 179 begin_frame_source_->AddObserver(this); |
178 else | 180 else |
179 begin_frame_source_->RemoveObserver(this); | 181 begin_frame_source_->RemoveObserver(this); |
180 } | 182 } |
181 | 183 |
182 } // namespace cc | 184 } // namespace cc |
OLD | NEW |