| 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 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "cc/output/compositor_frame.h" | 11 #include "cc/output/compositor_frame.h" |
| 12 #include "cc/scheduler/begin_frame_source.h" | 12 #include "cc/scheduler/begin_frame_source.h" |
| 13 #include "cc/surfaces/compositor_frame_sink_support_client.h" | 13 #include "cc/surfaces/compositor_frame_sink_support_client.h" |
| 14 #include "cc/surfaces/display.h" | 14 #include "cc/surfaces/display.h" |
| 15 #include "cc/surfaces/surface.h" | 15 #include "cc/surfaces/surface.h" |
| 16 #include "cc/surfaces/surface_manager.h" | 16 #include "cc/surfaces/surface_manager.h" |
| 17 #include "cc/surfaces/surface_reference.h" | 17 #include "cc/surfaces/surface_reference.h" |
| 18 | 18 |
| 19 namespace cc { | 19 namespace cc { |
| 20 | 20 |
| 21 CompositorFrameSinkSupport::CompositorFrameSinkSupport( | 21 CompositorFrameSinkSupport::CompositorFrameSinkSupport( |
| 22 CompositorFrameSinkSupportClient* client, | 22 CompositorFrameSinkSupportClient* client, |
| 23 SurfaceManager* surface_manager, | 23 SurfaceManager* surface_manager, |
| 24 const FrameSinkId& frame_sink_id, | 24 const FrameSinkId& frame_sink_id, |
| 25 bool submits_to_display_compositor) | 25 bool submits_to_display_compositor, |
| 26 bool handles_frame_sink_id_invalidation, |
| 27 bool needs_sync_points) |
| 26 : client_(client), | 28 : client_(client), |
| 27 surface_manager_(surface_manager), | 29 surface_manager_(surface_manager), |
| 28 frame_sink_id_(frame_sink_id), | 30 frame_sink_id_(frame_sink_id), |
| 29 surface_factory_(frame_sink_id_, surface_manager_, this), | 31 surface_factory_(frame_sink_id_, surface_manager_, this), |
| 30 reference_tracker_(frame_sink_id), | 32 reference_tracker_(frame_sink_id), |
| 31 submits_to_display_compositor_(submits_to_display_compositor), | 33 submits_to_display_compositor_(submits_to_display_compositor), |
| 34 handles_frame_sink_id_invalidation_(handles_frame_sink_id_invalidation), |
| 32 weak_factory_(this) { | 35 weak_factory_(this) { |
| 33 surface_manager_->RegisterFrameSinkId(frame_sink_id_); | 36 surface_factory_.set_needs_sync_points(needs_sync_points); |
| 37 if (handles_frame_sink_id_invalidation_) |
| 38 surface_manager_->RegisterFrameSinkId(frame_sink_id_); |
| 34 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); | 39 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); |
| 35 } | 40 } |
| 36 | 41 |
| 37 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() { | 42 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() { |
| 43 // Unregister |this| as a BeginFrameObserver so that the BeginFrameSource does |
| 44 // not call into |this| after it's deleted. |
| 45 SetNeedsBeginFrame(false); |
| 46 |
| 38 // For display root surfaces, the surface is no longer going to be visible | 47 // For display root surfaces, the surface is no longer going to be visible |
| 39 // so make it unreachable from the top-level root. | 48 // so make it unreachable from the top-level root. |
| 40 if (surface_manager_->using_surface_references() && | 49 if (surface_manager_->using_surface_references() && |
| 41 submits_to_display_compositor_ && | 50 submits_to_display_compositor_ && |
| 42 reference_tracker_.current_surface_id().is_valid()) | 51 reference_tracker_.current_surface_id().is_valid()) |
| 43 RemoveTopLevelRootReference(reference_tracker_.current_surface_id()); | 52 RemoveTopLevelRootReference(reference_tracker_.current_surface_id()); |
| 44 | 53 |
| 45 for (auto& child_frame_sink_id : child_frame_sinks_) { | 54 for (auto& child_frame_sink_id : child_frame_sinks_) { |
| 46 DCHECK(child_frame_sink_id.is_valid()); | 55 DCHECK(child_frame_sink_id.is_valid()); |
| 47 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, | 56 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, |
| 48 child_frame_sink_id); | 57 child_frame_sink_id); |
| 49 } | 58 } |
| 50 // SurfaceFactory's destructor will attempt to return resources which will | 59 // SurfaceFactory's destructor will attempt to return resources which will |
| 51 // call back into here and access |client_| so we should destroy | 60 // call back into here and access |client_| so we should destroy |
| 52 // |surface_factory_|'s resources early on. | 61 // |surface_factory_|'s resources early on. |
| 53 surface_factory_.EvictSurface(); | 62 surface_factory_.EvictSurface(); |
| 54 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); | 63 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); |
| 55 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); | 64 if (handles_frame_sink_id_invalidation_) |
| 65 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); |
| 56 } | 66 } |
| 57 | 67 |
| 58 void CompositorFrameSinkSupport::EvictFrame() { | 68 void CompositorFrameSinkSupport::EvictFrame() { |
| 59 surface_factory_.EvictSurface(); | 69 surface_factory_.EvictSurface(); |
| 60 } | 70 } |
| 61 | 71 |
| 62 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { | 72 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { |
| 63 needs_begin_frame_ = needs_begin_frame; | 73 needs_begin_frame_ = needs_begin_frame; |
| 64 UpdateNeedsBeginFramesInternal(); | 74 UpdateNeedsBeginFramesInternal(); |
| 65 } | 75 } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 return; | 241 return; |
| 232 | 242 |
| 233 added_frame_observer_ = needs_begin_frame_; | 243 added_frame_observer_ = needs_begin_frame_; |
| 234 if (needs_begin_frame_) | 244 if (needs_begin_frame_) |
| 235 begin_frame_source_->AddObserver(this); | 245 begin_frame_source_->AddObserver(this); |
| 236 else | 246 else |
| 237 begin_frame_source_->RemoveObserver(this); | 247 begin_frame_source_->RemoveObserver(this); |
| 238 } | 248 } |
| 239 | 249 |
| 240 } // namespace cc | 250 } // namespace cc |
| OLD | NEW |