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/surface.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 const FrameSinkId& frame_sink_id, | 19 const FrameSinkId& frame_sink_id, |
20 std::unique_ptr<Display> display, | 20 Display* display, |
21 std::unique_ptr<BeginFrameSource> display_begin_frame_source) | 21 std::unique_ptr<BeginFrameSource> display_begin_frame_source) |
22 : client_(client), | 22 : client_(client), |
23 surface_manager_(surface_manager), | 23 surface_manager_(surface_manager), |
24 frame_sink_id_(frame_sink_id), | 24 frame_sink_id_(frame_sink_id), |
25 display_begin_frame_source_(std::move(display_begin_frame_source)), | 25 display_begin_frame_source_(std::move(display_begin_frame_source)), |
26 display_(std::move(display)), | 26 display_(std::move(display)), |
27 surface_factory_(frame_sink_id_, surface_manager_, this), | 27 surface_factory_(frame_sink_id_, surface_manager_, this), |
28 weak_factory_(this) { | 28 weak_factory_(this) { |
29 surface_manager_->RegisterFrameSinkId(frame_sink_id_); | |
30 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); | 29 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); |
31 | 30 |
32 if (display_) { | 31 if (display_) |
33 display_->Initialize(this, surface_manager_); | 32 display_->Initialize(this, surface_manager_); |
34 display_->SetVisible(true); | |
35 } | |
36 } | 33 } |
37 | 34 |
38 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() { | 35 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() { |
39 for (auto& child_frame_sink_id : child_frame_sinks_) { | 36 for (auto& child_frame_sink_id : child_frame_sinks_) { |
40 DCHECK(child_frame_sink_id.is_valid()); | 37 DCHECK(child_frame_sink_id.is_valid()); |
41 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, | 38 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, |
42 child_frame_sink_id); | 39 child_frame_sink_id); |
43 } | 40 } |
44 // SurfaceFactory's destructor will attempt to return resources which will | 41 // Unregister the SurfaceFactoryClient here instead of the dtor so that only |
45 // call back into here and access |client_| so we should destroy | 42 // one client is alive for this namespace at any given time. |
46 // |surface_factory_|'s resources early on. | 43 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); |
47 surface_factory_.EvictSurface(); | 44 surface_factory_.EvictSurface(); |
48 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); | |
49 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); | |
Fady Samuel
2017/01/04 21:47:40
Why was this deleted? Please restore this code?
Alex Z.
2017/01/05 00:30:13
Done.
| |
50 } | 45 } |
51 | 46 |
52 void CompositorFrameSinkSupport::EvictFrame() { | 47 void CompositorFrameSinkSupport::EvictFrame() { |
53 surface_factory_.EvictSurface(); | 48 surface_factory_.EvictSurface(); |
54 } | 49 } |
55 | 50 |
56 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { | 51 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { |
57 needs_begin_frame_ = needs_begin_frame; | 52 needs_begin_frame_ = needs_begin_frame; |
58 UpdateNeedsBeginFramesInternal(); | 53 UpdateNeedsBeginFramesInternal(); |
59 } | 54 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 void CompositorFrameSinkSupport::RemoveChildFrameSink( | 120 void CompositorFrameSinkSupport::RemoveChildFrameSink( |
126 const FrameSinkId& child_frame_sink_id) { | 121 const FrameSinkId& child_frame_sink_id) { |
127 auto it = child_frame_sinks_.find(child_frame_sink_id); | 122 auto it = child_frame_sinks_.find(child_frame_sink_id); |
128 DCHECK(it != child_frame_sinks_.end()); | 123 DCHECK(it != child_frame_sinks_.end()); |
129 DCHECK(it->is_valid()); | 124 DCHECK(it->is_valid()); |
130 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, | 125 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, |
131 child_frame_sink_id); | 126 child_frame_sink_id); |
132 child_frame_sinks_.erase(it); | 127 child_frame_sinks_.erase(it); |
133 } | 128 } |
134 | 129 |
130 void CompositorFrameSinkSupport::SetNeedsSyncPoints(bool needs_sync_points) { | |
131 surface_factory_.set_needs_sync_points(needs_sync_points); | |
132 } | |
133 | |
134 void CompositorFrameSinkSupport::ForceReclaimResources() { | |
135 if (local_frame_id_.is_valid()) | |
136 surface_factory_.ClearSurface(); | |
137 } | |
138 | |
139 void CompositorFrameSinkSupport::RegisterFrameSinkId() { | |
Fady Samuel
2017/01/04 21:47:40
Delete this?
Alex Z.
2017/01/05 00:30:13
Done.
| |
140 surface_manager_->RegisterFrameSinkId(frame_sink_id_); | |
141 } | |
142 | |
143 void CompositorFrameSinkSupport::InvalidateFrameSinkId() { | |
Fady Samuel
2017/01/04 21:47:40
Delete this?
Alex Z.
2017/01/05 00:30:13
Done.
| |
144 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); | |
145 } | |
146 | |
135 void CompositorFrameSinkSupport::DisplayOutputSurfaceLost() {} | 147 void CompositorFrameSinkSupport::DisplayOutputSurfaceLost() {} |
136 | 148 |
137 void CompositorFrameSinkSupport::DisplayWillDrawAndSwap( | 149 void CompositorFrameSinkSupport::DisplayWillDrawAndSwap( |
138 bool will_draw_and_swap, | 150 bool will_draw_and_swap, |
139 const RenderPassList& render_passes) {} | 151 const RenderPassList& render_passes) {} |
140 | 152 |
141 void CompositorFrameSinkSupport::DisplayDidDrawAndSwap() {} | 153 void CompositorFrameSinkSupport::DisplayDidDrawAndSwap() {} |
142 | 154 |
143 void CompositorFrameSinkSupport::ReturnResources( | 155 void CompositorFrameSinkSupport::ReturnResources( |
144 const ReturnedResourceArray& resources) { | 156 const ReturnedResourceArray& resources) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 return; | 205 return; |
194 | 206 |
195 added_frame_observer_ = needs_begin_frame_; | 207 added_frame_observer_ = needs_begin_frame_; |
196 if (needs_begin_frame_) | 208 if (needs_begin_frame_) |
197 begin_frame_source_->AddObserver(this); | 209 begin_frame_source_->AddObserver(this); |
198 else | 210 else |
199 begin_frame_source_->RemoveObserver(this); | 211 begin_frame_source_->RemoveObserver(this); |
200 } | 212 } |
201 | 213 |
202 } // namespace cc | 214 } // namespace cc |
OLD | NEW |