summaryrefslogtreecommitdiff
path: root/src/mbgl/gl/texture_pool.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/gl/texture_pool.hpp')
-rw-r--r--src/mbgl/gl/texture_pool.hpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/mbgl/gl/texture_pool.hpp b/src/mbgl/gl/texture_pool.hpp
new file mode 100644
index 0000000000..10f63bfac9
--- /dev/null
+++ b/src/mbgl/gl/texture_pool.hpp
@@ -0,0 +1,41 @@
+#ifndef MBGL_UTIL_TEXTUREPOOL
+#define MBGL_UTIL_TEXTUREPOOL
+
+#include <mbgl/util/noncopyable.hpp>
+#include <mbgl/gl/gl.hpp>
+#include <mbgl/gl/gl_object_store.hpp>
+
+#include <algorithm>
+#include <memory>
+#include <vector>
+
+namespace mbgl {
+namespace gl {
+
+class TexturePool : private util::noncopyable {
+public:
+ GLuint getTextureID(gl::GLObjectStore&);
+ void releaseTextureID(GLuint);
+
+private:
+ class Impl : private util::noncopyable {
+ public:
+ Impl(gl::GLObjectStore& glObjectStore) : ids(gl::TexturePoolHolder::TextureMax) {
+ pool.create(glObjectStore);
+ std::copy(pool.getIDs().begin(), pool.getIDs().end(), ids.begin());
+ }
+
+ Impl(Impl&& o) : pool(std::move(o.pool)), ids(std::move(o.ids)) {}
+ Impl& operator=(Impl&& o) { pool = std::move(o.pool); ids = std::move(o.ids); return *this; }
+
+ gl::TexturePoolHolder pool;
+ std::vector<GLuint> ids;
+ };
+
+ std::vector<Impl> pools;
+};
+
+} // namespace gl
+} // namespace mbgl
+
+#endif