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 <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
11 #include "cc/scheduler/begin_frame_source.h" | 11 #include "cc/scheduler/begin_frame_source.h" |
12 #include "cc/surfaces/compositor_frame_sink_support_client.h" | 12 #include "cc/surfaces/compositor_frame_sink_support_client.h" |
13 #include "cc/surfaces/display.h" | 13 #include "cc/surfaces/display.h" |
14 #include "cc/surfaces/surface.h" | 14 #include "cc/surfaces/surface.h" |
| 15 #include "cc/surfaces/surface_info.h" |
15 #include "cc/surfaces/surface_manager.h" | 16 #include "cc/surfaces/surface_manager.h" |
16 #include "cc/surfaces/surface_reference.h" | 17 #include "cc/surfaces/surface_reference.h" |
17 | 18 |
18 namespace cc { | 19 namespace cc { |
19 | 20 |
20 // static | 21 // static |
21 std::unique_ptr<CompositorFrameSinkSupport> CompositorFrameSinkSupport::Create( | 22 std::unique_ptr<CompositorFrameSinkSupport> CompositorFrameSinkSupport::Create( |
22 CompositorFrameSinkSupportClient* client, | 23 CompositorFrameSinkSupportClient* client, |
23 SurfaceManager* surface_manager, | 24 SurfaceManager* surface_manager, |
24 const FrameSinkId& frame_sink_id, | 25 const FrameSinkId& frame_sink_id, |
25 bool is_root, | 26 bool is_root, |
26 bool handles_frame_sink_id_invalidation, | 27 bool handles_frame_sink_id_invalidation, |
27 bool needs_sync_points) { | 28 bool needs_sync_points) { |
28 std::unique_ptr<CompositorFrameSinkSupport> support = | 29 std::unique_ptr<CompositorFrameSinkSupport> support = |
29 base::WrapUnique(new CompositorFrameSinkSupport( | 30 base::WrapUnique(new CompositorFrameSinkSupport( |
30 client, frame_sink_id, is_root, handles_frame_sink_id_invalidation)); | 31 client, frame_sink_id, is_root, handles_frame_sink_id_invalidation, |
31 support->Init(surface_manager, needs_sync_points); | 32 needs_sync_points)); |
| 33 support->Init(surface_manager); |
32 return support; | 34 return support; |
33 } | 35 } |
34 | 36 |
35 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() { | 37 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() { |
36 // Unregister |this| as a BeginFrameObserver so that the BeginFrameSource does | 38 // Unregister |this| as a BeginFrameObserver so that the BeginFrameSource does |
37 // not call into |this| after it's deleted. | 39 // not call into |this| after it's deleted. |
38 SetNeedsBeginFrame(false); | 40 SetNeedsBeginFrame(false); |
39 | 41 |
40 // For display root surfaces, the surface is no longer going to be visible | 42 // For display root surfaces, the surface is no longer going to be visible |
41 // so make it unreachable from the top-level root. | 43 // so make it unreachable from the top-level root. |
42 if (surface_manager_->using_surface_references() && is_root_ && | 44 if (surface_manager_->using_surface_references() && is_root_ && |
43 reference_tracker_.current_surface_id().is_valid()) | 45 reference_tracker_.current_surface_id().is_valid()) |
44 RemoveTopLevelRootReference(reference_tracker_.current_surface_id()); | 46 RemoveTopLevelRootReference(reference_tracker_.current_surface_id()); |
45 | 47 |
46 // SurfaceFactory's destructor will attempt to return resources which will | 48 EvictFrame(); |
47 // call back into here and access |client_| so we should destroy | |
48 // |surface_factory_|'s resources early on. | |
49 surface_factory_->EvictSurface(); | |
50 surface_manager_->UnregisterFrameSinkManagerClient(frame_sink_id_); | 49 surface_manager_->UnregisterFrameSinkManagerClient(frame_sink_id_); |
51 if (handles_frame_sink_id_invalidation_) | 50 if (handles_frame_sink_id_invalidation_) |
52 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); | 51 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); |
53 } | 52 } |
54 | 53 |
55 void CompositorFrameSinkSupport::ReferencedSurfacesChanged( | |
56 const LocalSurfaceId& local_surface_id, | |
57 const std::vector<SurfaceId>* active_referenced_surfaces) { | |
58 if (!surface_manager_->using_surface_references()) | |
59 return; | |
60 | |
61 SurfaceId last_surface_id = reference_tracker_.current_surface_id(); | |
62 | |
63 // Populate list of surface references to add and remove based on reference | |
64 // surfaces in current frame compared with the last frame. The list of | |
65 // surface references includes references from both the pending and active | |
66 // frame if any. | |
67 reference_tracker_.UpdateReferences(local_surface_id, | |
68 active_referenced_surfaces); | |
69 | |
70 UpdateSurfaceReferences(last_surface_id, local_surface_id); | |
71 } | |
72 | |
73 void CompositorFrameSinkSupport::ReturnResources( | 54 void CompositorFrameSinkSupport::ReturnResources( |
74 const ReturnedResourceArray& resources) { | 55 const ReturnedResourceArray& resources) { |
75 if (resources.empty()) | 56 if (resources.empty()) |
76 return; | 57 return; |
77 if (!ack_pending_count_ && client_) { | 58 if (!ack_pending_count_ && client_) { |
78 client_->ReclaimResources(resources); | 59 client_->ReclaimResources(resources); |
79 return; | 60 return; |
80 } | 61 } |
81 | 62 |
82 std::copy(resources.begin(), resources.end(), | 63 std::copy(resources.begin(), resources.end(), |
83 std::back_inserter(surface_returned_resources_)); | 64 std::back_inserter(surface_returned_resources_)); |
84 } | 65 } |
85 | 66 |
86 void CompositorFrameSinkSupport::SetBeginFrameSource( | 67 void CompositorFrameSinkSupport::SetBeginFrameSource( |
87 BeginFrameSource* begin_frame_source) { | 68 BeginFrameSource* begin_frame_source) { |
88 if (begin_frame_source_ && added_frame_observer_) { | 69 if (begin_frame_source_ && added_frame_observer_) { |
89 begin_frame_source_->RemoveObserver(this); | 70 begin_frame_source_->RemoveObserver(this); |
90 added_frame_observer_ = false; | 71 added_frame_observer_ = false; |
91 } | 72 } |
92 begin_frame_source_ = begin_frame_source; | 73 begin_frame_source_ = begin_frame_source; |
93 UpdateNeedsBeginFramesInternal(); | 74 UpdateNeedsBeginFramesInternal(); |
94 } | 75 } |
95 | 76 |
96 void CompositorFrameSinkSupport::EvictFrame() { | 77 void CompositorFrameSinkSupport::EvictFrame() { |
97 DCHECK(surface_factory_); | 78 if (!current_surface_) |
98 surface_factory_->EvictSurface(); | 79 return; |
| 80 DestroyCurrentSurface(); |
99 } | 81 } |
100 | 82 |
101 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { | 83 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { |
102 needs_begin_frame_ = needs_begin_frame; | 84 needs_begin_frame_ = needs_begin_frame; |
103 UpdateNeedsBeginFramesInternal(); | 85 UpdateNeedsBeginFramesInternal(); |
104 } | 86 } |
105 | 87 |
106 void CompositorFrameSinkSupport::BeginFrameDidNotSwap( | 88 void CompositorFrameSinkSupport::BeginFrameDidNotSwap( |
107 const BeginFrameAck& ack) { | 89 const BeginFrameAck& ack) { |
108 // TODO(eseckler): While a pending CompositorFrame exists (see TODO below), we | 90 // TODO(eseckler): While a pending CompositorFrame exists (see TODO below), we |
109 // should not acknowledge immediately. Instead, we should update the ack that | 91 // should not acknowledge immediately. Instead, we should update the ack that |
110 // will be sent to DisplayScheduler when the pending frame is activated. | 92 // will be sent to DisplayScheduler when the pending frame is activated. |
111 DCHECK_GE(ack.sequence_number, BeginFrameArgs::kStartingFrameNumber); | 93 DCHECK_GE(ack.sequence_number, BeginFrameArgs::kStartingFrameNumber); |
112 | 94 |
113 // |has_damage| is not transmitted, but false by default. | 95 // |has_damage| is not transmitted, but false by default. |
114 DCHECK(!ack.has_damage); | 96 DCHECK(!ack.has_damage); |
115 if (begin_frame_source_) | 97 if (begin_frame_source_) |
116 begin_frame_source_->DidFinishFrame(this, ack); | 98 begin_frame_source_->DidFinishFrame(this, ack); |
117 } | 99 } |
118 | 100 |
119 void CompositorFrameSinkSupport::SubmitCompositorFrame( | 101 void CompositorFrameSinkSupport::SubmitCompositorFrame( |
120 const LocalSurfaceId& local_surface_id, | 102 const LocalSurfaceId& local_surface_id, |
121 CompositorFrame frame) { | 103 CompositorFrame frame) { |
122 DCHECK(surface_factory_); | 104 TRACE_EVENT0("cc", "CompositorFrameSinkSupport::SubmitCompositorFrame"); |
| 105 DCHECK(local_surface_id.is_valid()); |
123 DCHECK_GE(frame.metadata.begin_frame_ack.sequence_number, | 106 DCHECK_GE(frame.metadata.begin_frame_ack.sequence_number, |
124 BeginFrameArgs::kStartingFrameNumber); | 107 BeginFrameArgs::kStartingFrameNumber); |
125 DCHECK(!frame.render_pass_list.empty()); | 108 DCHECK(!frame.render_pass_list.empty()); |
126 | 109 |
127 ++ack_pending_count_; | 110 ++ack_pending_count_; |
128 | 111 |
129 // |has_damage| is not transmitted. | 112 // |has_damage| is not transmitted. |
130 frame.metadata.begin_frame_ack.has_damage = true; | 113 frame.metadata.begin_frame_ack.has_damage = true; |
131 | 114 |
132 BeginFrameAck ack = frame.metadata.begin_frame_ack; | 115 BeginFrameAck ack = frame.metadata.begin_frame_ack; |
133 surface_factory_->SubmitCompositorFrame( | 116 |
134 local_surface_id, std::move(frame), | 117 if (!ui::LatencyInfo::Verify(frame.metadata.latency_info, |
| 118 "RenderWidgetHostImpl::OnSwapCompositorFrame")) { |
| 119 std::vector<ui::LatencyInfo>().swap(frame.metadata.latency_info); |
| 120 } |
| 121 for (ui::LatencyInfo& latency : frame.metadata.latency_info) { |
| 122 if (latency.latency_components().size() > 0) { |
| 123 latency.AddLatencyNumber(ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, |
| 124 0, 0); |
| 125 } |
| 126 } |
| 127 |
| 128 std::unique_ptr<Surface> surface; |
| 129 bool create_new_surface = |
| 130 (!current_surface_ || |
| 131 local_surface_id != current_surface_->surface_id().local_surface_id()); |
| 132 if (!create_new_surface) { |
| 133 surface = std::move(current_surface_); |
| 134 } else { |
| 135 surface = CreateSurface(local_surface_id); |
| 136 } |
| 137 |
| 138 surface->QueueFrame( |
| 139 std::move(frame), |
135 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, | 140 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, |
136 weak_factory_.GetWeakPtr()), | 141 weak_factory_.GetWeakPtr()), |
137 base::BindRepeating(&CompositorFrameSinkSupport::WillDrawSurface, | 142 base::BindRepeating(&CompositorFrameSinkSupport::WillDrawSurface, |
138 weak_factory_.GetWeakPtr())); | 143 weak_factory_.GetWeakPtr())); |
139 | 144 |
| 145 if (current_surface_) { |
| 146 surface->SetPreviousFrameSurface(current_surface_.get()); |
| 147 DestroyCurrentSurface(); |
| 148 } |
| 149 current_surface_ = std::move(surface); |
| 150 |
140 // TODO(eseckler): The CompositorFrame submitted below might not be activated | 151 // TODO(eseckler): The CompositorFrame submitted below might not be activated |
141 // right away b/c of surface synchronization. We should only send the | 152 // right away b/c of surface synchronization. We should only send the |
142 // BeginFrameAck to DisplayScheduler when it is activated. This also means | 153 // BeginFrameAck to DisplayScheduler when it is activated. This also means |
143 // that we need to stay an active BFO while a CompositorFrame is pending. | 154 // that we need to stay an active BFO while a CompositorFrame is pending. |
144 // See https://crbug.com/703079. | 155 // See https://crbug.com/703079. |
145 if (begin_frame_source_) | 156 if (begin_frame_source_) |
146 begin_frame_source_->DidFinishFrame(this, ack); | 157 begin_frame_source_->DidFinishFrame(this, ack); |
147 } | 158 } |
148 | 159 |
149 void CompositorFrameSinkSupport::UpdateSurfaceReferences( | 160 void CompositorFrameSinkSupport::UpdateSurfaceReferences( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 SurfaceReference reference(surface_manager_->GetRootSurfaceId(), surface_id); | 195 SurfaceReference reference(surface_manager_->GetRootSurfaceId(), surface_id); |
185 surface_manager_->AddSurfaceReferences({reference}); | 196 surface_manager_->AddSurfaceReferences({reference}); |
186 } | 197 } |
187 | 198 |
188 void CompositorFrameSinkSupport::RemoveTopLevelRootReference( | 199 void CompositorFrameSinkSupport::RemoveTopLevelRootReference( |
189 const SurfaceId& surface_id) { | 200 const SurfaceId& surface_id) { |
190 SurfaceReference reference(surface_manager_->GetRootSurfaceId(), surface_id); | 201 SurfaceReference reference(surface_manager_->GetRootSurfaceId(), surface_id); |
191 surface_manager_->RemoveSurfaceReferences({reference}); | 202 surface_manager_->RemoveSurfaceReferences({reference}); |
192 } | 203 } |
193 | 204 |
| 205 void CompositorFrameSinkSupport::ReferencedSurfacesChanged( |
| 206 const LocalSurfaceId& local_surface_id, |
| 207 const std::vector<SurfaceId>* active_referenced_surfaces) { |
| 208 if (!surface_manager_->using_surface_references()) |
| 209 return; |
| 210 |
| 211 SurfaceId last_surface_id = reference_tracker_.current_surface_id(); |
| 212 |
| 213 // Populate list of surface references to add and remove based on reference |
| 214 // surfaces in current frame compared with the last frame. The list of |
| 215 // surface references includes references from both the pending and active |
| 216 // frame if any. |
| 217 reference_tracker_.UpdateReferences(local_surface_id, |
| 218 active_referenced_surfaces); |
| 219 |
| 220 UpdateSurfaceReferences(last_surface_id, local_surface_id); |
| 221 } |
| 222 |
194 void CompositorFrameSinkSupport::DidReceiveCompositorFrameAck() { | 223 void CompositorFrameSinkSupport::DidReceiveCompositorFrameAck() { |
195 DCHECK_GT(ack_pending_count_, 0); | 224 DCHECK_GT(ack_pending_count_, 0); |
196 ack_pending_count_--; | 225 ack_pending_count_--; |
197 if (!client_) | 226 if (!client_) |
198 return; | 227 return; |
| 228 |
199 client_->DidReceiveCompositorFrameAck(surface_returned_resources_); | 229 client_->DidReceiveCompositorFrameAck(surface_returned_resources_); |
200 surface_returned_resources_.clear(); | 230 surface_returned_resources_.clear(); |
201 } | 231 } |
202 | 232 |
203 void CompositorFrameSinkSupport::WillDrawSurface( | 233 void CompositorFrameSinkSupport::WillDrawSurface( |
204 const LocalSurfaceId& local_surface_id, | 234 const LocalSurfaceId& local_surface_id, |
205 const gfx::Rect& damage_rect) { | 235 const gfx::Rect& damage_rect) { |
206 if (client_) | 236 if (client_) |
207 client_->WillDrawSurface(local_surface_id, damage_rect); | 237 client_->WillDrawSurface(local_surface_id, damage_rect); |
208 } | 238 } |
209 | 239 |
210 void CompositorFrameSinkSupport::ClaimTemporaryReference( | 240 void CompositorFrameSinkSupport::ClaimTemporaryReference( |
211 const SurfaceId& surface_id) { | 241 const SurfaceId& surface_id) { |
212 surface_manager_->AssignTemporaryReference(surface_id, frame_sink_id_); | 242 surface_manager_->AssignTemporaryReference(surface_id, frame_sink_id_); |
213 } | 243 } |
214 | 244 |
| 245 void CompositorFrameSinkSupport::ReceiveFromChild( |
| 246 const TransferableResourceArray& resources) { |
| 247 surface_resource_holder_.ReceiveFromChild(resources); |
| 248 } |
| 249 |
| 250 void CompositorFrameSinkSupport::RefResources( |
| 251 const TransferableResourceArray& resources) { |
| 252 surface_resource_holder_.RefResources(resources); |
| 253 } |
| 254 |
| 255 void CompositorFrameSinkSupport::UnrefResources( |
| 256 const ReturnedResourceArray& resources) { |
| 257 surface_resource_holder_.UnrefResources(resources); |
| 258 } |
| 259 |
215 CompositorFrameSinkSupport::CompositorFrameSinkSupport( | 260 CompositorFrameSinkSupport::CompositorFrameSinkSupport( |
216 CompositorFrameSinkSupportClient* client, | 261 CompositorFrameSinkSupportClient* client, |
217 const FrameSinkId& frame_sink_id, | 262 const FrameSinkId& frame_sink_id, |
218 bool is_root, | 263 bool is_root, |
219 bool handles_frame_sink_id_invalidation) | 264 bool handles_frame_sink_id_invalidation, |
| 265 bool needs_sync_points) |
220 : client_(client), | 266 : client_(client), |
221 frame_sink_id_(frame_sink_id), | 267 frame_sink_id_(frame_sink_id), |
| 268 surface_resource_holder_(this), |
222 reference_tracker_(frame_sink_id), | 269 reference_tracker_(frame_sink_id), |
223 is_root_(is_root), | 270 is_root_(is_root), |
| 271 needs_sync_points_(needs_sync_points), |
224 handles_frame_sink_id_invalidation_(handles_frame_sink_id_invalidation), | 272 handles_frame_sink_id_invalidation_(handles_frame_sink_id_invalidation), |
225 weak_factory_(this) {} | 273 weak_factory_(this) {} |
226 | 274 |
227 void CompositorFrameSinkSupport::Init(SurfaceManager* surface_manager, | 275 void CompositorFrameSinkSupport::Init(SurfaceManager* surface_manager) { |
228 bool needs_sync_points) { | |
229 surface_manager_ = surface_manager; | 276 surface_manager_ = surface_manager; |
230 surface_factory_ = base::MakeUnique<SurfaceFactory>( | |
231 frame_sink_id_, surface_manager_, this, this); | |
232 if (handles_frame_sink_id_invalidation_) | 277 if (handles_frame_sink_id_invalidation_) |
233 surface_manager_->RegisterFrameSinkId(frame_sink_id_); | 278 surface_manager_->RegisterFrameSinkId(frame_sink_id_); |
234 surface_manager_->RegisterFrameSinkManagerClient(frame_sink_id_, this); | 279 surface_manager_->RegisterFrameSinkManagerClient(frame_sink_id_, this); |
235 surface_factory_->set_needs_sync_points(needs_sync_points); | |
236 } | 280 } |
237 | 281 |
238 void CompositorFrameSinkSupport::OnBeginFrame(const BeginFrameArgs& args) { | 282 void CompositorFrameSinkSupport::OnBeginFrame(const BeginFrameArgs& args) { |
239 UpdateNeedsBeginFramesInternal(); | 283 UpdateNeedsBeginFramesInternal(); |
240 last_begin_frame_args_ = args; | 284 last_begin_frame_args_ = args; |
241 if (client_) | 285 if (client_) |
242 client_->OnBeginFrame(args); | 286 client_->OnBeginFrame(args); |
243 } | 287 } |
244 | 288 |
245 const BeginFrameArgs& CompositorFrameSinkSupport::LastUsedBeginFrameArgs() | 289 const BeginFrameArgs& CompositorFrameSinkSupport::LastUsedBeginFrameArgs() |
246 const { | 290 const { |
247 return last_begin_frame_args_; | 291 return last_begin_frame_args_; |
248 } | 292 } |
249 | 293 |
250 void CompositorFrameSinkSupport::OnBeginFrameSourcePausedChanged(bool paused) {} | 294 void CompositorFrameSinkSupport::OnBeginFrameSourcePausedChanged(bool paused) {} |
251 | 295 |
| 296 void CompositorFrameSinkSupport::OnSurfaceActivated(Surface* surface) { |
| 297 DCHECK(surface->HasActiveFrame()); |
| 298 // TODO(staraz): Notify BeginFrameSource about the last activated sequence |
| 299 // number. |
| 300 if (!seen_first_frame_activation_) { |
| 301 seen_first_frame_activation_ = true; |
| 302 |
| 303 const CompositorFrame& frame = surface->GetActiveFrame(); |
| 304 // CompositorFrames might not be populated with a RenderPass in unit tests. |
| 305 gfx::Size frame_size; |
| 306 if (!frame.render_pass_list.empty()) |
| 307 frame_size = frame.render_pass_list.back()->output_rect.size(); |
| 308 |
| 309 // SurfaceCreated only applies for the first Surface activation. Thus, |
| 310 // SurfaceFactory stops observing new activations after the first one. |
| 311 surface_manager_->SurfaceCreated(SurfaceInfo( |
| 312 surface->surface_id(), frame.metadata.device_scale_factor, frame_size)); |
| 313 } |
| 314 // Fire SurfaceCreated first so that a temporary reference is added before it |
| 315 // is potentially transformed into a real reference by the client. |
| 316 ReferencedSurfacesChanged(surface->surface_id().local_surface_id(), |
| 317 surface->active_referenced_surfaces()); |
| 318 if (!surface_manager_->SurfaceModified(surface->surface_id())) { |
| 319 TRACE_EVENT_INSTANT0("cc", "Damage not visible.", TRACE_EVENT_SCOPE_THREAD); |
| 320 surface->RunDrawCallback(); |
| 321 } |
| 322 } |
| 323 |
| 324 void CompositorFrameSinkSupport::OnSurfaceDependenciesChanged( |
| 325 Surface* surface, |
| 326 const base::flat_set<SurfaceId>& added_dependencies, |
| 327 const base::flat_set<SurfaceId>& removed_dependencies) {} |
| 328 |
| 329 void CompositorFrameSinkSupport::OnSurfaceDiscarded(Surface* surface) {} |
| 330 |
252 void CompositorFrameSinkSupport::UpdateNeedsBeginFramesInternal() { | 331 void CompositorFrameSinkSupport::UpdateNeedsBeginFramesInternal() { |
253 if (!begin_frame_source_) | 332 if (!begin_frame_source_) |
254 return; | 333 return; |
255 | 334 |
256 if (needs_begin_frame_ == added_frame_observer_) | 335 if (needs_begin_frame_ == added_frame_observer_) |
257 return; | 336 return; |
258 | 337 |
259 added_frame_observer_ = needs_begin_frame_; | 338 added_frame_observer_ = needs_begin_frame_; |
260 if (needs_begin_frame_) | 339 if (needs_begin_frame_) |
261 begin_frame_source_->AddObserver(this); | 340 begin_frame_source_->AddObserver(this); |
262 else | 341 else |
263 begin_frame_source_->RemoveObserver(this); | 342 begin_frame_source_->RemoveObserver(this); |
264 } | 343 } |
265 | 344 |
| 345 std::unique_ptr<Surface> CompositorFrameSinkSupport::CreateSurface( |
| 346 const LocalSurfaceId& local_surface_id) { |
| 347 seen_first_frame_activation_ = false; |
| 348 std::unique_ptr<Surface> surface = surface_manager_->CreateSurface( |
| 349 weak_factory_.GetWeakPtr(), local_surface_id); |
| 350 surface->AddObserver(this); |
| 351 return surface; |
| 352 } |
| 353 |
| 354 void CompositorFrameSinkSupport::DestroyCurrentSurface() { |
| 355 current_surface_->RemoveObserver(this); |
| 356 surface_manager_->DestroySurface(std::move(current_surface_)); |
| 357 } |
| 358 |
266 void CompositorFrameSinkSupport::RequestCopyOfSurface( | 359 void CompositorFrameSinkSupport::RequestCopyOfSurface( |
267 std::unique_ptr<CopyOutputRequest> request) { | 360 std::unique_ptr<CopyOutputRequest> copy_request) { |
268 DCHECK(surface_factory_); | 361 if (!current_surface_) |
269 surface_factory_->RequestCopyOfSurface(std::move(request)); | 362 return; |
| 363 |
| 364 DCHECK(current_surface_->compositor_frame_sink_support().get() == this); |
| 365 current_surface_->RequestCopyOfOutput(std::move(copy_request)); |
| 366 surface_manager_->SurfaceModified(current_surface_->surface_id()); |
270 } | 367 } |
271 | 368 |
272 } // namespace cc | 369 } // namespace cc |
OLD | NEW |