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