3 ** Copyright 2006, The Android Open Source Project
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
9 ** http://www.apache.org/licenses/LICENSE-2.0
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
18 #ifndef ANDROID_OPENGLES_BUFFER_OBJECT_MANAGER_H
19 #define ANDROID_OPENGLES_BUFFER_OBJECT_MANAGER_H
23 #include <sys/types.h>
25 #include <utils/Atomic.h>
26 #include <utils/RefBase.h>
27 #include <utils/KeyedVector.h>
28 #include <utils/Errors.h>
32 #include "Tokenizer.h"
33 #include "TokenManager.h"
38 // ----------------------------------------------------------------------------
51 class EGLBufferObjectManager : public TokenManager
54 EGLBufferObjectManager();
55 ~EGLBufferObjectManager();
58 inline void incStrong(const void* id) const;
59 inline void decStrong(const void* id) const;
60 typedef void weakref_type;
62 gl::buffer_t const* bind(GLuint buffer);
63 int allocateStore(gl::buffer_t* bo, GLsizeiptr size, GLenum usage);
64 void deleteBuffers(GLsizei n, const GLuint* buffers);
67 mutable volatile int32_t mCount;
69 KeyedVector<GLuint, gl::buffer_t*> mBuffers;
72 void EGLBufferObjectManager::incStrong(const void* /*id*/) const {
73 android_atomic_inc(&mCount);
75 void EGLBufferObjectManager::decStrong(const void* /*id*/) const {
76 if (android_atomic_dec(&mCount) == 1) {
81 // ----------------------------------------------------------------------------
82 }; // namespace android
84 #endif // ANDROID_OPENGLES_BUFFER_OBJECT_MANAGER_H