| 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" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // For display root surfaces, the surface is no longer going to be visible | 40 // For display root surfaces, the surface is no longer going to be visible |
| 41 // so make it unreachable from the top-level root. | 41 // so make it unreachable from the top-level root. |
| 42 if (surface_manager_->using_surface_references() && is_root_ && | 42 if (surface_manager_->using_surface_references() && is_root_ && |
| 43 reference_tracker_.current_surface_id().is_valid()) | 43 reference_tracker_.current_surface_id().is_valid()) |
| 44 RemoveTopLevelRootReference(reference_tracker_.current_surface_id()); | 44 RemoveTopLevelRootReference(reference_tracker_.current_surface_id()); |
| 45 | 45 |
| 46 // SurfaceFactory's destructor will attempt to return resources which will | 46 // SurfaceFactory's destructor will attempt to return resources which will |
| 47 // call back into here and access |client_| so we should destroy | 47 // call back into here and access |client_| so we should destroy |
| 48 // |surface_factory_|'s resources early on. | 48 // |surface_factory_|'s resources early on. |
| 49 surface_factory_->EvictSurface(); | 49 surface_factory_->EvictSurface(); |
| 50 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); | 50 surface_manager_->UnregisterFrameSinkManagerClient(frame_sink_id_); |
| 51 if (handles_frame_sink_id_invalidation_) | 51 if (handles_frame_sink_id_invalidation_) |
| 52 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); | 52 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void CompositorFrameSinkSupport::ReferencedSurfacesChanged( | 55 void CompositorFrameSinkSupport::ReferencedSurfacesChanged( |
| 56 const LocalSurfaceId& local_surface_id, | 56 const LocalSurfaceId& local_surface_id, |
| 57 const std::vector<SurfaceId>* active_referenced_surfaces) { | 57 const std::vector<SurfaceId>* active_referenced_surfaces) { |
| 58 if (!surface_manager_->using_surface_references()) | 58 if (!surface_manager_->using_surface_references()) |
| 59 return; | 59 return; |
| 60 | 60 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 86 void CompositorFrameSinkSupport::SetBeginFrameSource( | 86 void CompositorFrameSinkSupport::SetBeginFrameSource( |
| 87 BeginFrameSource* begin_frame_source) { | 87 BeginFrameSource* begin_frame_source) { |
| 88 if (begin_frame_source_ && added_frame_observer_) { | 88 if (begin_frame_source_ && added_frame_observer_) { |
| 89 begin_frame_source_->RemoveObserver(this); | 89 begin_frame_source_->RemoveObserver(this); |
| 90 added_frame_observer_ = false; | 90 added_frame_observer_ = false; |
| 91 } | 91 } |
| 92 begin_frame_source_ = begin_frame_source; | 92 begin_frame_source_ = begin_frame_source; |
| 93 UpdateNeedsBeginFramesInternal(); | 93 UpdateNeedsBeginFramesInternal(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void CompositorFrameSinkSupport::WillDrawSurface( | |
| 97 const LocalSurfaceId& local_surface_id, | |
| 98 const gfx::Rect& damage_rect) { | |
| 99 if (client_) | |
| 100 client_->WillDrawSurface(local_surface_id, damage_rect); | |
| 101 } | |
| 102 | |
| 103 void CompositorFrameSinkSupport::EvictFrame() { | 96 void CompositorFrameSinkSupport::EvictFrame() { |
| 104 DCHECK(surface_factory_); | 97 DCHECK(surface_factory_); |
| 105 surface_factory_->EvictSurface(); | 98 surface_factory_->EvictSurface(); |
| 106 } | 99 } |
| 107 | 100 |
| 108 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { | 101 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { |
| 109 needs_begin_frame_ = needs_begin_frame; | 102 needs_begin_frame_ = needs_begin_frame; |
| 110 UpdateNeedsBeginFramesInternal(); | 103 UpdateNeedsBeginFramesInternal(); |
| 111 } | 104 } |
| 112 | 105 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 199 |
| 207 void CompositorFrameSinkSupport::DidReceiveCompositorFrameAck() { | 200 void CompositorFrameSinkSupport::DidReceiveCompositorFrameAck() { |
| 208 DCHECK_GT(ack_pending_count_, 0); | 201 DCHECK_GT(ack_pending_count_, 0); |
| 209 ack_pending_count_--; | 202 ack_pending_count_--; |
| 210 if (!client_) | 203 if (!client_) |
| 211 return; | 204 return; |
| 212 client_->DidReceiveCompositorFrameAck(surface_returned_resources_); | 205 client_->DidReceiveCompositorFrameAck(surface_returned_resources_); |
| 213 surface_returned_resources_.clear(); | 206 surface_returned_resources_.clear(); |
| 214 } | 207 } |
| 215 | 208 |
| 209 void CompositorFrameSinkSupport::WillDrawSurface( |
| 210 const LocalSurfaceId& local_surface_id, |
| 211 const gfx::Rect& damage_rect) { |
| 212 if (client_) |
| 213 client_->WillDrawSurface(local_surface_id, damage_rect); |
| 214 } |
| 215 |
| 216 void CompositorFrameSinkSupport::ForceReclaimResources() { | 216 void CompositorFrameSinkSupport::ForceReclaimResources() { |
| 217 DCHECK(surface_factory_); | 217 DCHECK(surface_factory_); |
| 218 surface_factory_->ClearSurface(); | 218 surface_factory_->ClearSurface(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void CompositorFrameSinkSupport::ClaimTemporaryReference( | 221 void CompositorFrameSinkSupport::ClaimTemporaryReference( |
| 222 const SurfaceId& surface_id) { | 222 const SurfaceId& surface_id) { |
| 223 surface_manager_->AssignTemporaryReference(surface_id, frame_sink_id_); | 223 surface_manager_->AssignTemporaryReference(surface_id, frame_sink_id_); |
| 224 } | 224 } |
| 225 | 225 |
| 226 CompositorFrameSinkSupport::CompositorFrameSinkSupport( | 226 CompositorFrameSinkSupport::CompositorFrameSinkSupport( |
| 227 CompositorFrameSinkSupportClient* client, | 227 CompositorFrameSinkSupportClient* client, |
| 228 const FrameSinkId& frame_sink_id, | 228 const FrameSinkId& frame_sink_id, |
| 229 bool is_root, | 229 bool is_root, |
| 230 bool handles_frame_sink_id_invalidation) | 230 bool handles_frame_sink_id_invalidation) |
| 231 : client_(client), | 231 : client_(client), |
| 232 frame_sink_id_(frame_sink_id), | 232 frame_sink_id_(frame_sink_id), |
| 233 reference_tracker_(frame_sink_id), | 233 reference_tracker_(frame_sink_id), |
| 234 is_root_(is_root), | 234 is_root_(is_root), |
| 235 handles_frame_sink_id_invalidation_(handles_frame_sink_id_invalidation), | 235 handles_frame_sink_id_invalidation_(handles_frame_sink_id_invalidation), |
| 236 weak_factory_(this) {} | 236 weak_factory_(this) {} |
| 237 | 237 |
| 238 void CompositorFrameSinkSupport::Init(SurfaceManager* surface_manager, | 238 void CompositorFrameSinkSupport::Init(SurfaceManager* surface_manager, |
| 239 bool needs_sync_points) { | 239 bool needs_sync_points) { |
| 240 surface_manager_ = surface_manager; | 240 surface_manager_ = surface_manager; |
| 241 surface_factory_ = | 241 surface_factory_ = base::MakeUnique<SurfaceFactory>( |
| 242 base::MakeUnique<SurfaceFactory>(frame_sink_id_, surface_manager_, this); | 242 frame_sink_id_, surface_manager_, this, this); |
| 243 if (handles_frame_sink_id_invalidation_) | 243 if (handles_frame_sink_id_invalidation_) |
| 244 surface_manager_->RegisterFrameSinkId(frame_sink_id_); | 244 surface_manager_->RegisterFrameSinkId(frame_sink_id_); |
| 245 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); | 245 surface_manager_->RegisterFrameSinkManagerClient(frame_sink_id_, this); |
| 246 surface_factory_->set_needs_sync_points(needs_sync_points); | 246 surface_factory_->set_needs_sync_points(needs_sync_points); |
| 247 } | 247 } |
| 248 | 248 |
| 249 void CompositorFrameSinkSupport::OnBeginFrame(const BeginFrameArgs& args) { | 249 void CompositorFrameSinkSupport::OnBeginFrame(const BeginFrameArgs& args) { |
| 250 UpdateNeedsBeginFramesInternal(); | 250 UpdateNeedsBeginFramesInternal(); |
| 251 last_begin_frame_args_ = args; | 251 last_begin_frame_args_ = args; |
| 252 if (client_) | 252 if (client_) |
| 253 client_->OnBeginFrame(args); | 253 client_->OnBeginFrame(args); |
| 254 } | 254 } |
| 255 | 255 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 274 begin_frame_source_->RemoveObserver(this); | 274 begin_frame_source_->RemoveObserver(this); |
| 275 } | 275 } |
| 276 | 276 |
| 277 void CompositorFrameSinkSupport::RequestCopyOfSurface( | 277 void CompositorFrameSinkSupport::RequestCopyOfSurface( |
| 278 std::unique_ptr<CopyOutputRequest> request) { | 278 std::unique_ptr<CopyOutputRequest> request) { |
| 279 DCHECK(surface_factory_); | 279 DCHECK(surface_factory_); |
| 280 surface_factory_->RequestCopyOfSurface(std::move(request)); | 280 surface_factory_->RequestCopyOfSurface(std::move(request)); |
| 281 } | 281 } |
| 282 | 282 |
| 283 } // namespace cc | 283 } // namespace cc |
| OLD | NEW |