summaryrefslogtreecommitdiff
path: root/src/mbgl/gl/texture_pool.hpp
blob: 10f63bfac9cce163076d477f0206a2984642cc40 (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
#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