| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test/ordered_texture_map.h" | 5 #include "cc/test/ordered_texture_map.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "cc/test/test_texture.h" | 8 #include "cc/test/test_texture.h" |
| 9 | 9 |
| 10 namespace cc { | 10 namespace cc { |
| 11 | 11 |
| 12 OrderedTextureMap::OrderedTextureMap() {} | 12 OrderedTextureMap::OrderedTextureMap() {} |
| 13 | 13 |
| 14 OrderedTextureMap::~OrderedTextureMap() {} | 14 OrderedTextureMap::~OrderedTextureMap() {} |
| 15 | 15 |
| 16 void OrderedTextureMap::Append(WebKit::WebGLId id, | 16 void OrderedTextureMap::Append(blink::WebGLId id, |
| 17 scoped_refptr<TestTexture> texture) { | 17 scoped_refptr<TestTexture> texture) { |
| 18 DCHECK(texture.get()); | 18 DCHECK(texture.get()); |
| 19 DCHECK(!ContainsId(id)); | 19 DCHECK(!ContainsId(id)); |
| 20 | 20 |
| 21 textures_[id] = texture; | 21 textures_[id] = texture; |
| 22 ordered_textures_.push_back(id); | 22 ordered_textures_.push_back(id); |
| 23 } | 23 } |
| 24 | 24 |
| 25 void OrderedTextureMap::Replace(WebKit::WebGLId id, | 25 void OrderedTextureMap::Replace(blink::WebGLId id, |
| 26 scoped_refptr<TestTexture> texture) { | 26 scoped_refptr<TestTexture> texture) { |
| 27 DCHECK(texture.get()); | 27 DCHECK(texture.get()); |
| 28 DCHECK(ContainsId(id)); | 28 DCHECK(ContainsId(id)); |
| 29 | 29 |
| 30 textures_[id] = texture; | 30 textures_[id] = texture; |
| 31 } | 31 } |
| 32 | 32 |
| 33 void OrderedTextureMap::Remove(WebKit::WebGLId id) { | 33 void OrderedTextureMap::Remove(blink::WebGLId id) { |
| 34 TextureMap::iterator map_it = textures_.find(id); | 34 TextureMap::iterator map_it = textures_.find(id); |
| 35 DCHECK(map_it != textures_.end()); | 35 DCHECK(map_it != textures_.end()); |
| 36 textures_.erase(map_it); | 36 textures_.erase(map_it); |
| 37 | 37 |
| 38 TextureList::iterator list_it = | 38 TextureList::iterator list_it = |
| 39 std::find(ordered_textures_.begin(), ordered_textures_.end(), id); | 39 std::find(ordered_textures_.begin(), ordered_textures_.end(), id); |
| 40 DCHECK(list_it != ordered_textures_.end()); | 40 DCHECK(list_it != ordered_textures_.end()); |
| 41 ordered_textures_.erase(list_it); | 41 ordered_textures_.erase(list_it); |
| 42 } | 42 } |
| 43 | 43 |
| 44 size_t OrderedTextureMap::Size() { return ordered_textures_.size(); } | 44 size_t OrderedTextureMap::Size() { return ordered_textures_.size(); } |
| 45 | 45 |
| 46 bool OrderedTextureMap::ContainsId(WebKit::WebGLId id) { | 46 bool OrderedTextureMap::ContainsId(blink::WebGLId id) { |
| 47 return textures_.find(id) != textures_.end(); | 47 return textures_.find(id) != textures_.end(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 scoped_refptr<TestTexture> OrderedTextureMap::TextureForId(WebKit::WebGLId id) { | 50 scoped_refptr<TestTexture> OrderedTextureMap::TextureForId(blink::WebGLId id) { |
| 51 DCHECK(ContainsId(id)); | 51 DCHECK(ContainsId(id)); |
| 52 scoped_refptr<TestTexture> texture = textures_[id]; | 52 scoped_refptr<TestTexture> texture = textures_[id]; |
| 53 DCHECK(texture.get()); | 53 DCHECK(texture.get()); |
| 54 return texture; | 54 return texture; |
| 55 } | 55 } |
| 56 | 56 |
| 57 WebKit::WebGLId OrderedTextureMap::IdAt(size_t index) { | 57 blink::WebGLId OrderedTextureMap::IdAt(size_t index) { |
| 58 DCHECK(index < Size()); | 58 DCHECK(index < Size()); |
| 59 return ordered_textures_[index]; | 59 return ordered_textures_[index]; |
| 60 } | 60 } |
| 61 | 61 |
| 62 } // namespace cc | 62 } // namespace cc |
| OLD | NEW |