|
5 | 5 | namespace mbgl {
|
6 | 6 | namespace gl {
|
7 | 7 |
|
8 |
| -void ProgramHolder::create(ObjectStore& objectStore_) { |
9 |
| - if (created()) return; |
10 |
| - objectStore = &objectStore_; |
11 |
| - id = MBGL_CHECK_ERROR(glCreateProgram()); |
| 8 | +void ProgramDeleter::operator()(GLuint id) const { |
| 9 | + store.get().abandonedPrograms.push_back(id); |
12 | 10 | }
|
13 | 11 |
|
14 |
| -void ProgramHolder::reset() { |
15 |
| - if (!created()) return; |
16 |
| - objectStore->abandonedPrograms.push_back(id); |
17 |
| - id = 0; |
| 12 | +void ShaderDeleter::operator()(GLuint id) const { |
| 13 | + store.get().abandonedShaders.push_back(id); |
18 | 14 | }
|
19 | 15 |
|
20 |
| -void ShaderHolder::create(ObjectStore& objectStore_) { |
21 |
| - if (created()) return; |
22 |
| - objectStore = &objectStore_; |
23 |
| - id = MBGL_CHECK_ERROR(glCreateShader(type)); |
| 16 | +void BufferDeleter::operator()(GLuint id) const { |
| 17 | + store.get().abandonedBuffers.push_back(id); |
24 | 18 | }
|
25 | 19 |
|
26 |
| -void ShaderHolder::reset() { |
27 |
| - if (!created()) return; |
28 |
| - objectStore->abandonedShaders.push_back(id); |
29 |
| - id = 0; |
| 20 | +void TextureDeleter::operator()(GLuint id) const { |
| 21 | + store.get().abandonedTextures.push_back(id); |
30 | 22 | }
|
31 | 23 |
|
32 |
| -void BufferHolder::create(ObjectStore& objectStore_) { |
33 |
| - if (created()) return; |
34 |
| - objectStore = &objectStore_; |
35 |
| - MBGL_CHECK_ERROR(glGenBuffers(1, &id)); |
| 24 | +void VAODeleter::operator()(GLuint id) const { |
| 25 | + store.get().abandonedVAOs.push_back(id); |
36 | 26 | }
|
37 | 27 |
|
38 |
| -void BufferHolder::reset() { |
39 |
| - if (!created()) return; |
40 |
| - objectStore->abandonedBuffers.push_back(id); |
41 |
| - id = 0; |
42 |
| -} |
43 |
| - |
44 |
| -void TextureHolder::create(ObjectStore& objectStore_) { |
45 |
| - if (created()) return; |
46 |
| - objectStore = &objectStore_; |
47 |
| - MBGL_CHECK_ERROR(glGenTextures(1, &id)); |
48 |
| -} |
49 |
| - |
50 |
| -void TextureHolder::reset() { |
51 |
| - if (!created()) return; |
52 |
| - objectStore->abandonedTextures.push_back(id); |
53 |
| - id = 0; |
54 |
| -} |
55 |
| - |
56 |
| -void TexturePoolHolder::create(ObjectStore& objectStore_) { |
57 |
| - if (created()) return; |
58 |
| - objectStore = &objectStore_; |
59 |
| - MBGL_CHECK_ERROR(glGenTextures(TextureMax, ids.data())); |
60 |
| -} |
61 |
| - |
62 |
| -void TexturePoolHolder::reset() { |
63 |
| - if (!created()) return; |
| 28 | +void TexturePoolDeleter::operator()(ObjectPool ids) const { |
64 | 29 | for (GLuint& id : ids) {
|
65 |
| - if (id == 0) continue; |
66 |
| - objectStore->abandonedTextures.push_back(id); |
67 |
| - id = 0; |
68 |
| - }; |
69 |
| -} |
70 |
| - |
71 |
| -void VAOHolder::create(ObjectStore& objectStore_) { |
72 |
| - if (created()) return; |
73 |
| - objectStore = &objectStore_; |
74 |
| - MBGL_CHECK_ERROR(gl::GenVertexArrays(1, &id)); |
75 |
| -} |
76 |
| - |
77 |
| -void VAOHolder::reset() { |
78 |
| - if (!created()) return; |
79 |
| - objectStore->abandonedVAOs.push_back(id); |
80 |
| - id = 0; |
| 30 | + if (id) { |
| 31 | + store.get().abandonedTextures.push_back(id); |
| 32 | + id = 0; |
| 33 | + }; |
| 34 | + } |
81 | 35 | }
|
82 | 36 |
|
83 | 37 | ObjectStore::~ObjectStore() {
|
|
0 commit comments