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 |
| 87 // If this fails then that implies that a client is trying to reference a |
| 88 // surface that no longer exists. This could result in flicker or missing |
| 89 // components of UI. |
| 90 DCHECK(surface); |
| 91 surface->AddDestructionDependency(sequence); |
| 92 } |
| 93 |
| 94 void CompositorFrameSinkSupport::Satisfy(const SurfaceSequence& sequence) { |
| 95 std::vector<uint32_t> sequences = {sequence.sequence}; |
| 96 surface_manager_->DidSatisfySequences(frame_sink_id_, &sequences); |
| 97 } |
| 98 |
81 void CompositorFrameSinkSupport::DidReceiveCompositorFrameAck() { | 99 void CompositorFrameSinkSupport::DidReceiveCompositorFrameAck() { |
82 DCHECK_GT(ack_pending_count_, 0); | 100 DCHECK_GT(ack_pending_count_, 0); |
83 ack_pending_count_--; | 101 ack_pending_count_--; |
84 | 102 |
85 if (!client_) | 103 if (!client_) |
86 return; | 104 return; |
87 client_->DidReceiveCompositorFrameAck(); | 105 client_->DidReceiveCompositorFrameAck(); |
88 if (!surface_returned_resources_.empty()) { | 106 if (!surface_returned_resources_.empty()) { |
89 client_->ReclaimResources(surface_returned_resources_); | 107 client_->ReclaimResources(surface_returned_resources_); |
90 surface_returned_resources_.clear(); | 108 surface_returned_resources_.clear(); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 return; | 182 return; |
165 | 183 |
166 added_frame_observer_ = needs_begin_frame_; | 184 added_frame_observer_ = needs_begin_frame_; |
167 if (needs_begin_frame_) | 185 if (needs_begin_frame_) |
168 begin_frame_source_->AddObserver(this); | 186 begin_frame_source_->AddObserver(this); |
169 else | 187 else |
170 begin_frame_source_->RemoveObserver(this); | 188 begin_frame_source_->RemoveObserver(this); |
171 } | 189 } |
172 | 190 |
173 } // namespace cc | 191 } // namespace cc |
OLD | NEW |