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