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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "cc/surfaces/surface.h" | 8 #include "cc/surfaces/surface.h" |
9 | 9 |
10 namespace cc { | 10 namespace cc { |
11 | 11 |
12 SurfaceManager::SurfaceManager() { | 12 SurfaceManager::SurfaceManager() { |
13 } | 13 } |
14 | 14 |
15 SurfaceManager::~SurfaceManager() { | 15 SurfaceManager::~SurfaceManager() { |
16 DCHECK_EQ(0u, surface_map_.size()); | |
17 } | 16 } |
18 | 17 |
19 void SurfaceManager::RegisterSurface(Surface* surface) { | 18 void SurfaceManager::RegisterSurface(Surface* surface) { |
20 DCHECK(surface); | 19 DCHECK(surface); |
21 DCHECK(!surface_map_.count(surface->surface_id())); | 20 DCHECK(!surface_map_.count(surface->surface_id())); |
22 surface_map_[surface->surface_id()] = surface; | 21 surface_map_[surface->surface_id()] = surface; |
23 } | 22 } |
24 | 23 |
25 void SurfaceManager::DeregisterSurface(SurfaceId surface_id) { | 24 void SurfaceManager::DeregisterSurface(SurfaceId surface_id) { |
26 SurfaceMap::iterator it = surface_map_.find(surface_id); | 25 SurfaceMap::iterator it = surface_map_.find(surface_id); |
27 DCHECK(it != surface_map_.end()); | 26 DCHECK(it != surface_map_.end()); |
28 surface_map_.erase(it); | 27 surface_map_.erase(it); |
29 } | 28 } |
30 | 29 |
31 Surface* SurfaceManager::GetSurfaceForId(SurfaceId surface_id) { | 30 Surface* SurfaceManager::GetSurfaceForId(SurfaceId surface_id) { |
32 SurfaceMap::iterator it = surface_map_.find(surface_id); | 31 SurfaceMap::iterator it = surface_map_.find(surface_id); |
33 if (it == surface_map_.end()) | 32 if (it == surface_map_.end()) |
34 return NULL; | 33 return NULL; |
35 return it->second; | 34 return it->second; |
36 } | 35 } |
37 | 36 |
38 void SurfaceManager::SurfaceModified(SurfaceId surface_id) { | 37 void SurfaceManager::SurfaceModified(SurfaceId surface_id) { |
39 FOR_EACH_OBSERVER( | 38 FOR_EACH_OBSERVER( |
40 SurfaceDamageObserver, observer_list_, OnSurfaceDamaged(surface_id)); | 39 SurfaceDamageObserver, observer_list_, OnSurfaceDamaged(surface_id)); |
41 } | 40 } |
42 | 41 |
43 } // namespace cc | 42 } // namespace cc |
OLD | NEW |