1 #ifndef __DALI_INTERNAL_GL_PROXY_IMPLEMENTATION_H__
2 #define __DALI_INTERNAL_GL_PROXY_IMPLEMENTATION_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 <gl/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
87 const char* mDescription;
89 float mAccumulatedSquare;
92 unsigned int mNumSamples;
93 unsigned int mCurrentFrameCount;
97 * Helper class to calculate number of OpenGL objects
102 ObjectCounter( const char* description );
105 * Increment the counter
110 * Decrement the counter
115 * @return The current number of objects
117 unsigned int GetCount() const;
120 * @return The maximum number of objects created
122 unsigned int GetPeak() const;
125 * @return the description of the sampler
127 const char* GetDescription() const;
130 const char* mDescription;
136 * GlProxyImplementation is a wrapper for the concrete implementation
137 * of GlAbstraction that also gathers statistical information.
139 class GlProxyImplementation : public GlImplementation
145 * @param environmentOptions to check how often to log results
147 GlProxyImplementation(EnvironmentOptions& environmentOptions);
152 virtual ~GlProxyImplementation();
155 * @copydoc GlAbstraction::PreRender();
157 virtual void PreRender();
160 * @copydoc GlAbstraction::PostRender();
162 virtual void PostRender();
164 /* OpenGL ES 2.0 API */
165 virtual void Clear( GLbitfield mask );
167 virtual void GenBuffers (GLsizei n, GLuint* buffers);
168 virtual void DeleteBuffers (GLsizei n, const GLuint* buffers);
169 virtual void BindBuffer( GLenum target, GLuint buffer );
171 virtual void GenTextures (GLsizei n, GLuint* textures);
172 virtual void DeleteTextures (GLsizei n, const GLuint* textures);
173 virtual void ActiveTexture(GLenum texture);
174 virtual void BindTexture( GLenum target, GLuint texture );
176 virtual void DrawArrays( GLenum mode, GLint first, GLsizei count );
177 virtual void DrawElements( GLenum mode, GLsizei count, GLenum type, const void* indices );
179 virtual void Uniform1f ( GLint location, GLfloat x );
180 virtual void Uniform1fv( GLint location, GLsizei count, const GLfloat* v );
181 virtual void Uniform1i ( GLint location, GLint x );
182 virtual void Uniform1iv( GLint location, GLsizei count, const GLint* v );
183 virtual void Uniform2f ( GLint location, GLfloat x, GLfloat y );
184 virtual void Uniform2fv( GLint location, GLsizei count, const GLfloat* v );
185 virtual void Uniform2i ( GLint location, GLint x, GLint y );
186 virtual void Uniform2iv( GLint location, GLsizei count, const GLint* v );
187 virtual void Uniform3f ( GLint location, GLfloat x, GLfloat y, GLfloat z );
188 virtual void Uniform3fv( GLint location, GLsizei count, const GLfloat* v );
189 virtual void Uniform3i ( GLint location, GLint x, GLint y, GLint z );
190 virtual void Uniform3iv( GLint location, GLsizei count, const GLint* v );
191 virtual void Uniform4f ( GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
192 virtual void Uniform4fv( GLint location, GLsizei count, const GLfloat* v );
193 virtual void Uniform4i ( GLint location, GLint x, GLint y, GLint z, GLint w );
194 virtual void Uniform4iv( GLint location, GLsizei count, const GLint* v );
195 virtual void UniformMatrix2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
196 virtual void UniformMatrix3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
197 virtual void UniformMatrix4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
199 virtual GLuint CreateProgram (void);
200 virtual void DeleteProgram (GLuint program);
201 virtual void UseProgram( GLuint program );
205 void AccumulateSamples();
207 void LogCalls( const Sampler& sampler );
208 void LogObjectCounter( const ObjectCounter& sampler );
209 void ResetSamplers();
213 EnvironmentOptions& mEnvironmentOptions;
214 Sampler mActiveTextureSampler;
215 Sampler mClearSampler;
216 Sampler mBindBufferSampler;
217 Sampler mBindTextureSampler;
218 Sampler mDrawSampler;
219 Sampler mUniformSampler;
220 Sampler mUseProgramSampler;
221 ObjectCounter mBufferCount;
222 ObjectCounter mTextureCount;
223 ObjectCounter mProgramCount;
229 } // namespace Adaptor
231 } // namespace Internal
235 #endif // __DALI_INTERNAL_GL_PROXY_IMPLEMENTATION_H__