Adding Peter Thatcher to the owners file.
[chromium-blink-merge.git] / cc / test / ordered_texture_map.cc
blob649700c49795a8eb12ff29626e0c1ea1f1b1d14f
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
3 // found in the LICENSE file.
5 #include "cc/test/ordered_texture_map.h"
7 #include "base/logging.h"
8 #include "cc/test/test_texture.h"
10 namespace cc {
12 OrderedTextureMap::OrderedTextureMap() {}
14 OrderedTextureMap::~OrderedTextureMap() {}
16 void OrderedTextureMap::Append(GLuint id,
17 scoped_refptr<TestTexture> texture) {
18 DCHECK(texture.get());
19 DCHECK(!ContainsId(id));
21 textures_[id] = texture;
22 ordered_textures_.push_back(id);
25 void OrderedTextureMap::Replace(GLuint id,
26 scoped_refptr<TestTexture> texture) {
27 DCHECK(texture.get());
28 DCHECK(ContainsId(id));
30 textures_[id] = texture;
33 void OrderedTextureMap::Remove(GLuint id) {
34 TextureMap::iterator map_it = textures_.find(id);
35 // for some test we generate dummy tex id, which are not registered,
36 // nothing to remove in that case.
37 if (map_it == textures_.end())
38 return;
39 textures_.erase(map_it);
41 TextureList::iterator list_it =
42 std::find(ordered_textures_.begin(), ordered_textures_.end(), id);
43 DCHECK(list_it != ordered_textures_.end());
44 ordered_textures_.erase(list_it);
47 size_t OrderedTextureMap::Size() { return ordered_textures_.size(); }
49 bool OrderedTextureMap::ContainsId(GLuint id) {
50 return textures_.find(id) != textures_.end();
53 scoped_refptr<TestTexture> OrderedTextureMap::TextureForId(GLuint id) {
54 DCHECK(ContainsId(id));
55 scoped_refptr<TestTexture> texture = textures_[id];
56 DCHECK(texture.get());
57 return texture;
60 GLuint OrderedTextureMap::IdAt(size_t index) {
61 DCHECK(index < Size());
62 return ordered_textures_[index];
65 } // namespace cc