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 "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 bool needs_sync_points, |
| 22 bool for_direct_compositor_frame_sink) | |
| 22 : client_(client), | 23 : client_(client), |
| 23 surface_manager_(surface_manager), | 24 surface_manager_(surface_manager), |
| 24 frame_sink_id_(frame_sink_id), | 25 frame_sink_id_(frame_sink_id), |
| 25 display_begin_frame_source_(std::move(display_begin_frame_source)), | 26 display_(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 for_direct_compositor_frame_sink_(for_direct_compositor_frame_sink), | |
| 28 weak_factory_(this) { | 29 weak_factory_(this) { |
| 29 surface_manager_->RegisterFrameSinkId(frame_sink_id_); | 30 if (!for_direct_compositor_frame_sink_) |
|
danakj
2017/02/06 16:42:58
The naming of this violates layering. It should ma
Alex Z.
2017/02/07 17:22:00
Done.
| |
| 31 surface_manager_->RegisterFrameSinkId(frame_sink_id_); | |
| 32 | |
| 30 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); | 33 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); |
| 34 surface_factory_.set_needs_sync_points(needs_sync_points); | |
| 31 | 35 |
| 32 if (display_) { | 36 if (display_) |
| 33 display_->Initialize(this, surface_manager_); | 37 display_->Initialize(this, surface_manager_); |
| 34 display_->SetVisible(true); | |
| 35 } | |
| 36 } | 38 } |
| 37 | 39 |
| 38 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() { | 40 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() { |
| 39 for (auto& child_frame_sink_id : child_frame_sinks_) { | 41 for (auto& child_frame_sink_id : child_frame_sinks_) { |
| 40 DCHECK(child_frame_sink_id.is_valid()); | 42 DCHECK(child_frame_sink_id.is_valid()); |
| 41 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, | 43 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, |
| 42 child_frame_sink_id); | 44 child_frame_sink_id); |
| 43 } | 45 } |
| 44 // SurfaceFactory's destructor will attempt to return resources which will | 46 // SurfaceFactory's destructor will attempt to return resources which will |
| 45 // call back into here and access |client_| so we should destroy | 47 // call back into here and access |client_| so we should destroy |
| 46 // |surface_factory_|'s resources early on. | 48 // |surface_factory_|'s resources early on. |
| 47 surface_factory_.EvictSurface(); | 49 surface_factory_.EvictSurface(); |
| 48 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); | 50 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); |
| 49 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); | 51 if (!for_direct_compositor_frame_sink_) |
| 52 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); | |
| 50 } | 53 } |
| 51 | 54 |
| 52 void CompositorFrameSinkSupport::EvictFrame() { | 55 void CompositorFrameSinkSupport::EvictFrame() { |
| 53 surface_factory_.EvictSurface(); | 56 surface_factory_.EvictSurface(); |
| 54 } | 57 } |
| 55 | 58 |
| 56 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { | 59 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { |
| 57 needs_begin_frame_ = needs_begin_frame; | 60 needs_begin_frame_ = needs_begin_frame; |
| 58 UpdateNeedsBeginFramesInternal(); | 61 UpdateNeedsBeginFramesInternal(); |
| 59 } | 62 } |
| 60 | 63 |
| 61 void CompositorFrameSinkSupport::SubmitCompositorFrame( | 64 void CompositorFrameSinkSupport::SubmitCompositorFrame( |
| 62 const LocalSurfaceId& local_surface_id, | 65 const LocalSurfaceId& local_surface_id, |
| 63 CompositorFrame frame) { | 66 CompositorFrame frame) { |
| 64 ++ack_pending_count_; | 67 ++ack_pending_count_; |
| 68 if (display_) { | |
| 69 display_->SetLocalSurfaceId(local_surface_id, | |
| 70 frame.metadata.device_scale_factor); | |
| 71 } | |
| 65 surface_factory_.SubmitCompositorFrame( | 72 surface_factory_.SubmitCompositorFrame( |
| 66 local_surface_id, std::move(frame), | 73 local_surface_id, std::move(frame), |
| 67 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, | 74 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, |
| 68 weak_factory_.GetWeakPtr())); | 75 weak_factory_.GetWeakPtr())); |
| 69 if (display_) { | |
| 70 display_->SetLocalSurfaceId(local_surface_id, | |
| 71 frame.metadata.device_scale_factor); | |
| 72 } | |
| 73 } | 76 } |
| 74 | 77 |
| 75 void CompositorFrameSinkSupport::Require(const LocalSurfaceId& local_surface_id, | 78 void CompositorFrameSinkSupport::Require(const LocalSurfaceId& local_surface_id, |
| 76 const SurfaceSequence& sequence) { | 79 const SurfaceSequence& sequence) { |
| 77 surface_manager_->RequireSequence(SurfaceId(frame_sink_id_, local_surface_id), | 80 surface_manager_->RequireSequence(SurfaceId(frame_sink_id_, local_surface_id), |
| 78 sequence); | 81 sequence); |
| 79 } | 82 } |
| 80 | 83 |
| 81 void CompositorFrameSinkSupport::Satisfy(const SurfaceSequence& sequence) { | 84 void CompositorFrameSinkSupport::Satisfy(const SurfaceSequence& sequence) { |
| 82 surface_manager_->SatisfySequence(sequence); | 85 surface_manager_->SatisfySequence(sequence); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 105 void CompositorFrameSinkSupport::RemoveChildFrameSink( | 108 void CompositorFrameSinkSupport::RemoveChildFrameSink( |
| 106 const FrameSinkId& child_frame_sink_id) { | 109 const FrameSinkId& child_frame_sink_id) { |
| 107 auto it = child_frame_sinks_.find(child_frame_sink_id); | 110 auto it = child_frame_sinks_.find(child_frame_sink_id); |
| 108 DCHECK(it != child_frame_sinks_.end()); | 111 DCHECK(it != child_frame_sinks_.end()); |
| 109 DCHECK(it->is_valid()); | 112 DCHECK(it->is_valid()); |
| 110 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, | 113 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, |
| 111 child_frame_sink_id); | 114 child_frame_sink_id); |
| 112 child_frame_sinks_.erase(it); | 115 child_frame_sinks_.erase(it); |
| 113 } | 116 } |
| 114 | 117 |
| 118 void CompositorFrameSinkSupport::ForceReclaimResources() { | |
| 119 surface_factory_.ClearSurface(); | |
| 120 } | |
| 121 | |
| 115 void CompositorFrameSinkSupport::DisplayOutputSurfaceLost() {} | 122 void CompositorFrameSinkSupport::DisplayOutputSurfaceLost() {} |
| 116 | 123 |
| 117 void CompositorFrameSinkSupport::DisplayWillDrawAndSwap( | 124 void CompositorFrameSinkSupport::DisplayWillDrawAndSwap( |
| 118 bool will_draw_and_swap, | 125 bool will_draw_and_swap, |
| 119 const RenderPassList& render_passes) {} | 126 const RenderPassList& render_passes) {} |
| 120 | 127 |
| 121 void CompositorFrameSinkSupport::DisplayDidDrawAndSwap() {} | 128 void CompositorFrameSinkSupport::DisplayDidDrawAndSwap() {} |
| 122 | 129 |
| 123 void CompositorFrameSinkSupport::ReturnResources( | 130 void CompositorFrameSinkSupport::ReturnResources( |
| 124 const ReturnedResourceArray& resources) { | 131 const ReturnedResourceArray& resources) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 return; | 180 return; |
| 174 | 181 |
| 175 added_frame_observer_ = needs_begin_frame_; | 182 added_frame_observer_ = needs_begin_frame_; |
| 176 if (needs_begin_frame_) | 183 if (needs_begin_frame_) |
| 177 begin_frame_source_->AddObserver(this); | 184 begin_frame_source_->AddObserver(this); |
| 178 else | 185 else |
| 179 begin_frame_source_->RemoveObserver(this); | 186 begin_frame_source_->RemoveObserver(this); |
| 180 } | 187 } |
| 181 | 188 |
| 182 } // namespace cc | 189 } // namespace cc |
| OLD | NEW |