Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/surface_manager.h" | 5 #include "cc/surfaces/surface_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 // the queue and reuse it. | 115 // the queue and reuse it. |
| 116 auto it = | 116 auto it = |
| 117 std::find_if(surfaces_to_destroy_.begin(), surfaces_to_destroy_.end(), | 117 std::find_if(surfaces_to_destroy_.begin(), surfaces_to_destroy_.end(), |
| 118 [&surface_id](const std::unique_ptr<Surface>& surface) { | 118 [&surface_id](const std::unique_ptr<Surface>& surface) { |
| 119 return surface->surface_id() == surface_id; | 119 return surface->surface_id() == surface_id; |
| 120 }); | 120 }); |
| 121 DCHECK(it != surfaces_to_destroy_.end()); | 121 DCHECK(it != surfaces_to_destroy_.end()); |
| 122 std::unique_ptr<Surface> surface = std::move(*it); | 122 std::unique_ptr<Surface> surface = std::move(*it); |
| 123 surfaces_to_destroy_.erase(it); | 123 surfaces_to_destroy_.erase(it); |
| 124 surface->set_destroyed(false); | 124 surface->set_destroyed(false); |
| 125 DCHECK_EQ(surface_factory.get(), surface->factory().get()); | 125 surface->set_factory(surface_factory); |
|
Fady Samuel
2017/03/15 12:05:47
This is subtle and needs a unit test. Parent refer
Saman Sami
2017/03/16 18:33:06
Done.
| |
| 126 return surface; | 126 return surface; |
| 127 } | 127 } |
| 128 | 128 |
| 129 void SurfaceManager::DestroySurface(std::unique_ptr<Surface> surface) { | 129 void SurfaceManager::DestroySurface(std::unique_ptr<Surface> surface) { |
| 130 DCHECK(thread_checker_.CalledOnValidThread()); | 130 DCHECK(thread_checker_.CalledOnValidThread()); |
| 131 surface->set_destroyed(true); | 131 surface->set_destroyed(true); |
| 132 surfaces_to_destroy_.push_back(std::move(surface)); | 132 surfaces_to_destroy_.push_back(std::move(surface)); |
| 133 GarbageCollectSurfaces(); | 133 GarbageCollectSurfaces(); |
| 134 } | 134 } |
| 135 | 135 |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 688 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end()); | 688 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end()); |
| 689 std::sort(children.begin(), children.end()); | 689 std::sort(children.begin(), children.end()); |
| 690 | 690 |
| 691 for (const SurfaceId& child_id : children) | 691 for (const SurfaceId& child_id : children) |
| 692 SurfaceReferencesToStringImpl(child_id, indent + " ", str); | 692 SurfaceReferencesToStringImpl(child_id, indent + " ", str); |
| 693 } | 693 } |
| 694 } | 694 } |
| 695 #endif // DCHECK_IS_ON() | 695 #endif // DCHECK_IS_ON() |
| 696 | 696 |
| 697 } // namespace cc | 697 } // namespace cc |
| OLD | NEW |