1 #ifndef __DALI_INTERNAL_GPU_BUFFER_H__
2 #define __DALI_INTERNAL_GPU_BUFFER_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/internal/render/gl-resources/context.h>
31 * Used to create and update a GPU memory buffer.
33 * The buffer can be used for storing vertex data, index arrays (indices)
34 * or pixel data (PBO).
36 * The buffer allows data to be stored in high-performance
37 * graphics memory on the server side and
38 * promotes efficient data transfer.
45 * Enum to encapsulate the GL buffer type. This is to avoid having to store a whole int for type
49 ARRAY_BUFFER, ///< GL_ARRAY_BUFFER
50 ELEMENT_ARRAY_BUFFER, ///< GL_ELEMENT_ARRAY_BUFFER
51 TRANSFORM_FEEDBACK_BUFFER ///< GL_TRANSFORM_FEEDBACK_BUFFER
55 * Enum to encapsulate the GL draw mode. This is to avoid having to store a whole int for mode
59 STREAM_DRAW, ///< GL_STREAM_DRAW
60 STATIC_DRAW, ///< GL_STATIC_DRAW
61 DYNAMIC_DRAW, ///< GL_DYNAMIC_DRAW
68 * @param context drawing context
70 GpuBuffer( Context& context );
73 * Destructor, non virtual as no virtual methods or inheritance
79 * Creates or updates a buffer object and binds it to the target.
80 * @param context The context to bind the the buffer
81 * @param size Specifies the size in bytes of the buffer object's new data store.
82 * @param data pointer to the data to load
83 * @param usage How the buffer will be used
84 * @param target The target buffer to update
86 void UpdateDataBuffer(Context& context, GLsizeiptr size, const GLvoid *data, Usage usage, Target target);
89 * Bind the buffer object to the target
90 * Will assert if the buffer size is zero
91 * @param context The context to bind the the buffer
92 * @param target The target buffer to bind
94 void Bind(Context& context, Target target) const;
97 * @return true if the GPU buffer is valid, i.e. its created and not empty
99 bool BufferIsValid() const;
102 * Get the size of the buffer
105 GLsizeiptr GetBufferSize() const
111 * Needs to be called when GL context is destroyed
113 void GlContextDestroyed();
118 * Perfoms a bind without checking the size of the buffer
119 * @param bufferId to bind
121 void BindNoChecks(GLuint bufferId) const;
125 Context& mContext; ///< shared context for dali drawing
126 GLsizeiptr mCapacity; ///< buffer capacity
127 GLsizeiptr mSize; ///< buffer size
128 GLuint mBufferId; ///< buffer object name(id)
130 bool mBufferCreated:1; ///< whether buffer has been created
134 } // namespace Internal
138 #endif // __DALI_INTERNAL_GPU_BUFFER_H__