| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "services/ui/surfaces/display_compositor.h" | 5 #include "services/ui/surfaces/display_compositor.h" |
| 6 | 6 |
| 7 #include "cc/surfaces/surface.h" |
| 8 |
| 7 namespace ui { | 9 namespace ui { |
| 8 | 10 |
| 9 DisplayCompositor::DisplayCompositor( | 11 DisplayCompositor::DisplayCompositor( |
| 10 cc::mojom::DisplayCompositorClientPtr client) | 12 cc::mojom::DisplayCompositorClientPtr client) |
| 11 : client_(std::move(client)) { | 13 : client_(std::move(client)) { |
| 12 manager_.AddObserver(this); | 14 manager_.AddObserver(this); |
| 13 } | 15 } |
| 14 | 16 |
| 15 void DisplayCompositor::ReturnSurfaceReference( | 17 void DisplayCompositor::AddSurfaceReference( |
| 16 const cc::SurfaceSequence& sequence) { | 18 const cc::SurfaceId& surface_id, |
| 17 std::vector<uint32_t> sequences; | 19 const cc::SurfaceSequence& surface_sequence) { |
| 18 sequences.push_back(sequence.sequence); | 20 cc::Surface* surface = manager_.GetSurfaceForId(surface_id); |
| 19 manager_.DidSatisfySequences(sequence.frame_sink_id, &sequences); | 21 if (!surface) { |
| 22 LOG(ERROR) << "Attempting to add dependency to nonexistent surface " |
| 23 << surface_id.ToString(); |
| 24 return; |
| 25 } |
| 26 surface->AddDestructionDependency(surface_sequence); |
| 27 } |
| 28 |
| 29 void DisplayCompositor::ReturnSurfaceReferences( |
| 30 const cc::FrameSinkId& frame_sink_id, |
| 31 const std::vector<uint32_t>& sequences) { |
| 32 std::vector<uint32_t> sequences_copy(sequences); |
| 33 manager_.DidSatisfySequences(frame_sink_id, &sequences_copy); |
| 20 } | 34 } |
| 21 | 35 |
| 22 DisplayCompositor::~DisplayCompositor() { | 36 DisplayCompositor::~DisplayCompositor() { |
| 23 manager_.RemoveObserver(this); | 37 manager_.RemoveObserver(this); |
| 24 } | 38 } |
| 25 | 39 |
| 26 void DisplayCompositor::OnSurfaceCreated(const cc::SurfaceId& surface_id, | 40 void DisplayCompositor::OnSurfaceCreated(const cc::SurfaceId& surface_id, |
| 27 const gfx::Size& frame_size, | 41 const gfx::Size& frame_size, |
| 28 float device_scale_factor) { | 42 float device_scale_factor) { |
| 29 if (client_) | 43 if (client_) |
| 30 client_->OnSurfaceCreated(surface_id, frame_size, device_scale_factor); | 44 client_->OnSurfaceCreated(surface_id, frame_size, device_scale_factor); |
| 31 } | 45 } |
| 32 | 46 |
| 33 void DisplayCompositor::OnSurfaceDamaged(const cc::SurfaceId& surface_id, | 47 void DisplayCompositor::OnSurfaceDamaged(const cc::SurfaceId& surface_id, |
| 34 bool* changed) {} | 48 bool* changed) {} |
| 35 | 49 |
| 36 } // namespace ui | 50 } // namespace ui |
| OLD | NEW |