1 #ifndef __DALI_INTERNAL_GL_PROXY_IMPLEMENTATION_H__
2 #define __DALI_INTERNAL_GL_PROXY_IMPLEMENTATION_H__
5 * Copyright (c) 2016 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/graphics/gles/gl-implementation.h>
30 class EnvironmentOptions;
33 * Helper class to calculate the statistics for Open GLES calls
41 * @param description to write to the log
43 Sampler( const char* description );
46 * Increment the counter for this frame
56 * Accumulate the count onto statistics
61 * @return the description of the sampler
63 const char* GetDescription() const;
66 * @return the mean value
68 float GetMeanValue() const;
71 * @return the standard deviation
73 float GetStandardDeviation() const;
76 * @return the minimum value
81 * @return the maximum value
86 * @return the current count
88 uint64_t GetCount() const;
92 const char* mDescription;
94 uint64_t mAccumulatedSquare;
95 uint64_t mAccumulated;
99 unsigned int mCurrentFrameCount;
103 * Helper class to calculate number of OpenGL objects
108 ObjectCounter( const char* description );
111 * Increment the counter
116 * Decrement the counter
121 * @return The current number of objects
123 unsigned int GetCount() const;
126 * @return The maximum number of objects created
128 unsigned int GetPeak() const;
131 * @return the description of the sampler
133 const char* GetDescription() const;
136 const char* mDescription;
142 * GlProxyImplementation is a wrapper for the concrete implementation
143 * of GlAbstraction that also gathers statistical information.
145 class GlProxyImplementation : public GlImplementation
151 * @param environmentOptions to check how often to log results
153 GlProxyImplementation( EnvironmentOptions& environmentOptions );
158 virtual ~GlProxyImplementation();
161 * @copydoc GlAbstraction::PreRender();
163 virtual void PreRender();
166 * @copydoc GlAbstraction::PostRender();
168 virtual void PostRender();
170 /* OpenGL ES 2.0 API */
171 virtual void Clear( GLbitfield mask );
173 virtual void GenBuffers( GLsizei n, GLuint* buffers );
174 virtual void DeleteBuffers( GLsizei n, const GLuint* buffers );
175 virtual void BindBuffer( GLenum target, GLuint buffer );
177 virtual void GenTextures( GLsizei n, GLuint* textures );
178 virtual void DeleteTextures( GLsizei n, const GLuint* textures );
179 virtual void ActiveTexture( GLenum texture );
180 virtual void BindTexture( GLenum target, GLuint texture );
182 virtual void DrawArrays( GLenum mode, GLint first, GLsizei count );
183 virtual void DrawElements( GLenum mode, GLsizei count, GLenum type, const void* indices );
185 virtual void Uniform1f ( GLint location, GLfloat x );
186 virtual void Uniform1fv( GLint location, GLsizei count, const GLfloat* v );
187 virtual void Uniform1i ( GLint location, GLint x );
188 virtual void Uniform1iv( GLint location, GLsizei count, const GLint* v );
189 virtual void Uniform2f ( GLint location, GLfloat x, GLfloat y );
190 virtual void Uniform2fv( GLint location, GLsizei count, const GLfloat* v );
191 virtual void Uniform2i ( GLint location, GLint x, GLint y );
192 virtual void Uniform2iv( GLint location, GLsizei count, const GLint* v );
193 virtual void Uniform3f ( GLint location, GLfloat x, GLfloat y, GLfloat z );
194 virtual void Uniform3fv( GLint location, GLsizei count, const GLfloat* v );
195 virtual void Uniform3i ( GLint location, GLint x, GLint y, GLint z );
196 virtual void Uniform3iv( GLint location, GLsizei count, const GLint* v );
197 virtual void Uniform4f ( GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
198 virtual void Uniform4fv( GLint location, GLsizei count, const GLfloat* v );
199 virtual void Uniform4i ( GLint location, GLint x, GLint y, GLint z, GLint w );
200 virtual void Uniform4iv( GLint location, GLsizei count, const GLint* v );
201 virtual void UniformMatrix2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
202 virtual void UniformMatrix3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
203 virtual void UniformMatrix4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
205 virtual GLuint CreateProgram( void );
206 virtual void DeleteProgram( GLuint program );
207 virtual void UseProgram( GLuint program );
211 void AccumulateSamples();
213 void LogCalls( const Sampler& sampler );
214 void LogObjectCounter( const ObjectCounter& sampler );
215 void ResetSamplers();
219 EnvironmentOptions& mEnvironmentOptions;
220 Sampler mActiveTextureSampler;
221 Sampler mClearSampler;
222 Sampler mBindBufferSampler;
223 Sampler mBindTextureSampler;
224 Sampler mDrawSampler;
225 Sampler mUniformSampler;
226 Sampler mUseProgramSampler;
227 ObjectCounter mBufferCount;
228 ObjectCounter mTextureCount;
229 ObjectCounter mProgramCount;
231 int mCurrentFrameCount;
232 int mTotalFrameCount;
235 } // namespace Adaptor
237 } // namespace Internal
241 #endif // __DALI_INTERNAL_GL_PROXY_IMPLEMENTATION_H__