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 <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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 | 176 |
| 177 void CompositorFrameSinkSupport::ForceReclaimResources() { | 177 void CompositorFrameSinkSupport::ForceReclaimResources() { |
| 178 surface_factory_.ClearSurface(); | 178 surface_factory_.ClearSurface(); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void CompositorFrameSinkSupport::ClaimTemporaryReference( | 181 void CompositorFrameSinkSupport::ClaimTemporaryReference( |
| 182 const SurfaceId& surface_id) { | 182 const SurfaceId& surface_id) { |
| 183 surface_manager_->AssignTemporaryReference(surface_id, frame_sink_id_); | 183 surface_manager_->AssignTemporaryReference(surface_id, frame_sink_id_); |
| 184 } | 184 } |
| 185 | 185 |
| 186 BeginFrameSource* CompositorFrameSinkSupport::BeginFrameSourceForTesting() | |
| 187 const { | |
| 188 return begin_frame_source_; | |
| 189 } | |
| 190 const ReturnedResourceArray& | |
| 191 CompositorFrameSinkSupport::LastReturnedResourcesForTesting() const { | |
|
Fady Samuel
2017/04/05 14:42:32
Remove this?
Alex Z.
2017/04/05 20:43:13
Done.
| |
| 192 return last_returned_resources_; | |
| 193 } | |
| 194 | |
| 186 void CompositorFrameSinkSupport::ReferencedSurfacesChanged( | 195 void CompositorFrameSinkSupport::ReferencedSurfacesChanged( |
| 187 const LocalSurfaceId& local_surface_id, | 196 const LocalSurfaceId& local_surface_id, |
| 188 const std::vector<SurfaceId>* active_referenced_surfaces, | 197 const std::vector<SurfaceId>* active_referenced_surfaces, |
| 189 const std::vector<SurfaceId>* pending_referenced_surfaces) { | 198 const std::vector<SurfaceId>* pending_referenced_surfaces) { |
| 190 if (!surface_manager_->using_surface_references()) | 199 if (!surface_manager_->using_surface_references()) |
| 191 return; | 200 return; |
| 192 | 201 |
| 193 SurfaceId last_surface_id = reference_tracker_.current_surface_id(); | 202 SurfaceId last_surface_id = reference_tracker_.current_surface_id(); |
| 194 | 203 |
| 195 // Populate list of surface references to add and remove based on reference | 204 // Populate list of surface references to add and remove based on reference |
| 196 // surfaces in current frame compared with the last frame. The list of | 205 // surfaces in current frame compared with the last frame. The list of |
| 197 // surface references includes references from both the pending and active | 206 // surface references includes references from both the pending and active |
| 198 // frame if any. | 207 // frame if any. |
| 199 reference_tracker_.UpdateReferences(local_surface_id, | 208 reference_tracker_.UpdateReferences(local_surface_id, |
| 200 active_referenced_surfaces, | 209 active_referenced_surfaces, |
| 201 pending_referenced_surfaces); | 210 pending_referenced_surfaces); |
| 202 | 211 |
| 203 UpdateSurfaceReferences(last_surface_id, local_surface_id); | 212 UpdateSurfaceReferences(last_surface_id, local_surface_id); |
| 204 } | 213 } |
| 205 | 214 |
| 206 void CompositorFrameSinkSupport::ReturnResources( | 215 void CompositorFrameSinkSupport::ReturnResources( |
| 207 const ReturnedResourceArray& resources) { | 216 const ReturnedResourceArray& resources) { |
| 217 last_returned_resources_ = resources; | |
|
Fady Samuel
2017/04/05 14:42:32
Don't expose this?
Alex Z.
2017/04/05 20:43:13
Done.
| |
| 208 if (resources.empty()) | 218 if (resources.empty()) |
| 209 return; | 219 return; |
| 210 | 220 |
| 211 if (!ack_pending_count_ && client_) { | 221 if (!ack_pending_count_ && client_) { |
| 212 client_->ReclaimResources(resources); | 222 client_->ReclaimResources(resources); |
| 213 return; | 223 return; |
| 214 } | 224 } |
| 215 | 225 |
| 216 std::copy(resources.begin(), resources.end(), | 226 std::copy(resources.begin(), resources.end(), |
| 217 std::back_inserter(surface_returned_resources_)); | 227 std::back_inserter(surface_returned_resources_)); |
| 218 } | 228 } |
| 219 | 229 |
| 220 void CompositorFrameSinkSupport::SetBeginFrameSource( | 230 void CompositorFrameSinkSupport::SetBeginFrameSource( |
| 221 BeginFrameSource* begin_frame_source) { | 231 BeginFrameSource* begin_frame_source) { |
| 222 if (begin_frame_source_ && added_frame_observer_) { | 232 if (begin_frame_source_ && added_frame_observer_) { |
| 223 begin_frame_source_->RemoveObserver(this); | 233 begin_frame_source_->RemoveObserver(this); |
| 224 added_frame_observer_ = false; | 234 added_frame_observer_ = false; |
| 225 } | 235 } |
| 226 begin_frame_source_ = begin_frame_source; | 236 begin_frame_source_ = begin_frame_source; |
| 227 UpdateNeedsBeginFramesInternal(); | 237 UpdateNeedsBeginFramesInternal(); |
| 228 } | 238 } |
| 229 | 239 |
| 230 void CompositorFrameSinkSupport::WillDrawSurface( | 240 void CompositorFrameSinkSupport::WillDrawSurface( |
| 231 const LocalSurfaceId& local_surface_id, | 241 const LocalSurfaceId& local_surface_id, |
| 232 const gfx::Rect& damage_rect) { | 242 const gfx::Rect& damage_rect) { |
| 243 last_local_surface_id_ = local_surface_id; | |
| 244 last_damage_rect_ = damage_rect; | |
|
Fady Samuel
2017/04/05 14:42:32
Don't expose these. Implement CompositorFrameSinkS
Alex Z.
2017/04/05 20:43:13
Done.
| |
| 233 if (client_) | 245 if (client_) |
| 234 client_->WillDrawSurface(local_surface_id, damage_rect); | 246 client_->WillDrawSurface(local_surface_id, damage_rect); |
| 235 } | 247 } |
| 236 | 248 |
| 237 void CompositorFrameSinkSupport::OnBeginFrame(const BeginFrameArgs& args) { | 249 void CompositorFrameSinkSupport::OnBeginFrame(const BeginFrameArgs& args) { |
| 238 UpdateNeedsBeginFramesInternal(); | 250 UpdateNeedsBeginFramesInternal(); |
| 239 last_begin_frame_args_ = args; | 251 last_begin_frame_args_ = args; |
| 240 if (client_) | 252 if (client_) |
| 241 client_->OnBeginFrame(args); | 253 client_->OnBeginFrame(args); |
| 242 } | 254 } |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 261 else | 273 else |
| 262 begin_frame_source_->RemoveObserver(this); | 274 begin_frame_source_->RemoveObserver(this); |
| 263 } | 275 } |
| 264 | 276 |
| 265 void CompositorFrameSinkSupport::RequestCopyOfSurface( | 277 void CompositorFrameSinkSupport::RequestCopyOfSurface( |
| 266 std::unique_ptr<CopyOutputRequest> request) { | 278 std::unique_ptr<CopyOutputRequest> request) { |
| 267 surface_factory_.RequestCopyOfSurface(std::move(request)); | 279 surface_factory_.RequestCopyOfSurface(std::move(request)); |
| 268 } | 280 } |
| 269 | 281 |
| 270 } // namespace cc | 282 } // namespace cc |
| OLD | NEW |