1 #ifndef DALI_INTERNAL_GL_PROXY_IMPLEMENTATION_H
2 #define DALI_INTERNAL_GL_PROXY_IMPLEMENTATION_H
5 * Copyright (c) 2019 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 void PreRender() override;
166 * @copydoc GlAbstraction::PostRender();
168 void PostRender() override;
170 /* OpenGL ES 2.0 API */
171 void Clear( GLbitfield mask ) override;
173 void GenBuffers( GLsizei n, GLuint* buffers ) override;
174 void DeleteBuffers( GLsizei n, const GLuint* buffers ) override;
175 void BindBuffer( GLenum target, GLuint buffer ) override;
177 void GenTextures( GLsizei n, GLuint* textures ) override;
178 void DeleteTextures( GLsizei n, const GLuint* textures ) override;
179 void ActiveTexture( GLenum texture ) override;
180 void BindTexture( GLenum target, GLuint texture ) override;
182 void DrawArrays( GLenum mode, GLint first, GLsizei count ) override;
183 void DrawElements( GLenum mode, GLsizei count, GLenum type, const void* indices ) override;
185 void Uniform1f ( GLint location, GLfloat x ) override;
186 void Uniform1fv( GLint location, GLsizei count, const GLfloat* v ) override;
187 void Uniform1i ( GLint location, GLint x ) override;
188 void Uniform1iv( GLint location, GLsizei count, const GLint* v ) override;
189 void Uniform2f ( GLint location, GLfloat x, GLfloat y ) override;
190 void Uniform2fv( GLint location, GLsizei count, const GLfloat* v ) override;
191 void Uniform2i ( GLint location, GLint x, GLint y ) override;
192 void Uniform2iv( GLint location, GLsizei count, const GLint* v ) override;
193 void Uniform3f ( GLint location, GLfloat x, GLfloat y, GLfloat z ) override;
194 void Uniform3fv( GLint location, GLsizei count, const GLfloat* v ) override;
195 void Uniform3i ( GLint location, GLint x, GLint y, GLint z ) override;
196 void Uniform3iv( GLint location, GLsizei count, const GLint* v ) override;
197 void Uniform4f ( GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) override;
198 void Uniform4fv( GLint location, GLsizei count, const GLfloat* v ) override;
199 void Uniform4i ( GLint location, GLint x, GLint y, GLint z, GLint w ) override;
200 void Uniform4iv( GLint location, GLsizei count, const GLint* v ) override;
201 void UniformMatrix2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override;
202 void UniformMatrix3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override;
203 void UniformMatrix4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override;
205 GLuint CreateProgram( void ) override;
206 void DeleteProgram( GLuint program ) override;
207 void UseProgram( GLuint program ) override;
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