2ad0eff9cbd67f0a2bf2fbbab3f37afa60afbdb7
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles / egl-implementation.cpp
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18
19 // CLASS HEADER
20 #include <dali/internal/graphics/gles/egl-implementation.h>
21
22 // EXTERNAL INCLUDES
23 #include <sstream>
24 #include <dali/integration-api/debug.h>
25 #include <dali/public-api/common/dali-vector.h>
26
27 // INTERNAL INCLUDES
28 #include <dali/public-api/dali-adaptor-common.h>
29 #include <dali/internal/graphics/gles/gl-implementation.h>
30 #include <dali/internal/graphics/gles/egl-debug.h>
31
32 // EGL constants use C style casts
33 #pragma GCC diagnostic push
34 #pragma GCC diagnostic ignored "-Wold-style-cast"
35
36 namespace
37 {
38   const uint32_t CHECK_EXTENSION_NUMBER = 3;
39   const std::string EGL_KHR_SURFACELESS_CONTEXT = "EGL_KHR_surfaceless_context";
40   const std::string EGL_KHR_CREATE_CONTEXT = "EGL_KHR_create_context";
41   const std::string EGL_KHR_PARTIAL_UPDATE = "EGL_KHR_partial_update";
42 }
43
44 namespace Dali
45 {
46
47 namespace Internal
48 {
49
50 namespace Adaptor
51 {
52
53 #define TEST_EGL_ERROR(lastCommand) \
54 { \
55   EGLint err = eglGetError(); \
56   if (err != EGL_SUCCESS) \
57   { \
58     DALI_LOG_ERROR("EGL error after %s\n", lastCommand); \
59     Egl::PrintError(err); \
60     DALI_ASSERT_ALWAYS(0 && "EGL error"); \
61   } \
62 }
63
64 EglImplementation::EglImplementation( int multiSamplingLevel,
65                                       Integration::DepthBufferAvailable depthBufferRequired,
66                                       Integration::StencilBufferAvailable stencilBufferRequired,
67                                       Integration::PartialUpdateAvailable partialUpdateAvailable )
68 : mContextAttribs(),
69   mEglNativeDisplay( 0 ),
70   mEglNativeWindow( 0 ),
71   mCurrentEglNativePixmap( 0 ),
72   mEglDisplay( 0 ),
73   mEglConfig( 0 ),
74   mEglContext( 0 ),
75   mCurrentEglSurface( 0 ),
76   mCurrentEglContext( EGL_NO_CONTEXT ),
77   mMultiSamplingLevel( multiSamplingLevel ),
78   mGlesVersion( 30 ),
79   mDamagedRectArray( 0 ),
80   mColorDepth( COLOR_DEPTH_24 ),
81   mGlesInitialized( false ),
82   mIsOwnSurface( true ),
83   mIsWindow( true ),
84   mDepthBufferRequired( depthBufferRequired == Integration::DepthBufferAvailable::TRUE ),
85   mStencilBufferRequired( stencilBufferRequired == Integration::StencilBufferAvailable::TRUE ),
86   mIsSurfacelessContextSupported( false ),
87   mIsKhrCreateContextSupported( false ),
88   mIsFirstFrameAfterResume( false ),
89   mIsKhrPartialUpdateSupported( false ),
90   mPartialUpdateAvailable( partialUpdateAvailable == Integration::PartialUpdateAvailable::TRUE ),
91   mEglSetDamageRegionKHR( nullptr ),
92   mSwapBuffersWithDamage( nullptr )
93 {
94   if( mPartialUpdateAvailable )
95   {
96     mEglSetDamageRegionKHR =  reinterpret_cast< PFNEGLSETDAMAGEREGIONKHRPROC >( eglGetProcAddress( "eglSetDamageRegionKHR" ) );
97     mSwapBuffersWithDamage = reinterpret_cast< PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC >( eglGetProcAddress( "eglSwapBuffersWithDamageEXT" ) );
98     if( !mEglSetDamageRegionKHR || !mSwapBuffersWithDamage )
99     {
100       mPartialUpdateAvailable = false;
101       DALI_LOG_ERROR("Initialization of partial update failed.\n");
102     }
103     else
104     {
105       DALI_LOG_RELEASE_INFO("Initialization of partial update success!\n");
106     }
107   }
108 }
109
110 EglImplementation::~EglImplementation()
111 {
112   TerminateGles();
113 }
114
115 bool EglImplementation::InitializeGles( EGLNativeDisplayType display, bool isOwnSurface )
116 {
117   if ( !mGlesInitialized )
118   {
119     mEglNativeDisplay = display;
120
121     //@todo see if we can just EGL_DEFAULT_DISPLAY instead
122     mEglDisplay = eglGetDisplay(mEglNativeDisplay);
123     EGLint error = eglGetError();
124
125     if( mEglDisplay == NULL && error != EGL_SUCCESS )
126     {
127       throw Dali::DaliException( "", "OpenGL ES is not supported");
128     }
129
130     EGLint majorVersion = 0;
131     EGLint minorVersion = 0;
132     if ( !eglInitialize( mEglDisplay, &majorVersion, &minorVersion ) )
133     {
134       return false;
135     }
136     eglBindAPI(EGL_OPENGL_ES_API);
137
138     mGlesInitialized = true;
139     mIsOwnSurface = isOwnSurface;
140   }
141
142   // Query EGL extensions to check whether surfaceless context is supported
143   const char* const extensionStr = eglQueryString( mEglDisplay, EGL_EXTENSIONS );
144   std::istringstream stream( extensionStr );
145   std::string currentExtension;
146   uint32_t extensionCheckCount = 0;
147   while( std::getline( stream, currentExtension, ' ' ) && extensionCheckCount < CHECK_EXTENSION_NUMBER )
148   {
149     if( currentExtension == EGL_KHR_SURFACELESS_CONTEXT )
150     {
151       mIsSurfacelessContextSupported = true;
152       extensionCheckCount++;
153     }
154     if( currentExtension == EGL_KHR_CREATE_CONTEXT )
155     {
156       mIsKhrCreateContextSupported = true;
157       extensionCheckCount++;
158     }
159     if( currentExtension == EGL_KHR_PARTIAL_UPDATE )
160     {
161       mIsKhrPartialUpdateSupported = true;
162       extensionCheckCount++;
163     }
164   }
165
166   if( !mIsKhrPartialUpdateSupported )
167   {
168     mPartialUpdateAvailable = false;
169   }
170
171   // We want to display this information all the time, so use the LogMessage directly
172   Integration::Log::LogMessage(Integration::Log::DebugInfo, "EGL Information\n"
173       "            Vendor:        %s\n"
174       "            Version:       %s\n"
175       "            Client APIs:   %s\n"
176       "            Extensions:    %s\n",
177       eglQueryString( mEglDisplay, EGL_VENDOR ),
178       eglQueryString( mEglDisplay, EGL_VERSION ),
179       eglQueryString( mEglDisplay, EGL_CLIENT_APIS ),
180       extensionStr);
181
182   return mGlesInitialized;
183 }
184
185 bool EglImplementation::CreateContext()
186 {
187   // make sure a context isn't created twice
188   DALI_ASSERT_ALWAYS( (mEglContext == 0) && "EGL context recreated" );
189
190   mEglContext = eglCreateContext(mEglDisplay, mEglConfig, NULL, &(mContextAttribs[0]));
191   TEST_EGL_ERROR("eglCreateContext render thread");
192
193   DALI_ASSERT_ALWAYS( EGL_NO_CONTEXT != mEglContext && "EGL context not created" );
194
195   DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VENDOR : %s ***\n", glGetString(GL_VENDOR));
196   DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_RENDERER : %s ***\n", glGetString(GL_RENDERER));
197   DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VERSION : %s ***\n", glGetString(GL_VERSION));
198   DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_SHADING_LANGUAGE_VERSION : %s***\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
199   DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** Supported Extensions ***\n%s\n\n", glGetString(GL_EXTENSIONS));
200
201   return true;
202 }
203
204 bool EglImplementation::CreateWindowContext( EGLContext& eglContext )
205 {
206   // make sure a context isn't created twice
207   DALI_ASSERT_ALWAYS( (eglContext == 0) && "EGL context recreated" );
208
209   eglContext = eglCreateContext(mEglDisplay, mEglConfig, mEglContext, &(mContextAttribs[0]));
210   TEST_EGL_ERROR("eglCreateContext render thread");
211
212   DALI_ASSERT_ALWAYS( EGL_NO_CONTEXT != eglContext && "EGL context not created" );
213
214   DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VENDOR : %s ***\n", glGetString(GL_VENDOR));
215   DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_RENDERER : %s ***\n", glGetString(GL_RENDERER));
216   DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VERSION : %s ***\n", glGetString(GL_VERSION));
217   DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_SHADING_LANGUAGE_VERSION : %s***\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
218   DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** Supported Extensions ***\n%s\n\n", glGetString(GL_EXTENSIONS));
219
220   mEglWindowContexts.push_back( eglContext );
221
222   return true;
223 }
224
225 void EglImplementation::DestroyContext( EGLContext& eglContext )
226 {
227   DALI_ASSERT_ALWAYS( mEglContext && "no EGL context" );
228
229   eglDestroyContext( mEglDisplay, eglContext );
230   eglContext = 0;
231 }
232
233 void EglImplementation::DestroySurface( EGLSurface& eglSurface )
234 {
235   if(mIsOwnSurface && eglSurface)
236   {
237     // Make context null to prevent crash in driver side
238     MakeContextNull();
239     eglDestroySurface( mEglDisplay, eglSurface );
240     eglSurface = 0;
241   }
242 }
243
244 void EglImplementation::MakeContextCurrent( EGLSurface eglSurface, EGLContext eglContext )
245 {
246   if (mCurrentEglContext == eglContext)
247   {
248     return;
249   }
250
251   mCurrentEglSurface = eglSurface;
252
253   if(mIsOwnSurface)
254   {
255     eglMakeCurrent( mEglDisplay, eglSurface, eglSurface, eglContext );
256
257     mCurrentEglContext = eglContext;
258   }
259
260   EGLint error = eglGetError();
261
262   if ( error != EGL_SUCCESS )
263   {
264     Egl::PrintError(error);
265
266     DALI_ASSERT_ALWAYS(false && "MakeContextCurrent failed!");
267   }
268 }
269
270 void EglImplementation::MakeCurrent( EGLNativePixmapType pixmap, EGLSurface eglSurface )
271 {
272   if (mCurrentEglContext == mEglContext)
273   {
274     return;
275   }
276
277   mCurrentEglNativePixmap = pixmap;
278   mCurrentEglSurface = eglSurface;
279
280   if(mIsOwnSurface)
281   {
282     eglMakeCurrent( mEglDisplay, eglSurface, eglSurface, mEglContext );
283
284     mCurrentEglContext = mEglContext;
285   }
286
287   EGLint error = eglGetError();
288
289   if ( error != EGL_SUCCESS )
290   {
291     Egl::PrintError(error);
292
293     DALI_ASSERT_ALWAYS(false && "MakeCurrent failed!");
294   }
295 }
296
297 void EglImplementation::MakeContextNull()
298 {
299   // clear the current context
300   eglMakeCurrent( mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT );
301   mCurrentEglContext = EGL_NO_CONTEXT;
302 }
303
304 void EglImplementation::TerminateGles()
305 {
306   if ( mGlesInitialized )
307   {
308     // Make context null to prevent crash in driver side
309     MakeContextNull();
310
311     for ( auto eglSurface : mEglWindowSurfaces )
312     {
313       if(mIsOwnSurface && eglSurface)
314       {
315         eglDestroySurface(mEglDisplay, eglSurface);
316       }
317     }
318     eglDestroyContext(mEglDisplay, mEglContext);
319     for ( auto eglContext : mEglWindowContexts )
320     {
321       eglDestroyContext(mEglDisplay, eglContext);
322     }
323
324     eglTerminate(mEglDisplay);
325
326     mEglDisplay = NULL;
327     mEglConfig  = NULL;
328     mEglContext = NULL;
329     mCurrentEglSurface = NULL;
330     mCurrentEglContext = EGL_NO_CONTEXT;
331
332     mGlesInitialized = false;
333   }
334 }
335
336 bool EglImplementation::IsGlesInitialized() const
337 {
338   return mGlesInitialized;
339 }
340
341
342 const char* GetEglErrorString(EGLint error)
343 {
344     switch(error)
345     {
346     case EGL_SUCCESS: return "No error";
347     case EGL_NOT_INITIALIZED: return "EGL not initialized or failed to initialize";
348     case EGL_BAD_ACCESS: return "Resource inaccessible";
349     case EGL_BAD_ALLOC: return "Cannot allocate resources";
350     case EGL_BAD_ATTRIBUTE: return "Unrecognized attribute or attribute value";
351     case EGL_BAD_CONTEXT: return "Invalid EGL context";
352     case EGL_BAD_CONFIG: return "Invalid EGL frame buffer configuration";
353     case EGL_BAD_CURRENT_SURFACE: return "Current surface is no longer valid";
354     case EGL_BAD_DISPLAY: return "Invalid EGL display";
355     case EGL_BAD_SURFACE: return "Invalid surface";
356     case EGL_BAD_MATCH: return "Inconsistent arguments";
357     case EGL_BAD_PARAMETER: return "Invalid argument";
358     case EGL_BAD_NATIVE_PIXMAP: return "Invalid native pixmap";
359     case EGL_BAD_NATIVE_WINDOW: return "Invalid native window";
360     case EGL_CONTEXT_LOST: return "Context lost";
361     }
362     return "Unknown error ";
363 }
364
365
366 void EglImplementation::SwapBuffers( EGLSurface& eglSurface )
367 {
368   if ( eglSurface != EGL_NO_SURFACE ) // skip if using surfaceless context
369   {
370     if( mIsFirstFrameAfterResume )
371     {
372       DALI_LOG_RELEASE_INFO( "EglImplementation::SwapBuffers: First SwapBuffers call.\n" );
373       mIsFirstFrameAfterResume = false;
374     }
375     if( mPartialUpdateAvailable && mSwapBuffersWithDamage )
376     {
377       mSwapBuffersWithDamage( mEglDisplay, eglSurface, &mDamagedRectArray[0], mDamagedRectArray.size()/4 );
378     }
379     else
380     {
381       eglSwapBuffers( mEglDisplay, eglSurface );
382     }
383   }
384 }
385
386
387 int EglImplementation::GetBufferAge( EGLSurface& eglSurface )
388 {
389   int bufferAge = 0;
390   if ( eglSurface != EGL_NO_SURFACE && mIsKhrPartialUpdateSupported )
391   {
392     if( !eglQuerySurface(mEglDisplay, eglSurface, EGL_BUFFER_AGE_KHR, &bufferAge) )
393     {
394       DALI_LOG_ERROR("EglImplementation::GetBufferAge() eglQuerySurface %s ",  GetEglErrorString(eglGetError()) );
395     }
396   }
397   return bufferAge;
398 }
399
400 void EglImplementation::SetDamagedRect( std::vector<int> damagedRectArray, EGLSurface& eglSurface )
401 {
402   mDamagedRectArray = damagedRectArray;
403   if ( eglSurface != EGL_NO_SURFACE && mPartialUpdateAvailable && mEglSetDamageRegionKHR )
404   {
405     if( !mEglSetDamageRegionKHR( mEglDisplay, eglSurface, &damagedRectArray[0], damagedRectArray.size() / 4 ) )
406     {
407       DALI_LOG_ERROR("EglImplementation::mEglSetDamageRegionKHR() error %s ",  GetEglErrorString(eglGetError()) );
408     }
409   }
410 }
411
412 void EglImplementation::CopyBuffers( EGLSurface& eglSurface )
413 {
414   eglCopyBuffers( mEglDisplay, eglSurface, mCurrentEglNativePixmap );
415 }
416
417 void EglImplementation::WaitGL()
418 {
419   eglWaitGL();
420 }
421
422 bool EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth )
423 {
424   if(mEglConfig && isWindowType == mIsWindow && mColorDepth == depth)
425   {
426     return true;
427   }
428
429   mColorDepth = depth;
430   mIsWindow = isWindowType;
431
432   EGLint numConfigs;
433   Vector<EGLint> configAttribs;
434   configAttribs.Reserve(31);
435
436   if(isWindowType)
437   {
438     configAttribs.PushBack( EGL_SURFACE_TYPE );
439     configAttribs.PushBack( EGL_WINDOW_BIT );
440   }
441   else
442   {
443     configAttribs.PushBack( EGL_SURFACE_TYPE );
444     configAttribs.PushBack( EGL_PIXMAP_BIT );
445   }
446
447   configAttribs.PushBack( EGL_RENDERABLE_TYPE );
448
449   if( mGlesVersion >= 30 )
450   {
451     configAttribs.PushBack( EGL_OPENGL_ES3_BIT_KHR );
452   }
453   else
454   {
455     configAttribs.PushBack( EGL_OPENGL_ES2_BIT );
456   }
457
458 // TODO: enable this flag when it becomes supported
459 //  configAttribs.PushBack( EGL_CONTEXT_FLAGS_KHR );
460 //  configAttribs.PushBack( EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR );
461
462   configAttribs.PushBack( EGL_RED_SIZE );
463   configAttribs.PushBack( 8 );
464   configAttribs.PushBack( EGL_GREEN_SIZE );
465   configAttribs.PushBack( 8 );
466   configAttribs.PushBack( EGL_BLUE_SIZE );
467   configAttribs.PushBack( 8 );
468
469 //  For underlay video playback, we also need to set the alpha value of the 24/32bit window.
470   configAttribs.PushBack( EGL_ALPHA_SIZE );
471   configAttribs.PushBack( 8 );
472
473   configAttribs.PushBack( EGL_DEPTH_SIZE );
474   configAttribs.PushBack( mDepthBufferRequired ? 24 : 0 );
475   configAttribs.PushBack( EGL_STENCIL_SIZE );
476   configAttribs.PushBack( mStencilBufferRequired ? 8 : 0 );
477
478 #ifndef DALI_PROFILE_UBUNTU
479   if( mMultiSamplingLevel != EGL_DONT_CARE )
480   {
481     configAttribs.PushBack( EGL_SAMPLES );
482     configAttribs.PushBack( mMultiSamplingLevel );
483     configAttribs.PushBack( EGL_SAMPLE_BUFFERS );
484     configAttribs.PushBack( 1 );
485   }
486 #endif // DALI_PROFILE_UBUNTU
487   configAttribs.PushBack( EGL_NONE );
488
489   // Ensure number of configs is set to 1 as on some drivers,
490   // eglChooseConfig succeeds but does not actually create a proper configuration.
491   if ( ( eglChooseConfig( mEglDisplay, &(configAttribs[0]), &mEglConfig, 1, &numConfigs ) != EGL_TRUE ) ||
492        ( numConfigs != 1 ) )
493   {
494     if( mGlesVersion >= 30 )
495     {
496       mEglConfig = NULL;
497       DALI_LOG_ERROR("Fail to use OpenGL es 3.0. Retrying to use OpenGL es 2.0.");
498       return false;
499     }
500
501     if ( numConfigs != 1 )
502     {
503       DALI_LOG_ERROR("No configurations found.\n");
504
505       TEST_EGL_ERROR("eglChooseConfig");
506     }
507
508     EGLint error = eglGetError();
509     switch (error)
510     {
511       case EGL_BAD_DISPLAY:
512       {
513         DALI_LOG_ERROR("Display is not an EGL display connection\n");
514         break;
515       }
516       case EGL_BAD_ATTRIBUTE:
517       {
518         DALI_LOG_ERROR("The parameter configAttribs contains an invalid frame buffer configuration attribute or an attribute value that is unrecognized or out of range\n");
519         break;
520       }
521       case EGL_NOT_INITIALIZED:
522       {
523         DALI_LOG_ERROR("Display has not been initialized\n");
524         break;
525       }
526       case EGL_BAD_PARAMETER:
527       {
528         DALI_LOG_ERROR("The parameter numConfig is NULL\n");
529         break;
530       }
531       default:
532       {
533         DALI_LOG_ERROR("Unknown error.\n");
534       }
535     }
536     DALI_ASSERT_ALWAYS(false && "eglChooseConfig failed!");
537     return false;
538   }
539   Integration::Log::LogMessage(Integration::Log::DebugInfo, "Using OpenGL es %d.%d.\n", mGlesVersion / 10, mGlesVersion % 10 );
540
541   mContextAttribs.Clear();
542   if( mIsKhrCreateContextSupported )
543   {
544     mContextAttribs.Reserve(5);
545     mContextAttribs.PushBack( EGL_CONTEXT_MAJOR_VERSION_KHR );
546     mContextAttribs.PushBack( mGlesVersion / 10 );
547     mContextAttribs.PushBack( EGL_CONTEXT_MINOR_VERSION_KHR );
548     mContextAttribs.PushBack( mGlesVersion % 10 );
549   }
550   else
551   {
552     mContextAttribs.Reserve(3);
553     mContextAttribs.PushBack( EGL_CONTEXT_CLIENT_VERSION );
554     mContextAttribs.PushBack( mGlesVersion / 10 );
555   }
556   mContextAttribs.PushBack( EGL_NONE );
557
558   return true;
559 }
560
561 EGLSurface EglImplementation::CreateSurfaceWindow( EGLNativeWindowType window, ColorDepth depth )
562 {
563   mEglNativeWindow = window;
564   mColorDepth = depth;
565   mIsWindow = true;
566
567   // egl choose config
568   ChooseConfig(mIsWindow, mColorDepth);
569
570   mCurrentEglSurface = eglCreateWindowSurface( mEglDisplay, mEglConfig, mEglNativeWindow, NULL );
571   TEST_EGL_ERROR("eglCreateWindowSurface");
572
573   DALI_ASSERT_ALWAYS( mCurrentEglSurface && "Create window surface failed" );
574
575   return mCurrentEglSurface;
576 }
577
578 EGLSurface EglImplementation::CreateSurfacePixmap( EGLNativePixmapType pixmap, ColorDepth depth )
579 {
580   mCurrentEglNativePixmap = pixmap;
581   mColorDepth = depth;
582   mIsWindow = false;
583
584   // egl choose config
585   ChooseConfig(mIsWindow, mColorDepth);
586
587   mCurrentEglSurface = eglCreatePixmapSurface( mEglDisplay, mEglConfig, mCurrentEglNativePixmap, NULL );
588   TEST_EGL_ERROR("eglCreatePixmapSurface");
589
590   DALI_ASSERT_ALWAYS( mCurrentEglSurface && "Create pixmap surface failed" );
591
592   return mCurrentEglSurface;
593 }
594
595 bool EglImplementation::ReplaceSurfaceWindow( EGLNativeWindowType window, EGLSurface& eglSurface, EGLContext& eglContext )
596 {
597   bool contextLost = false;
598
599   // display connection has not changed, then we can just create a new surface
600   //  the surface is bound to the context, so set the context to null
601   MakeContextNull();
602
603   // destroy the surface
604   DestroySurface( eglSurface );
605
606   // create the EGL surface
607   EGLSurface newEglSurface = CreateSurfaceWindow( window, mColorDepth );
608
609   // set the context to be current with the new surface
610   MakeContextCurrent( newEglSurface, eglContext );
611
612   return contextLost;
613 }
614
615 bool EglImplementation::ReplaceSurfacePixmap( EGLNativePixmapType pixmap, EGLSurface& eglSurface )
616 {
617   bool contextLost = false;
618
619   // display connection has not changed, then we can just create a new surface
620   // create the EGL surface
621   eglSurface = CreateSurfacePixmap( pixmap, mColorDepth );
622
623   // set the eglSurface to be current
624   MakeCurrent( pixmap, eglSurface );
625
626   return contextLost;
627 }
628
629 void EglImplementation::SetGlesVersion( const int32_t glesVersion )
630 {
631   mGlesVersion = glesVersion;
632 }
633
634 void EglImplementation::SetFirstFrameAfterResume()
635 {
636   mIsFirstFrameAfterResume = true;
637 }
638
639 EGLDisplay EglImplementation::GetDisplay() const
640 {
641   return mEglDisplay;
642 }
643
644 EGLContext EglImplementation::GetContext() const
645 {
646   return mEglContext;
647 }
648
649 int32_t EglImplementation::GetGlesVersion() const
650 {
651   return mGlesVersion;
652 }
653
654 bool EglImplementation::IsSurfacelessContextSupported() const
655 {
656   return mIsSurfacelessContextSupported;
657 }
658
659 void EglImplementation::WaitClient()
660 {
661   // Wait for EGL to finish executing all rendering calls for the current context
662   if ( eglWaitClient() != EGL_TRUE )
663   {
664     TEST_EGL_ERROR("eglWaitClient");
665   }
666 }
667
668 } // namespace Adaptor
669
670 } // namespace Internal
671
672 } // namespace Dali
673
674 #pragma GCC diagnostic pop