Changed 'virtual' function override declarations to 'override'.
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles / gl-implementation.h
1 #ifndef DALI_INTERNAL_GL_IMPLEMENTATION_H
2 #define DALI_INTERNAL_GL_IMPLEMENTATION_H
3
4 /*
5  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <memory>
23 #include <cstdlib>
24 #include <GLES2/gl2.h>
25 #include <dali/integration-api/gl-abstraction.h>
26 #include <dali/devel-api/threading/conditional-wait.h>
27
28 // INTERNAL INCLUDES
29 #include <dali/internal/graphics/gles/gles-abstraction.h>
30 #include <dali/internal/graphics/gles/gles2-implementation.h>
31 #include <dali/internal/graphics/gles/gles3-implementation.h>
32
33 namespace Dali
34 {
35
36 namespace Internal
37 {
38
39 namespace Adaptor
40 {
41
42 /**
43  * GlImplementation is a concrete implementation for GlAbstraction.
44  * The class provides an OpenGL-ES 2.0 or 3.0 implementation.
45  * The class is provided when creating the Integration::Core object.
46  */
47 class GlImplementation : public Dali::Integration::GlAbstraction
48 {
49
50 public:
51   GlImplementation()
52     : mGlesVersion( 30 ),
53       mIsSurfacelessContextSupported( false ),
54       mIsContextCreated( false ),
55       mContextCreatedWaitCondition(),
56       mMaxTextureSize( 0 )
57   {
58     mImpl.reset( new Gles3Implementation() );
59   }
60
61   virtual ~GlImplementation() {}
62
63   void PreRender() override
64   {
65     /* Do nothing in main implementation */
66   }
67
68   void PostRender() override
69   {
70     /* Do nothing in main implementation */
71   }
72
73   void ContextCreated()
74   {
75     glGetIntegerv( GL_MAX_TEXTURE_SIZE, &mMaxTextureSize );
76
77     if( !mIsContextCreated )
78     {
79       mContextCreatedWaitCondition.Notify();
80     }
81     mIsContextCreated = true;
82   }
83
84   void SetGlesVersion( const int32_t glesVersion )
85   {
86     if( mGlesVersion != glesVersion )
87     {
88       mGlesVersion = glesVersion;
89       if( mGlesVersion >= 30 )
90       {
91         mImpl.reset( new Gles3Implementation() );
92       }
93       else
94       {
95         mImpl.reset( new Gles2Implementation() );
96       }
97     }
98   }
99
100   void SetIsSurfacelessContextSupported( const bool isSupported )
101   {
102     mIsSurfacelessContextSupported = isSupported;
103   }
104
105   bool IsSurfacelessContextSupported() const override
106   {
107     return mIsSurfacelessContextSupported;
108   }
109
110   bool TextureRequiresConverting( const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage ) const override
111   {
112     bool convert = ( ( imageGlFormat == GL_RGB ) && ( textureGlFormat == GL_RGBA ) );
113     if( mGlesVersion >= 30 )
114     {
115       // Don't convert manually from RGB to RGBA if GLES >= 3.0 and a sub-image is uploaded.
116       convert = ( convert && !isSubImage );
117     }
118     return convert;
119   }
120
121   int GetMaxTextureSize()
122   {
123     if( !mIsContextCreated )
124     {
125       mContextCreatedWaitCondition.Wait();
126     }
127     return mMaxTextureSize;
128   }
129
130   /* OpenGL ES 2.0 */
131
132   void ActiveTexture( GLenum texture ) override
133   {
134     glActiveTexture( texture );
135   }
136
137   void AttachShader( GLuint program, GLuint shader ) override
138   {
139     glAttachShader( program, shader );
140   }
141
142   void BindAttribLocation( GLuint program, GLuint index, const char* name ) override
143   {
144     glBindAttribLocation( program, index, name );
145   }
146
147   void BindBuffer( GLenum target, GLuint buffer ) override
148   {
149     glBindBuffer( target, buffer );
150   }
151
152   void BindFramebuffer( GLenum target, GLuint framebuffer ) override
153   {
154     glBindFramebuffer( target, framebuffer );
155   }
156
157   void BindRenderbuffer( GLenum target, GLuint renderbuffer ) override
158   {
159     glBindRenderbuffer( target, renderbuffer );
160   }
161
162   void BindTexture( GLenum target, GLuint texture ) override
163   {
164     glBindTexture( target, texture );
165   }
166
167   void BlendColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) override
168   {
169     glBlendColor( red, green, blue, alpha );
170   }
171
172   void BlendEquation( GLenum mode ) override
173   {
174     glBlendEquation( mode );
175   }
176
177   void BlendEquationSeparate( GLenum modeRGB, GLenum modeAlpha ) override
178   {
179     glBlendEquationSeparate( modeRGB, modeAlpha );
180   }
181
182   void BlendFunc( GLenum sfactor, GLenum dfactor ) override
183   {
184     glBlendFunc( sfactor, dfactor );
185   }
186
187   void BlendFuncSeparate( GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha ) override
188   {
189     glBlendFuncSeparate( srcRGB, dstRGB, srcAlpha, dstAlpha );
190   }
191
192   void BufferData( GLenum target, GLsizeiptr size, const void* data, GLenum usage ) override
193   {
194     glBufferData( target, size, data, usage );
195   }
196
197   void BufferSubData( GLenum target, GLintptr offset, GLsizeiptr size, const void* data ) override
198   {
199     glBufferSubData( target, offset, size, data );
200   }
201
202   GLenum CheckFramebufferStatus( GLenum target ) override
203   {
204     return glCheckFramebufferStatus( target );
205   }
206
207   void Clear( GLbitfield mask ) override
208   {
209     glClear( mask );
210   }
211
212   void ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) override
213   {
214     glClearColor( red, green, blue, alpha );
215   }
216
217   void ClearDepthf( GLclampf depth ) override
218   {
219     glClearDepthf( depth );
220   }
221
222   void ClearStencil( GLint s ) override
223   {
224     glClearStencil( s );
225   }
226
227   void ColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ) override
228   {
229     glColorMask( red, green, blue, alpha );
230   }
231
232   void CompileShader( GLuint shader ) override
233   {
234     glCompileShader( shader );
235   }
236
237   void CompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data ) override
238   {
239     glCompressedTexImage2D( target, level, internalformat, width, height, border, imageSize, data );
240   }
241
242   void CompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data ) override
243   {
244     glCompressedTexSubImage2D( target, level, xoffset, yoffset, width, height, format, imageSize, data );
245   }
246
247   void CopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border ) override
248   {
249     glCopyTexImage2D( target, level, internalformat, x, y, width, height, border );
250   }
251
252   void CopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height ) override
253   {
254     glCopyTexSubImage2D( target, level, xoffset, yoffset, x, y, width, height );
255   }
256
257   GLuint CreateProgram( void ) override
258   {
259     return glCreateProgram();
260   }
261
262   GLuint CreateShader( GLenum type ) override
263   {
264     return glCreateShader( type );
265   }
266
267   void CullFace( GLenum mode ) override
268   {
269     glCullFace( mode );
270   }
271
272   void DeleteBuffers( GLsizei n, const GLuint* buffers ) override
273   {
274     glDeleteBuffers( n, buffers );
275   }
276
277   void DeleteFramebuffers( GLsizei n, const GLuint* framebuffers ) override
278   {
279     glDeleteFramebuffers( n, framebuffers );
280   }
281
282   void DeleteProgram( GLuint program ) override
283   {
284     glDeleteProgram( program );
285   }
286
287   void DeleteRenderbuffers( GLsizei n, const GLuint* renderbuffers ) override
288   {
289     glDeleteRenderbuffers( n, renderbuffers );
290   }
291
292   void DeleteShader( GLuint shader ) override
293   {
294     glDeleteShader( shader );
295   }
296
297   void DeleteTextures( GLsizei n, const GLuint* textures ) override
298   {
299     glDeleteTextures( n, textures );
300   }
301
302   void DepthFunc( GLenum func ) override
303   {
304     glDepthFunc( func );
305   }
306
307   void DepthMask( GLboolean flag ) override
308   {
309     glDepthMask( flag );
310   }
311
312   void DepthRangef( GLclampf zNear, GLclampf zFar ) override
313   {
314     glDepthRangef( zNear, zFar );
315   }
316
317   void DetachShader( GLuint program, GLuint shader ) override
318   {
319     glDetachShader( program, shader );
320   }
321
322   void Disable( GLenum cap ) override
323   {
324     glDisable( cap );
325   }
326
327   void DisableVertexAttribArray( GLuint index ) override
328   {
329     glDisableVertexAttribArray( index );
330   }
331
332   void DrawArrays( GLenum mode, GLint first, GLsizei count ) override
333   {
334     glDrawArrays( mode, first, count );
335   }
336
337   void DrawElements( GLenum mode, GLsizei count, GLenum type, const void* indices ) override
338   {
339     glDrawElements( mode, count, type, indices );
340   }
341
342   void Enable( GLenum cap ) override
343   {
344     glEnable( cap );
345   }
346
347   void EnableVertexAttribArray( GLuint index ) override
348   {
349     glEnableVertexAttribArray( index );
350   }
351
352   void Finish( void ) override
353   {
354     glFinish();
355   }
356
357   void Flush( void ) override
358   {
359     glFlush();
360   }
361
362   void FramebufferRenderbuffer( GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer ) override
363   {
364     glFramebufferRenderbuffer( target, attachment, renderbuffertarget, renderbuffer );
365   }
366
367   void FramebufferTexture2D( GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level ) override
368   {
369     glFramebufferTexture2D( target, attachment, textarget, texture, level );
370   }
371
372   void FrontFace( GLenum mode ) override
373   {
374     glFrontFace( mode );
375   }
376
377   void GenBuffers( GLsizei n, GLuint* buffers ) override
378   {
379     glGenBuffers( n, buffers );
380   }
381
382   void GenerateMipmap( GLenum target ) override
383   {
384     glGenerateMipmap( target );
385   }
386
387   void GenFramebuffers( GLsizei n, GLuint* framebuffers ) override
388   {
389     glGenFramebuffers( n, framebuffers );
390   }
391
392   void GenRenderbuffers( GLsizei n, GLuint* renderbuffers ) override
393   {
394     glGenRenderbuffers( n, renderbuffers );
395   }
396
397   void GenTextures( GLsizei n, GLuint* textures ) override
398   {
399     glGenTextures( n, textures );
400   }
401
402   void GetActiveAttrib( GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name ) override
403   {
404     glGetActiveAttrib( program, index, bufsize, length, size, type, name );
405   }
406
407   void GetActiveUniform( GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name ) override
408   {
409     glGetActiveUniform( program, index, bufsize, length, size, type, name );
410   }
411
412   void GetAttachedShaders( GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders ) override
413   {
414     glGetAttachedShaders( program, maxcount, count, shaders );
415   }
416
417   int  GetAttribLocation( GLuint program, const char* name ) override
418   {
419     return glGetAttribLocation( program, name );
420   }
421
422   void GetBooleanv( GLenum pname, GLboolean* params ) override
423   {
424     glGetBooleanv( pname, params );
425   }
426
427   void GetBufferParameteriv( GLenum target, GLenum pname, GLint* params ) override
428   {
429     glGetBufferParameteriv( target, pname, params );
430   }
431
432   GLenum GetError( void ) override
433   {
434     return glGetError();
435   }
436
437   void GetFloatv( GLenum pname, GLfloat* params ) override
438   {
439     glGetFloatv( pname, params );
440   }
441
442   void GetFramebufferAttachmentParameteriv( GLenum target, GLenum attachment, GLenum pname, GLint* params ) override
443   {
444     glGetFramebufferAttachmentParameteriv( target, attachment, pname, params );
445   }
446
447   void GetIntegerv( GLenum pname, GLint* params ) override
448   {
449     glGetIntegerv( pname, params );
450   }
451
452   void GetProgramiv( GLuint program, GLenum pname, GLint* params ) override
453   {
454     glGetProgramiv( program, pname, params );
455   }
456
457   void GetProgramInfoLog( GLuint program, GLsizei bufsize, GLsizei* length, char* infolog ) override
458   {
459     glGetProgramInfoLog( program, bufsize, length, infolog );
460   }
461
462   void GetRenderbufferParameteriv( GLenum target, GLenum pname, GLint* params ) override
463   {
464     glGetRenderbufferParameteriv( target, pname, params );
465   }
466
467   void GetShaderiv( GLuint shader, GLenum pname, GLint* params ) override
468   {
469     glGetShaderiv( shader, pname, params );
470   }
471
472   void GetShaderInfoLog( GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog ) override
473   {
474     glGetShaderInfoLog( shader, bufsize, length, infolog );
475   }
476
477   void GetShaderPrecisionFormat( GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision ) override
478   {
479     glGetShaderPrecisionFormat( shadertype, precisiontype, range, precision );
480   }
481
482   void GetShaderSource( GLuint shader, GLsizei bufsize, GLsizei* length, char* source ) override
483   {
484     glGetShaderSource( shader, bufsize, length, source );
485   }
486
487   const GLubyte* GetString( GLenum name ) override
488   {
489     return glGetString( name );
490   }
491
492   void GetTexParameterfv( GLenum target, GLenum pname, GLfloat* params ) override
493   {
494     glGetTexParameterfv( target, pname, params );
495   }
496
497   void GetTexParameteriv( GLenum target, GLenum pname, GLint* params ) override
498   {
499     glGetTexParameteriv( target, pname, params );
500   }
501
502   void GetUniformfv( GLuint program, GLint location, GLfloat* params ) override
503   {
504     glGetUniformfv( program, location, params );
505   }
506
507   void GetUniformiv( GLuint program, GLint location, GLint* params ) override
508   {
509     glGetUniformiv( program, location, params );
510   }
511
512   int  GetUniformLocation( GLuint program, const char* name ) override
513   {
514     return glGetUniformLocation( program, name );
515   }
516
517   void GetVertexAttribfv( GLuint index, GLenum pname, GLfloat* params ) override
518   {
519     glGetVertexAttribfv( index, pname, params );
520   }
521
522   void GetVertexAttribiv( GLuint index, GLenum pname, GLint* params ) override
523   {
524     glGetVertexAttribiv( index, pname, params );
525   }
526
527   void GetVertexAttribPointerv( GLuint index, GLenum pname, void** pointer ) override
528   {
529     glGetVertexAttribPointerv( index, pname, pointer );
530   }
531
532   void Hint( GLenum target, GLenum mode ) override
533   {
534     glHint( target, mode );
535   }
536
537   GLboolean IsBuffer( GLuint buffer ) override
538   {
539     return glIsBuffer( buffer );
540   }
541
542   GLboolean IsEnabled( GLenum cap ) override
543   {
544     return glIsEnabled( cap );
545   }
546
547   GLboolean IsFramebuffer( GLuint framebuffer ) override
548   {
549     return glIsFramebuffer( framebuffer );
550   }
551
552   GLboolean IsProgram( GLuint program ) override
553   {
554     return glIsProgram( program );
555   }
556
557   GLboolean IsRenderbuffer( GLuint renderbuffer ) override
558   {
559     return glIsRenderbuffer( renderbuffer );
560   }
561
562   GLboolean IsShader( GLuint shader ) override
563   {
564     return glIsShader( shader );
565   }
566
567   GLboolean IsTexture( GLuint texture ) override
568   {
569     return glIsTexture( texture );
570   }
571
572   void LineWidth( GLfloat width ) override
573   {
574     glLineWidth( width );
575   }
576
577   void LinkProgram( GLuint program ) override
578   {
579     glLinkProgram( program );
580   }
581
582   void PixelStorei( GLenum pname, GLint param ) override
583   {
584     glPixelStorei( pname, param );
585   }
586
587   void PolygonOffset( GLfloat factor, GLfloat units ) override
588   {
589     glPolygonOffset( factor, units );
590   }
591
592   void ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels ) override
593   {
594     glReadPixels( x, y, width, height, format, type, pixels );
595   }
596
597   void ReleaseShaderCompiler( void ) override
598   {
599     glReleaseShaderCompiler();
600   }
601
602   void RenderbufferStorage( GLenum target, GLenum internalformat, GLsizei width, GLsizei height ) override
603   {
604     glRenderbufferStorage( target, internalformat, width, height );
605   }
606
607   void SampleCoverage( GLclampf value, GLboolean invert ) override
608   {
609     glSampleCoverage( value, invert );
610   }
611
612   void Scissor( GLint x, GLint y, GLsizei width, GLsizei height ) override
613   {
614     glScissor( x, y, width, height );
615   }
616
617   void ShaderBinary( GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length ) override
618   {
619     glShaderBinary( n, shaders, binaryformat, binary, length );
620   }
621
622   void ShaderSource( GLuint shader, GLsizei count, const char** string, const GLint* length ) override
623   {
624     glShaderSource( shader, count, string, length );
625   }
626
627   void StencilFunc( GLenum func, GLint ref, GLuint mask ) override
628   {
629     glStencilFunc( func, ref, mask );
630   }
631
632   void StencilFuncSeparate( GLenum face, GLenum func, GLint ref, GLuint mask ) override
633   {
634     glStencilFuncSeparate( face, func, ref, mask );
635   }
636
637   void StencilMask( GLuint mask ) override
638   {
639     glStencilMask( mask );
640   }
641
642   void StencilMaskSeparate( GLenum face, GLuint mask ) override
643   {
644     glStencilMaskSeparate( face, mask );
645   }
646
647   void StencilOp( GLenum fail, GLenum zfail, GLenum zpass ) override
648   {
649     glStencilOp( fail, zfail, zpass );
650   }
651
652   void StencilOpSeparate( GLenum face, GLenum fail, GLenum zfail, GLenum zpass ) override
653   {
654     glStencilOpSeparate( face, fail, zfail, zpass );
655   }
656
657   void TexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels ) override
658   {
659     glTexImage2D( target, level, internalformat, width, height, border, format, type, pixels );
660   }
661
662   void TexParameterf( GLenum target, GLenum pname, GLfloat param ) override
663   {
664     glTexParameterf( target, pname, param );
665   }
666
667   void TexParameterfv( GLenum target, GLenum pname, const GLfloat* params ) override
668   {
669     glTexParameterfv( target, pname, params );
670   }
671
672   void TexParameteri( GLenum target, GLenum pname, GLint param ) override
673   {
674     glTexParameteri( target, pname, param );
675   }
676
677   void TexParameteriv( GLenum target, GLenum pname, const GLint* params ) override
678   {
679     glTexParameteriv( target, pname, params );
680   }
681
682   void TexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels ) override
683   {
684     glTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, pixels );
685   }
686
687   void Uniform1f( GLint location, GLfloat x ) override
688   {
689     glUniform1f( location, x );
690   }
691
692   void Uniform1fv( GLint location, GLsizei count, const GLfloat* v ) override
693   {
694     glUniform1fv( location, count, v );
695   }
696
697   void Uniform1i( GLint location, GLint x ) override
698   {
699     glUniform1i( location, x );
700   }
701
702   void Uniform1iv( GLint location, GLsizei count, const GLint* v ) override
703   {
704     glUniform1iv( location, count, v );
705   }
706
707   void Uniform2f( GLint location, GLfloat x, GLfloat y ) override
708   {
709     glUniform2f( location, x, y );
710   }
711
712   void Uniform2fv( GLint location, GLsizei count, const GLfloat* v ) override
713   {
714     glUniform2fv( location, count, v );
715   }
716
717   void Uniform2i( GLint location, GLint x, GLint y ) override
718   {
719     glUniform2i( location, x, y );
720   }
721
722   void Uniform2iv( GLint location, GLsizei count, const GLint* v ) override
723   {
724     glUniform2iv( location, count, v );
725   }
726
727   void Uniform3f( GLint location, GLfloat x, GLfloat y, GLfloat z ) override
728   {
729     glUniform3f( location, x, y, z );
730   }
731
732   void Uniform3fv( GLint location, GLsizei count, const GLfloat* v ) override
733   {
734     glUniform3fv( location, count, v );
735   }
736
737   void Uniform3i( GLint location, GLint x, GLint y, GLint z ) override
738   {
739     glUniform3i( location, x, y, z );
740   }
741
742   void Uniform3iv( GLint location, GLsizei count, const GLint* v ) override
743   {
744     glUniform3iv( location, count, v );
745   }
746
747   void Uniform4f( GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) override
748   {
749     glUniform4f( location, x, y, z, w );
750   }
751
752   void Uniform4fv( GLint location, GLsizei count, const GLfloat* v ) override
753   {
754     glUniform4fv( location, count, v );
755   }
756
757   void Uniform4i( GLint location, GLint x, GLint y, GLint z, GLint w ) override
758   {
759     glUniform4i( location, x, y, z, w );
760   }
761
762   void Uniform4iv( GLint location, GLsizei count, const GLint* v ) override
763   {
764     glUniform4iv( location, count, v );
765   }
766
767   void UniformMatrix2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
768   {
769     glUniformMatrix2fv( location, count, transpose, value );
770   }
771
772   void UniformMatrix3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
773   {
774     glUniformMatrix3fv( location, count, transpose, value );
775   }
776
777   void UniformMatrix4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
778   {
779     glUniformMatrix4fv( location, count, transpose, value );
780   }
781
782   void UseProgram( GLuint program ) override
783   {
784     glUseProgram( program );
785   }
786
787   void ValidateProgram( GLuint program ) override
788   {
789     glValidateProgram( program );
790   }
791
792   void VertexAttrib1f( GLuint indx, GLfloat x ) override
793   {
794     glVertexAttrib1f( indx, x );
795   }
796
797   void VertexAttrib1fv( GLuint indx, const GLfloat* values ) override
798   {
799     glVertexAttrib1fv( indx, values );
800   }
801
802   void VertexAttrib2f( GLuint indx, GLfloat x, GLfloat y ) override
803   {
804     glVertexAttrib2f( indx, x, y );
805   }
806
807   void VertexAttrib2fv( GLuint indx, const GLfloat* values ) override
808   {
809     glVertexAttrib2fv( indx, values );
810   }
811
812   void VertexAttrib3f( GLuint indx, GLfloat x, GLfloat y, GLfloat z ) override
813   {
814     glVertexAttrib3f( indx, x, y, z );
815   }
816
817   void VertexAttrib3fv( GLuint indx, const GLfloat* values ) override
818   {
819     glVertexAttrib3fv( indx, values );
820   }
821
822   void VertexAttrib4f( GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) override
823   {
824     glVertexAttrib4f( indx, x, y, z, w );
825   }
826
827   void VertexAttrib4fv( GLuint indx, const GLfloat* values ) override
828   {
829     glVertexAttrib4fv( indx, values );
830   }
831
832   void VertexAttribPointer( GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr ) override
833   {
834     glVertexAttribPointer( indx, size, type, normalized, stride, ptr );
835   }
836
837   void Viewport( GLint x, GLint y, GLsizei width, GLsizei height ) override
838   {
839     glViewport( x, y, width, height );
840   }
841
842   /* OpenGL ES 3.0 */
843
844   void ReadBuffer( GLenum mode ) override
845   {
846     mImpl->ReadBuffer( mode );
847   }
848
849   void DrawRangeElements( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices ) override
850   {
851     mImpl->DrawRangeElements( mode, start, end, count, type, indices );
852   }
853
854   void TexImage3D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels ) override
855   {
856     mImpl->TexImage3D( target, level, internalformat, width, height, depth, border, format, type, pixels );
857   }
858
859   void TexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels ) override
860   {
861     mImpl->TexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels );
862   }
863
864   void CopyTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ) override
865   {
866     mImpl->CopyTexSubImage3D( target, level, xoffset, yoffset, zoffset, x, y, width, height );
867   }
868
869   void CompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data ) override
870   {
871     mImpl->CompressedTexImage3D( target, level, internalformat, width, height, depth, border, imageSize, data );
872   }
873
874   void CompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data ) override
875   {
876     mImpl->CompressedTexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data );
877   }
878
879   void GenQueries( GLsizei n, GLuint* ids ) override
880   {
881     mImpl->GenQueries( n, ids );
882   }
883
884   void DeleteQueries( GLsizei n, const GLuint* ids ) override
885   {
886     mImpl->DeleteQueries( n, ids );
887   }
888
889   GLboolean IsQuery( GLuint id ) override
890   {
891     return mImpl->IsQuery( id );
892   }
893
894   void BeginQuery( GLenum target, GLuint id ) override
895   {
896     mImpl->BeginQuery( target, id );
897   }
898
899   void EndQuery( GLenum target ) override
900   {
901     mImpl->EndQuery( target );
902   }
903
904   void GetQueryiv( GLenum target, GLenum pname, GLint* params ) override
905   {
906     mImpl->GetQueryiv( target, pname, params );
907   }
908
909   void GetQueryObjectuiv( GLuint id, GLenum pname, GLuint* params ) override
910   {
911     mImpl->GetQueryObjectuiv( id, pname, params );
912   }
913
914   GLboolean UnmapBuffer( GLenum target ) override
915   {
916     return mImpl->UnmapBuffer( target );
917   }
918
919   void GetBufferPointerv( GLenum target, GLenum pname, GLvoid** params ) override
920   {
921     mImpl->GetBufferPointerv( target, pname, params );
922   }
923
924   void DrawBuffers( GLsizei n, const GLenum* bufs ) override
925   {
926     mImpl->DrawBuffers( n, bufs );
927   }
928
929   void UniformMatrix2x3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
930   {
931     mImpl->UniformMatrix2x3fv( location, count, transpose, value );
932   }
933
934   void UniformMatrix3x2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
935   {
936     mImpl->UniformMatrix3x2fv( location, count, transpose, value );
937   }
938
939   void UniformMatrix2x4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
940   {
941     mImpl->UniformMatrix2x4fv( location, count, transpose, value );
942   }
943
944   void UniformMatrix4x2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
945   {
946     mImpl->UniformMatrix4x2fv( location, count, transpose, value );
947   }
948
949   void UniformMatrix3x4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
950   {
951     mImpl->UniformMatrix3x4fv( location, count, transpose, value );
952   }
953
954   void UniformMatrix4x3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
955   {
956     mImpl->UniformMatrix4x3fv( location, count, transpose, value );
957   }
958
959   void BlitFramebuffer( GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter ) override
960   {
961     mImpl->BlitFramebuffer( srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter );
962   }
963
964   void RenderbufferStorageMultisample( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height ) override
965   {
966     mImpl->RenderbufferStorageMultisample( target, samples, internalformat, width, height );
967   }
968
969   void FramebufferTextureLayer( GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer ) override
970   {
971     mImpl->FramebufferTextureLayer( target, attachment, texture, level, layer );
972   }
973
974   GLvoid* MapBufferRange( GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access ) override
975   {
976     return mImpl->MapBufferRange( target, offset, length, access );
977   }
978
979   void FlushMappedBufferRange( GLenum target, GLintptr offset, GLsizeiptr length ) override
980   {
981     mImpl->FlushMappedBufferRange( target, offset, length );
982   }
983
984   void BindVertexArray( GLuint array ) override
985   {
986     mImpl->BindVertexArray( array );
987   }
988
989   void DeleteVertexArrays( GLsizei n, const GLuint* arrays ) override
990   {
991     mImpl->DeleteVertexArrays( n, arrays );
992   }
993
994   void GenVertexArrays( GLsizei n, GLuint* arrays ) override
995   {
996     mImpl->GenVertexArrays( n, arrays );
997   }
998
999   GLboolean IsVertexArray( GLuint array ) override
1000   {
1001     return mImpl->IsVertexArray( array );
1002   }
1003
1004   void GetIntegeri_v( GLenum target, GLuint index, GLint* data ) override
1005   {
1006     mImpl->GetIntegeri_v( target, index, data );
1007   }
1008
1009   void BeginTransformFeedback( GLenum primitiveMode ) override
1010   {
1011     mImpl->BeginTransformFeedback( primitiveMode );
1012   }
1013
1014   void EndTransformFeedback( void ) override
1015   {
1016     mImpl->EndTransformFeedback();
1017   }
1018
1019   void BindBufferRange( GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size ) override
1020   {
1021     mImpl->BindBufferRange( target, index, buffer, offset, size );
1022   }
1023
1024   void BindBufferBase( GLenum target, GLuint index, GLuint buffer ) override
1025   {
1026     mImpl->BindBufferBase( target, index, buffer );
1027   }
1028
1029   void TransformFeedbackVaryings( GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode ) override
1030   {
1031     mImpl->TransformFeedbackVaryings( program, count, varyings, bufferMode );
1032   }
1033
1034   void GetTransformFeedbackVarying( GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name ) override
1035   {
1036     mImpl->GetTransformFeedbackVarying( program, index, bufSize, length, size, type, name );
1037   }
1038
1039   void VertexAttribIPointer( GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer ) override
1040   {
1041     mImpl->VertexAttribIPointer( index, size, type, stride, pointer );
1042   }
1043
1044   void GetVertexAttribIiv( GLuint index, GLenum pname, GLint* params ) override
1045   {
1046     mImpl->GetVertexAttribIiv( index, pname, params );
1047   }
1048
1049   void GetVertexAttribIuiv( GLuint index, GLenum pname, GLuint* params ) override
1050   {
1051     mImpl->GetVertexAttribIuiv( index, pname, params );
1052   }
1053
1054   void VertexAttribI4i( GLuint index, GLint x, GLint y, GLint z, GLint w ) override
1055   {
1056     mImpl->VertexAttribI4i( index, x, y, z, w );
1057   }
1058
1059   void VertexAttribI4ui( GLuint index, GLuint x, GLuint y, GLuint z, GLuint w ) override
1060   {
1061     mImpl->VertexAttribI4ui( index, x, y, z, w );
1062   }
1063
1064   void VertexAttribI4iv( GLuint index, const GLint* v ) override
1065   {
1066     mImpl->VertexAttribI4iv( index, v );
1067   }
1068
1069   void VertexAttribI4uiv( GLuint index, const GLuint* v ) override
1070   {
1071     mImpl->VertexAttribI4uiv( index, v );
1072   }
1073
1074   void GetUniformuiv( GLuint program, GLint location, GLuint* params ) override
1075   {
1076     mImpl->GetUniformuiv( program, location, params );
1077   }
1078
1079   GLint GetFragDataLocation( GLuint program, const GLchar *name ) override
1080   {
1081     return mImpl->GetFragDataLocation( program, name );
1082   }
1083
1084   void Uniform1ui( GLint location, GLuint v0 ) override
1085   {
1086     mImpl->Uniform1ui( location, v0 );
1087   }
1088
1089   void Uniform2ui( GLint location, GLuint v0, GLuint v1 ) override
1090   {
1091     mImpl->Uniform2ui( location, v0, v1 );
1092   }
1093
1094   void Uniform3ui( GLint location, GLuint v0, GLuint v1, GLuint v2 ) override
1095   {
1096     mImpl->Uniform3ui( location, v0, v1, v2 );
1097   }
1098
1099   void Uniform4ui( GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3 ) override
1100   {
1101     mImpl->Uniform4ui( location, v0, v1, v2, v3 );
1102   }
1103
1104   void Uniform1uiv( GLint location, GLsizei count, const GLuint* value ) override
1105   {
1106     mImpl->Uniform1uiv( location, count, value );
1107   }
1108
1109   void Uniform2uiv( GLint location, GLsizei count, const GLuint* value ) override
1110   {
1111     mImpl->Uniform2uiv( location, count, value );
1112   }
1113
1114   void Uniform3uiv( GLint location, GLsizei count, const GLuint* value ) override
1115   {
1116     mImpl->Uniform3uiv( location, count, value );
1117   }
1118
1119   void Uniform4uiv( GLint location, GLsizei count, const GLuint* value ) override
1120   {
1121     mImpl->Uniform4uiv( location, count, value );
1122   }
1123
1124   void ClearBufferiv( GLenum buffer, GLint drawbuffer, const GLint* value ) override
1125   {
1126     mImpl->ClearBufferiv( buffer, drawbuffer, value );
1127   }
1128
1129   void ClearBufferuiv( GLenum buffer, GLint drawbuffer, const GLuint* value ) override
1130   {
1131     mImpl->ClearBufferuiv( buffer, drawbuffer, value );
1132   }
1133
1134   void ClearBufferfv( GLenum buffer, GLint drawbuffer, const GLfloat* value ) override
1135   {
1136     mImpl->ClearBufferfv( buffer, drawbuffer, value );
1137   }
1138
1139   void ClearBufferfi( GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil ) override
1140   {
1141     mImpl->ClearBufferfi( buffer, drawbuffer, depth, stencil );
1142   }
1143
1144   const GLubyte* GetStringi( GLenum name, GLuint index ) override
1145   {
1146     return mImpl->GetStringi( name, index );
1147   }
1148
1149   void CopyBufferSubData( GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size ) override
1150   {
1151     mImpl->CopyBufferSubData( readTarget, writeTarget, readOffset, writeOffset, size );
1152   }
1153
1154   void GetUniformIndices( GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices ) override
1155   {
1156     mImpl->GetUniformIndices( program, uniformCount, uniformNames, uniformIndices );
1157   }
1158
1159   void GetActiveUniformsiv( GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params ) override
1160   {
1161     mImpl->GetActiveUniformsiv( program, uniformCount, uniformIndices, pname, params );
1162   }
1163
1164   GLuint GetUniformBlockIndex( GLuint program, const GLchar* uniformBlockName ) override
1165   {
1166     return mImpl->GetUniformBlockIndex( program, uniformBlockName );
1167   }
1168
1169   void GetActiveUniformBlockiv( GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params ) override
1170   {
1171     mImpl->GetActiveUniformBlockiv( program, uniformBlockIndex, pname, params );
1172   }
1173
1174   void GetActiveUniformBlockName( GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName ) override
1175   {
1176     mImpl->GetActiveUniformBlockName( program, uniformBlockIndex, bufSize, length, uniformBlockName );
1177   }
1178
1179   void UniformBlockBinding( GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding ) override
1180   {
1181     mImpl->UniformBlockBinding( program, uniformBlockIndex, uniformBlockBinding );
1182   }
1183
1184   void DrawArraysInstanced( GLenum mode, GLint first, GLsizei count, GLsizei instanceCount ) override
1185   {
1186     mImpl->DrawArraysInstanced( mode, first, count, instanceCount );
1187   }
1188
1189   void DrawElementsInstanced( GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount ) override
1190   {
1191     mImpl->DrawElementsInstanced( mode, count, type, indices, instanceCount );
1192   }
1193
1194   GLsync FenceSync( GLenum condition, GLbitfield flags ) override
1195   {
1196     return mImpl->FenceSync( condition, flags );
1197   }
1198
1199   GLboolean IsSync( GLsync sync ) override
1200   {
1201     return mImpl->IsSync( sync );
1202   }
1203
1204   void DeleteSync( GLsync sync ) override
1205   {
1206     mImpl->DeleteSync( sync );
1207   }
1208
1209   GLenum ClientWaitSync( GLsync sync, GLbitfield flags, GLuint64 timeout ) override
1210   {
1211     return mImpl->ClientWaitSync( sync, flags, timeout );
1212   }
1213
1214   void WaitSync( GLsync sync, GLbitfield flags, GLuint64 timeout ) override
1215   {
1216     mImpl->WaitSync( sync, flags, timeout );
1217   }
1218
1219   void GetInteger64v( GLenum pname, GLint64* params ) override
1220   {
1221     mImpl->GetInteger64v( pname, params );
1222   }
1223
1224   void GetSynciv( GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values ) override
1225   {
1226     mImpl->GetSynciv( sync, pname, bufSize, length, values );
1227   }
1228
1229   void GetInteger64i_v( GLenum target, GLuint index, GLint64* data ) override
1230   {
1231     mImpl->GetInteger64i_v( target, index, data );
1232   }
1233
1234   void GetBufferParameteri64v( GLenum target, GLenum pname, GLint64* params ) override
1235   {
1236     mImpl->GetBufferParameteri64v( target, pname, params );
1237   }
1238
1239   void GenSamplers( GLsizei count, GLuint* samplers ) override
1240   {
1241     mImpl->GenSamplers( count, samplers );
1242   }
1243
1244   void DeleteSamplers( GLsizei count, const GLuint* samplers ) override
1245   {
1246     mImpl->DeleteSamplers( count, samplers );
1247   }
1248
1249   GLboolean IsSampler( GLuint sampler ) override
1250   {
1251     return mImpl->IsSampler( sampler );
1252   }
1253
1254   void BindSampler( GLuint unit, GLuint sampler ) override
1255   {
1256     mImpl->BindSampler( unit, sampler );
1257   }
1258
1259   void SamplerParameteri( GLuint sampler, GLenum pname, GLint param ) override
1260   {
1261     mImpl->SamplerParameteri( sampler, pname, param );
1262   }
1263
1264   void SamplerParameteriv( GLuint sampler, GLenum pname, const GLint* param ) override
1265   {
1266     mImpl->SamplerParameteriv( sampler, pname, param );
1267   }
1268
1269   void SamplerParameterf( GLuint sampler, GLenum pname, GLfloat param ) override
1270   {
1271     mImpl->SamplerParameterf( sampler, pname, param );
1272   }
1273
1274   void SamplerParameterfv( GLuint sampler, GLenum pname, const GLfloat* param ) override
1275   {
1276     mImpl->SamplerParameterfv( sampler, pname, param );
1277   }
1278
1279   void GetSamplerParameteriv( GLuint sampler, GLenum pname, GLint* params ) override
1280   {
1281     mImpl->GetSamplerParameteriv( sampler, pname, params );
1282   }
1283
1284   void GetSamplerParameterfv( GLuint sampler, GLenum pname, GLfloat* params ) override
1285   {
1286     mImpl->GetSamplerParameterfv( sampler, pname, params );
1287   }
1288
1289   void VertexAttribDivisor( GLuint index, GLuint divisor ) override
1290   {
1291     mImpl->VertexAttribDivisor( index, divisor );
1292   }
1293
1294   void BindTransformFeedback( GLenum target, GLuint id ) override
1295   {
1296     mImpl->BindTransformFeedback( target, id );
1297   }
1298
1299   void DeleteTransformFeedbacks( GLsizei n, const GLuint* ids ) override
1300   {
1301     mImpl->DeleteTransformFeedbacks( n, ids );
1302   }
1303
1304   void GenTransformFeedbacks( GLsizei n, GLuint* ids ) override
1305   {
1306     mImpl->GenTransformFeedbacks( n, ids );
1307   }
1308
1309   GLboolean IsTransformFeedback( GLuint id ) override
1310   {
1311     return mImpl->IsTransformFeedback( id );
1312   }
1313
1314   void PauseTransformFeedback( void ) override
1315   {
1316     mImpl->PauseTransformFeedback();
1317   }
1318
1319   void ResumeTransformFeedback( void ) override
1320   {
1321     mImpl->ResumeTransformFeedback();
1322   }
1323
1324   void GetProgramBinary( GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary ) override
1325   {
1326     mImpl->GetProgramBinary( program, bufSize, length, binaryFormat, binary );
1327   }
1328
1329   void ProgramBinary( GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length ) override
1330   {
1331     mImpl->ProgramBinary( program, binaryFormat, binary, length );
1332   }
1333
1334   void ProgramParameteri( GLuint program, GLenum pname, GLint value ) override
1335   {
1336     mImpl->ProgramParameteri( program, pname, value );
1337   }
1338
1339   void InvalidateFramebuffer( GLenum target, GLsizei numAttachments, const GLenum* attachments ) override
1340   {
1341     mImpl->InvalidateFramebuffer( target, numAttachments, attachments );
1342   }
1343
1344   void InvalidateSubFramebuffer( GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height ) override
1345   {
1346     mImpl->InvalidateSubFramebuffer( target, numAttachments, attachments, x, y, width, height );
1347   }
1348
1349   void TexStorage2D( GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height ) override
1350   {
1351     mImpl->TexStorage2D( target, levels, internalformat, width, height );
1352   }
1353
1354   void TexStorage3D( GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth ) override
1355   {
1356     mImpl->TexStorage3D( target, levels, internalformat, width, height, depth );
1357   }
1358
1359   void GetInternalformativ( GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params ) override
1360   {
1361     mImpl->GetInternalformativ( target, internalformat, pname, bufSize, params );
1362   }
1363
1364 private:
1365   int32_t mGlesVersion;
1366   bool mIsSurfacelessContextSupported;
1367   bool mIsContextCreated;
1368   ConditionalWait mContextCreatedWaitCondition;
1369   GLint mMaxTextureSize;
1370   std::unique_ptr<GlesAbstraction> mImpl;
1371 };
1372
1373 } // namespace Adaptor
1374
1375 } // namespace Internal
1376
1377 } // namespace Dali
1378
1379 #endif // DALI_INTERNAL_GL_IMPLEMENTATION_H