blob: 649700c49795a8eb12ff29626e0c1ea1f1b1d14f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/test/ordered_texture_map.h"
#include "base/logging.h"
#include "cc/test/test_texture.h"
namespace cc {
OrderedTextureMap::OrderedTextureMap() {}
OrderedTextureMap::~OrderedTextureMap() {}
void OrderedTextureMap::Append(GLuint id,
scoped_refptr<TestTexture> texture) {
DCHECK(texture.get());
DCHECK(!ContainsId(id));
textures_[id] = texture;
ordered_textures_.push_back(id);
}
void OrderedTextureMap::Replace(GLuint id,
scoped_refptr<TestTexture> texture) {
DCHECK(texture.get());
DCHECK(ContainsId(id));
textures_[id] = texture;
}
void OrderedTextureMap::Remove(GLuint id) {
TextureMap::iterator map_it = textures_.find(id);
// for some test we generate dummy tex id, which are not registered,
// nothing to remove in that case.
if (map_it == textures_.end())
return;
textures_.erase(map_it);
TextureList::iterator list_it =
std::find(ordered_textures_.begin(), ordered_textures_.end(), id);
DCHECK(list_it != ordered_textures_.end());
ordered_textures_.erase(list_it);
}
size_t OrderedTextureMap::Size() { return ordered_textures_.size(); }
bool OrderedTextureMap::ContainsId(GLuint id) {
return textures_.find(id) != textures_.end();
}
scoped_refptr<TestTexture> OrderedTextureMap::TextureForId(GLuint id) {
DCHECK(ContainsId(id));
scoped_refptr<TestTexture> texture = textures_[id];
DCHECK(texture.get());
return texture;
}
GLuint OrderedTextureMap::IdAt(size_t index) {
DCHECK(index < Size());
return ordered_textures_[index];
}
} // namespace cc
|