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_manager.h" | 12 #include "cc/surfaces/surface_manager.h" |
| 12 | 13 |
| 13 namespace cc { | 14 namespace cc { |
| 14 | 15 |
| 15 CompositorFrameSinkSupport::CompositorFrameSinkSupport( | 16 CompositorFrameSinkSupport::CompositorFrameSinkSupport( |
| 16 CompositorFrameSinkSupportClient* client, | 17 CompositorFrameSinkSupportClient* client, |
| 17 SurfaceManager* surface_manager, | 18 SurfaceManager* surface_manager, |
| 18 const FrameSinkId& frame_sink_id, | 19 const FrameSinkId& frame_sink_id, |
| 19 std::unique_ptr<Display> display) | 20 std::unique_ptr<Display> display) |
| 20 : client_(client), | 21 : client_(client), |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 surface_factory_.SubmitCompositorFrame( | 72 surface_factory_.SubmitCompositorFrame( |
| 72 local_frame_id_, std::move(frame), | 73 local_frame_id_, std::move(frame), |
| 73 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, | 74 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, |
| 74 weak_factory_.GetWeakPtr())); | 75 weak_factory_.GetWeakPtr())); |
| 75 if (display_) { | 76 if (display_) { |
| 76 display_->SetLocalFrameId(local_frame_id_, | 77 display_->SetLocalFrameId(local_frame_id_, |
| 77 frame.metadata.device_scale_factor); | 78 frame.metadata.device_scale_factor); |
| 78 } | 79 } |
| 79 } | 80 } |
| 80 | 81 |
| 82 void CompositorFrameSinkSupport::Require(const LocalFrameId& local_frame_id, | |
| 83 const SurfaceSequence& sequence) { | |
| 84 Surface* surface = surface_manager_->GetSurfaceForId( | |
| 85 SurfaceId(frame_sink_id_, local_frame_id)); | |
| 86 DCHECK(surface); // Ensure the surface exists before requiring callback | |
|
Fady Samuel
2016/12/06 16:45:25
nit: How about this comment?
If this fails then
Alex Z.
2016/12/06 16:55:40
Done.
| |
| 87 surface->AddDestructionDependency(sequence); | |
| 88 } | |
| 89 | |
| 90 void CompositorFrameSinkSupport::Satisfy(const SurfaceSequence& sequence) { | |
| 91 std::vector<uint32_t> sequences = {sequence.sequence}; | |
| 92 surface_manager_->DidSatisfySequences(sequence.frame_sink_id, &sequences); | |
| 93 } | |
| 94 | |
| 81 void CompositorFrameSinkSupport::DidReceiveCompositorFrameAck() { | 95 void CompositorFrameSinkSupport::DidReceiveCompositorFrameAck() { |
| 82 DCHECK_GT(ack_pending_count_, 0); | 96 DCHECK_GT(ack_pending_count_, 0); |
| 83 ack_pending_count_--; | 97 ack_pending_count_--; |
| 84 | 98 |
| 85 if (!client_) | 99 if (!client_) |
| 86 return; | 100 return; |
| 87 client_->DidReceiveCompositorFrameAck(); | 101 client_->DidReceiveCompositorFrameAck(); |
| 88 if (!surface_returned_resources_.empty()) { | 102 if (!surface_returned_resources_.empty()) { |
| 89 client_->ReclaimResources(surface_returned_resources_); | 103 client_->ReclaimResources(surface_returned_resources_); |
| 90 surface_returned_resources_.clear(); | 104 surface_returned_resources_.clear(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 return; | 178 return; |
| 165 | 179 |
| 166 added_frame_observer_ = needs_begin_frame_; | 180 added_frame_observer_ = needs_begin_frame_; |
| 167 if (needs_begin_frame_) | 181 if (needs_begin_frame_) |
| 168 begin_frame_source_->AddObserver(this); | 182 begin_frame_source_->AddObserver(this); |
| 169 else | 183 else |
| 170 begin_frame_source_->RemoveObserver(this); | 184 begin_frame_source_->RemoveObserver(this); |
| 171 } | 185 } |
| 172 | 186 |
| 173 } // namespace cc | 187 } // namespace cc |
| OLD | NEW |