blob: a875f4d579d6d1cf15088ba268210e0d8182d976 (
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
|
#include <mbgl/gl/texture_pool.hpp>
#include <mbgl/gl/gl_object_store.hpp>
#include <vector>
namespace mbgl {
namespace gl {
GLuint TexturePool::getTextureID(gl::GLObjectStore& glObjectStore) {
for (auto& impl : pools) {
if (impl.ids.empty()) continue;
auto it = impl.ids.begin();
GLuint id = *it;
impl.ids.erase(it);
return id;
}
// All texture IDs are in use.
pools.emplace_back(Impl(glObjectStore));
auto it = pools.back().ids.begin();
GLuint id = *it;
pools.back().ids.erase(it);
return id;
}
void TexturePool::releaseTextureID(GLuint id) {
for (auto it = pools.begin(); it != pools.end(); ++it) {
for (GLsizei i = 0; i < gl::TexturePoolHolder::TextureMax; ++i) {
if (it->pool[i] == id) {
it->ids.push_back(id);
if (GLsizei(it->ids.size()) == gl::TexturePoolHolder::TextureMax) {
pools.erase(it);
}
return;
}
}
}
}
} // namespace gl
} // namespace mbgl
|