2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/graphics/gles/egl-implementation.h>
22 #include <dali/integration-api/debug.h>
23 #include <dali/integration-api/trace.h>
24 #include <dali/public-api/common/dali-vector.h>
28 #include <dali/devel-api/adaptor-framework/environment-variable.h>
29 #include <dali/internal/graphics/gles/egl-debug.h>
30 #include <dali/internal/graphics/gles/gl-implementation.h>
31 #include <dali/internal/system/common/time-service.h>
32 #include <dali/public-api/dali-adaptor-common.h>
34 // EGL constants use C style casts
35 #pragma GCC diagnostic push
36 #pragma GCC diagnostic ignored "-Wold-style-cast"
40 const uint32_t THRESHOLD_SWAPBUFFER_COUNT = 5;
41 const uint32_t CHECK_EXTENSION_NUMBER = 4;
42 const uint32_t EGL_VERSION_SUPPORT_SURFACELESS_CONTEXT = 15;
43 const std::string EGL_KHR_SURFACELESS_CONTEXT = "EGL_KHR_surfaceless_context";
44 const std::string EGL_KHR_CREATE_CONTEXT = "EGL_KHR_create_context";
45 const std::string EGL_KHR_PARTIAL_UPDATE = "EGL_KHR_partial_update";
46 const std::string EGL_KHR_SWAP_BUFFERS_WITH_DAMAGE = "EGL_KHR_swap_buffers_with_damage";
48 // Threshold time in miliseconds
49 constexpr auto PERFORMANCE_LOG_THRESHOLD_TIME_ENV = "DALI_EGL_PERFORMANCE_LOG_THRESHOLD_TIME";
51 DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_EGL, true);
53 uint32_t GetPerformanceLogThresholdTime()
55 auto timeString = Dali::EnvironmentVariable::GetEnvironmentVariable(PERFORMANCE_LOG_THRESHOLD_TIME_ENV);
56 uint32_t time = timeString ? static_cast<uint32_t>(std::atoi(timeString)) : 0u;
67 #define TEST_EGL_ERROR(lastCommand) \
69 EGLint err = eglGetError(); \
70 if(err != EGL_SUCCESS) \
72 DALI_LOG_ERROR("EGL error after %s\n", lastCommand); \
73 Egl::PrintError(err); \
74 DALI_ASSERT_ALWAYS(0 && "EGL error"); \
78 EglImplementation::EglImplementation(int multiSamplingLevel,
79 Integration::DepthBufferAvailable depthBufferRequired,
80 Integration::StencilBufferAvailable stencilBufferRequired,
81 Integration::PartialUpdateAvailable partialUpdateRequired)
85 mCurrentEglNativePixmap(0),
89 mCurrentEglSurface(0),
90 mCurrentEglContext(EGL_NO_CONTEXT),
91 mMultiSamplingLevel(multiSamplingLevel),
93 mColorDepth(COLOR_DEPTH_24),
94 mGlesInitialized(false),
97 mDepthBufferRequired(depthBufferRequired == Integration::DepthBufferAvailable::TRUE),
98 mStencilBufferRequired(stencilBufferRequired == Integration::StencilBufferAvailable::TRUE),
99 mPartialUpdateRequired(partialUpdateRequired == Integration::PartialUpdateAvailable::TRUE),
100 mIsSurfacelessContextSupported(false),
101 mIsKhrCreateContextSupported(false),
102 mSwapBufferCountAfterResume(0),
103 mEglSetDamageRegionKHR(0),
104 mEglSwapBuffersWithDamageKHR(0)
108 EglImplementation::~EglImplementation()
113 bool EglImplementation::InitializeGles(EGLNativeDisplayType display, bool isOwnSurface)
115 if(!mGlesInitialized)
117 mEglNativeDisplay = display;
119 // Try to get the display connection for the native display first
120 mEglDisplay = eglGetDisplay(mEglNativeDisplay);
122 if(mEglDisplay == EGL_NO_DISPLAY)
124 // If failed, try to get the default display connection
125 mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
128 if(mEglDisplay == EGL_NO_DISPLAY)
130 // Still failed to get a display connection
131 throw Dali::DaliException("", "OpenGL ES is not supported");
134 EGLint majorVersion = 0;
135 EGLint minorVersion = 0;
136 if(!eglInitialize(mEglDisplay, &majorVersion, &minorVersion))
140 eglBindAPI(EGL_OPENGL_ES_API);
142 mIsOwnSurface = isOwnSurface;
145 const char* const versionStr = eglQueryString(mEglDisplay, EGL_VERSION);
146 const char* const extensionStr = eglQueryString(mEglDisplay, EGL_EXTENSIONS);
148 // Query EGL extensions to check whether required extensions are supported
149 std::istringstream versionStream(versionStr);
150 std::string majorVersion, minorVersion;
151 std::getline(versionStream, majorVersion, '.');
152 std::getline(versionStream, minorVersion);
153 uint32_t extensionCheckCount = 0;
154 if(stoul(majorVersion) * 10 + stoul(minorVersion) >= EGL_VERSION_SUPPORT_SURFACELESS_CONTEXT)
156 mIsSurfacelessContextSupported = true;
157 mIsKhrCreateContextSupported = true;
158 extensionCheckCount += 2;
161 std::istringstream stream(extensionStr);
162 std::string currentExtension;
163 bool isKhrPartialUpdateSupported = false;
164 bool isKhrSwapBuffersWithDamageSupported = false;
165 while(std::getline(stream, currentExtension, ' ') && extensionCheckCount < CHECK_EXTENSION_NUMBER)
167 if(currentExtension == EGL_KHR_SURFACELESS_CONTEXT && !mIsSurfacelessContextSupported)
169 mIsSurfacelessContextSupported = true;
170 extensionCheckCount++;
172 if(currentExtension == EGL_KHR_CREATE_CONTEXT && !mIsKhrCreateContextSupported)
174 mIsKhrCreateContextSupported = true;
175 extensionCheckCount++;
177 if(currentExtension == EGL_KHR_PARTIAL_UPDATE)
179 isKhrPartialUpdateSupported = true;
180 extensionCheckCount++;
182 if(currentExtension == EGL_KHR_SWAP_BUFFERS_WITH_DAMAGE)
184 isKhrSwapBuffersWithDamageSupported = true;
185 extensionCheckCount++;
189 if(!isKhrPartialUpdateSupported || !isKhrSwapBuffersWithDamageSupported)
191 mPartialUpdateRequired = false;
194 mLogThreshold = GetPerformanceLogThresholdTime();
195 mLogEnabled = mLogThreshold > 0 ? true : false;
197 mGlesInitialized = true;
199 // We want to display this information all the time, so use the LogMessage directly
200 Integration::Log::LogMessage(Integration::Log::INFO,
202 " PartialUpdate %d\n"
207 mPartialUpdateRequired,
208 eglQueryString(mEglDisplay, EGL_VENDOR),
210 eglQueryString(mEglDisplay, EGL_CLIENT_APIS),
213 return mGlesInitialized;
216 bool EglImplementation::CreateContext()
218 // make sure a context isn't created twice
219 DALI_ASSERT_ALWAYS((mEglContext == 0) && "EGL context recreated");
221 mEglContext = eglCreateContext(mEglDisplay, mEglConfig, NULL, &(mContextAttribs[0]));
222 TEST_EGL_ERROR("eglCreateContext render thread");
224 DALI_ASSERT_ALWAYS(EGL_NO_CONTEXT != mEglContext && "EGL context not created");
226 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VENDOR : %s ***\n", glGetString(GL_VENDOR));
227 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_RENDERER : %s ***\n", glGetString(GL_RENDERER));
228 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VERSION : %s ***\n", glGetString(GL_VERSION));
229 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_SHADING_LANGUAGE_VERSION : %s***\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
230 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** Supported Extensions ***\n%s\n\n", glGetString(GL_EXTENSIONS));
232 mEglSetDamageRegionKHR = reinterpret_cast<PFNEGLSETDAMAGEREGIONKHRPROC>(eglGetProcAddress("eglSetDamageRegionKHR"));
233 if(!mEglSetDamageRegionKHR)
235 DALI_LOG_ERROR("Coudn't find eglSetDamageRegionKHR!\n");
236 mPartialUpdateRequired = false;
238 mEglSwapBuffersWithDamageKHR = reinterpret_cast<PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC>(eglGetProcAddress("eglSwapBuffersWithDamageKHR"));
239 if(!mEglSwapBuffersWithDamageKHR)
241 DALI_LOG_ERROR("Coudn't find eglSwapBuffersWithDamageKHR!\n");
242 mPartialUpdateRequired = false;
247 bool EglImplementation::CreateWindowContext(EGLContext& eglContext)
249 // make sure a context isn't created twice
250 DALI_ASSERT_ALWAYS((eglContext == 0) && "EGL context recreated");
252 eglContext = eglCreateContext(mEglDisplay, mEglConfig, mEglContext, &(mContextAttribs[0]));
253 TEST_EGL_ERROR("eglCreateContext render thread");
255 DALI_ASSERT_ALWAYS(EGL_NO_CONTEXT != eglContext && "EGL context not created");
257 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VENDOR : %s ***\n", glGetString(GL_VENDOR));
258 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_RENDERER : %s ***\n", glGetString(GL_RENDERER));
259 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VERSION : %s ***\n", glGetString(GL_VERSION));
260 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_SHADING_LANGUAGE_VERSION : %s***\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
261 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** Supported Extensions ***\n%s\n\n", glGetString(GL_EXTENSIONS));
263 mEglWindowContexts.push_back(eglContext);
265 mEglSetDamageRegionKHR = reinterpret_cast<PFNEGLSETDAMAGEREGIONKHRPROC>(eglGetProcAddress("eglSetDamageRegionKHR"));
266 if(!mEglSetDamageRegionKHR)
268 DALI_LOG_ERROR("Coudn't find eglSetDamageRegionKHR!\n");
269 mPartialUpdateRequired = false;
271 mEglSwapBuffersWithDamageKHR = reinterpret_cast<PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC>(eglGetProcAddress("eglSwapBuffersWithDamageKHR"));
272 if(!mEglSwapBuffersWithDamageKHR)
274 DALI_LOG_ERROR("Coudn't find eglSwapBuffersWithDamageKHR!\n");
275 mPartialUpdateRequired = false;
280 void EglImplementation::DestroyContext(EGLContext& eglContext)
284 eglDestroyContext(mEglDisplay, eglContext);
289 void EglImplementation::DestroySurface(EGLSurface& eglSurface)
291 if(mIsOwnSurface && eglSurface)
293 // Make context null to prevent crash in driver side
295 eglDestroySurface(mEglDisplay, eglSurface);
300 void EglImplementation::MakeContextCurrent(EGLSurface eglSurface, EGLContext eglContext)
302 if(mCurrentEglContext == eglContext)
307 mCurrentEglSurface = eglSurface;
311 eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, eglContext);
313 mCurrentEglContext = eglContext;
316 EGLint error = eglGetError();
318 if(error != EGL_SUCCESS)
320 Egl::PrintError(error);
322 DALI_ASSERT_ALWAYS(false && "MakeContextCurrent failed!");
326 void EglImplementation::MakeCurrent(EGLNativePixmapType pixmap, EGLSurface eglSurface)
328 if(mCurrentEglContext == mEglContext)
333 mCurrentEglNativePixmap = pixmap;
334 mCurrentEglSurface = eglSurface;
338 eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, mEglContext);
340 mCurrentEglContext = mEglContext;
343 EGLint error = eglGetError();
345 if(error != EGL_SUCCESS)
347 Egl::PrintError(error);
349 DALI_ASSERT_ALWAYS(false && "MakeCurrent failed!");
353 void EglImplementation::MakeContextNull()
355 // clear the current context
356 eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
357 mCurrentEglContext = EGL_NO_CONTEXT;
360 void EglImplementation::TerminateGles()
364 // Make context null to prevent crash in driver side
367 for(auto eglSurface : mEglWindowSurfaces)
369 if(mIsOwnSurface && eglSurface)
371 eglDestroySurface(mEglDisplay, eglSurface);
374 eglDestroyContext(mEglDisplay, mEglContext);
375 for(auto eglContext : mEglWindowContexts)
377 eglDestroyContext(mEglDisplay, eglContext);
380 eglTerminate(mEglDisplay);
385 mCurrentEglSurface = NULL;
386 mCurrentEglContext = EGL_NO_CONTEXT;
388 mGlesInitialized = false;
392 bool EglImplementation::IsGlesInitialized() const
394 return mGlesInitialized;
397 void EglImplementation::SwapBuffers(EGLSurface& eglSurface)
399 if(eglSurface != EGL_NO_SURFACE) // skip if using surfaceless context
401 uint32_t startTime = 0, endTime = 0;
404 startTime = TimeService::GetMilliSeconds();
407 #ifndef DALI_PROFILE_UBUNTU
408 if(mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT)
410 DALI_LOG_RELEASE_INFO("EglImplementation::eglSwapBuffers started. eglSurface(%p)\n", eglSurface);
411 DALI_TRACE_BEGIN(gTraceFilter, "DALI_EGL_SWAP_BUFFERS");
413 #endif //DALI_PROFILE_UBUNTU
415 // DALI_LOG_ERROR("EglImplementation::SwapBuffers()\n");
416 eglSwapBuffers(mEglDisplay, eglSurface);
418 #ifndef DALI_PROFILE_UBUNTU
419 if(mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT)
421 DALI_TRACE_END(gTraceFilter, "DALI_EGL_SWAP_BUFFERS");
422 DALI_LOG_RELEASE_INFO("EglImplementation::eglSwapBuffers finished.\n");
423 mSwapBufferCountAfterResume++;
425 #endif //DALI_PROFILE_UBUNTU
429 endTime = TimeService::GetMilliSeconds();
430 if(endTime - startTime > mLogThreshold)
432 DALI_LOG_DEBUG_INFO("eglSwapBuffers takes long time! [%u ms]\n", endTime - startTime);
438 EGLint EglImplementation::GetBufferAge(EGLSurface& eglSurface) const
440 uint32_t startTime = 0, endTime = 0;
443 startTime = TimeService::GetMilliSeconds();
447 eglQuerySurface(mEglDisplay, eglSurface, EGL_BUFFER_AGE_EXT, &age);
450 DALI_LOG_ERROR("eglQuerySurface(%d)\n", eglGetError());
456 endTime = TimeService::GetMilliSeconds();
457 if(endTime - startTime > mLogThreshold)
459 DALI_LOG_DEBUG_INFO("eglQuerySurface takes long time! [%u ms]\n", endTime - startTime);
465 void EglImplementation::SetDamageRegion(EGLSurface& eglSurface, std::vector<Rect<int>>& damagedRects)
467 if(!mPartialUpdateRequired)
472 if(eglSurface != EGL_NO_SURFACE) // skip if using surfaceless context
474 EGLBoolean result = mEglSetDamageRegionKHR(mEglDisplay, eglSurface, reinterpret_cast<int*>(damagedRects.data()), 1);
475 if(result == EGL_FALSE)
477 DALI_LOG_ERROR("eglSetDamageRegionKHR(0x%x)\n", eglGetError());
482 void EglImplementation::SwapBuffers(EGLSurface& eglSurface, const std::vector<Rect<int>>& damagedRects)
484 if(eglSurface != EGL_NO_SURFACE) // skip if using surfaceless context
486 if(!mPartialUpdateRequired)
488 SwapBuffers(eglSurface);
492 uint32_t startTime = 0, endTime = 0;
495 startTime = TimeService::GetMilliSeconds();
498 #ifndef DALI_PROFILE_UBUNTU
499 if(mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT)
501 DALI_LOG_RELEASE_INFO("EglImplementation::eglSwapBuffersWithDamageKHR started. eglSurface(%p)\n", eglSurface);
502 DALI_TRACE_BEGIN(gTraceFilter, "DALI_EGL_SWAP_BUFFERS_KHR");
504 #endif //DALI_PROFILE_UBUNTU
506 EGLBoolean result = mEglSwapBuffersWithDamageKHR(mEglDisplay, eglSurface, reinterpret_cast<int*>(const_cast<std::vector<Rect<int>>&>(damagedRects).data()), damagedRects.size());
507 if(result == EGL_FALSE)
509 DALI_LOG_ERROR("eglSwapBuffersWithDamageKHR(%d)\n", eglGetError());
512 #ifndef DALI_PROFILE_UBUNTU
513 if(mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT)
515 DALI_TRACE_END(gTraceFilter, "DALI_EGL_SWAP_BUFFERS_KHR");
516 DALI_LOG_RELEASE_INFO("EglImplementation::eglSwapBuffersWithDamageKHR finished.\n");
517 mSwapBufferCountAfterResume++;
519 #endif //DALI_PROFILE_UBUNTU
523 endTime = TimeService::GetMilliSeconds();
524 if(endTime - startTime > mLogThreshold)
526 DALI_LOG_DEBUG_INFO("eglSwapBuffersWithDamageKHR takes long time! [%u ms]\n", endTime - startTime);
532 void EglImplementation::CopyBuffers(EGLSurface& eglSurface)
534 eglCopyBuffers(mEglDisplay, eglSurface, mCurrentEglNativePixmap);
537 void EglImplementation::WaitGL()
542 bool EglImplementation::ChooseConfig(bool isWindowType, ColorDepth depth)
544 if(mEglConfig && isWindowType == mIsWindow && mColorDepth == depth)
550 mIsWindow = isWindowType;
553 Vector<EGLint> configAttribs;
554 configAttribs.Reserve(31);
558 configAttribs.PushBack(EGL_SURFACE_TYPE);
559 configAttribs.PushBack(EGL_WINDOW_BIT);
563 configAttribs.PushBack(EGL_SURFACE_TYPE);
564 configAttribs.PushBack(EGL_PIXMAP_BIT);
567 configAttribs.PushBack(EGL_RENDERABLE_TYPE);
569 if(mGlesVersion >= 30)
571 configAttribs.PushBack(EGL_OPENGL_ES3_BIT_KHR);
575 configAttribs.PushBack(EGL_OPENGL_ES2_BIT);
578 // TODO: enable this flag when it becomes supported
579 // configAttribs.PushBack( EGL_CONTEXT_FLAGS_KHR );
580 // configAttribs.PushBack( EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR );
582 configAttribs.PushBack(EGL_RED_SIZE);
583 configAttribs.PushBack(8);
584 configAttribs.PushBack(EGL_GREEN_SIZE);
585 configAttribs.PushBack(8);
586 configAttribs.PushBack(EGL_BLUE_SIZE);
587 configAttribs.PushBack(8);
589 // For underlay video playback, we also need to set the alpha value of the 24/32bit window.
590 // TODO: When the tbm queue of GlView is 24bit, do we have to set the alpha size??
591 configAttribs.PushBack(EGL_ALPHA_SIZE);
592 configAttribs.PushBack(8);
594 configAttribs.PushBack(EGL_DEPTH_SIZE);
595 configAttribs.PushBack(mDepthBufferRequired ? 24 : 0);
596 configAttribs.PushBack(EGL_STENCIL_SIZE);
597 configAttribs.PushBack(mStencilBufferRequired ? 8 : 0);
599 #ifndef DALI_PROFILE_UBUNTU
600 if(mMultiSamplingLevel != EGL_DONT_CARE)
602 configAttribs.PushBack(EGL_SAMPLES);
603 configAttribs.PushBack(mMultiSamplingLevel);
604 configAttribs.PushBack(EGL_SAMPLE_BUFFERS);
605 configAttribs.PushBack(1);
607 #endif // DALI_PROFILE_UBUNTU
608 configAttribs.PushBack(EGL_NONE);
610 // Ensure number of configs is set to 1 as on some drivers,
611 // eglChooseConfig succeeds but does not actually create a proper configuration.
612 if((eglChooseConfig(mEglDisplay, &(configAttribs[0]), &mEglConfig, 1, &numConfigs) != EGL_TRUE) ||
615 if(mGlesVersion >= 30)
618 DALI_LOG_ERROR("Fail to use OpenGL es 3.0. Retrying to use OpenGL es 2.0.");
624 DALI_LOG_ERROR("No configurations found.\n");
626 TEST_EGL_ERROR("eglChooseConfig");
629 EGLint error = eglGetError();
632 case EGL_BAD_DISPLAY:
634 DALI_LOG_ERROR("Display is not an EGL display connection\n");
637 case EGL_BAD_ATTRIBUTE:
639 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");
642 case EGL_NOT_INITIALIZED:
644 DALI_LOG_ERROR("Display has not been initialized\n");
647 case EGL_BAD_PARAMETER:
649 DALI_LOG_ERROR("The parameter numConfig is NULL\n");
654 DALI_LOG_ERROR("Unknown error.\n");
657 DALI_ASSERT_ALWAYS(false && "eglChooseConfig failed!");
660 Integration::Log::LogMessage(Integration::Log::INFO, "Using OpenGL es %d.%d.\n", mGlesVersion / 10, mGlesVersion % 10);
662 mContextAttribs.Clear();
663 if(mIsKhrCreateContextSupported)
665 mContextAttribs.Reserve(5);
666 mContextAttribs.PushBack(EGL_CONTEXT_MAJOR_VERSION_KHR);
667 mContextAttribs.PushBack(mGlesVersion / 10);
668 mContextAttribs.PushBack(EGL_CONTEXT_MINOR_VERSION_KHR);
669 mContextAttribs.PushBack(mGlesVersion % 10);
673 mContextAttribs.Reserve(3);
674 mContextAttribs.PushBack(EGL_CONTEXT_CLIENT_VERSION);
675 mContextAttribs.PushBack(mGlesVersion / 10);
677 mContextAttribs.PushBack(EGL_NONE);
682 EGLSurface EglImplementation::CreateSurfaceWindow(EGLNativeWindowType window, ColorDepth depth)
684 mEglNativeWindow = window;
689 ChooseConfig(mIsWindow, mColorDepth);
691 mCurrentEglSurface = eglCreateWindowSurface(mEglDisplay, mEglConfig, mEglNativeWindow, NULL);
692 TEST_EGL_ERROR("eglCreateWindowSurface");
694 DALI_ASSERT_ALWAYS(mCurrentEglSurface && "Create window surface failed");
696 return mCurrentEglSurface;
699 EGLSurface EglImplementation::CreateSurfacePixmap(EGLNativePixmapType pixmap, ColorDepth depth)
701 mCurrentEglNativePixmap = pixmap;
706 ChooseConfig(mIsWindow, mColorDepth);
708 mCurrentEglSurface = eglCreatePixmapSurface(mEglDisplay, mEglConfig, mCurrentEglNativePixmap, NULL);
709 TEST_EGL_ERROR("eglCreatePixmapSurface");
711 DALI_ASSERT_ALWAYS(mCurrentEglSurface && "Create pixmap surface failed");
713 return mCurrentEglSurface;
716 bool EglImplementation::ReplaceSurfaceWindow(EGLNativeWindowType window, EGLSurface& eglSurface, EGLContext& eglContext)
718 bool contextLost = false;
720 // display connection has not changed, then we can just create a new surface
721 // the surface is bound to the context, so set the context to null
726 // destroy the surface
727 DestroySurface(eglSurface);
730 // create the EGL surface
731 EGLSurface newEglSurface = CreateSurfaceWindow(window, mColorDepth);
733 // set the context to be current with the new surface
734 MakeContextCurrent(newEglSurface, eglContext);
739 bool EglImplementation::ReplaceSurfacePixmap(EGLNativePixmapType pixmap, EGLSurface& eglSurface)
741 bool contextLost = false;
743 // display connection has not changed, then we can just create a new surface
744 // create the EGL surface
745 eglSurface = CreateSurfacePixmap(pixmap, mColorDepth);
747 // set the eglSurface to be current
748 MakeCurrent(pixmap, eglSurface);
753 void EglImplementation::SetGlesVersion(const int32_t glesVersion)
755 mGlesVersion = glesVersion;
758 void EglImplementation::SetFirstFrameAfterResume()
760 mSwapBufferCountAfterResume = 0;
763 EGLDisplay EglImplementation::GetDisplay() const
768 EGLContext EglImplementation::GetContext() const
773 int32_t EglImplementation::GetGlesVersion() const
778 bool EglImplementation::IsSurfacelessContextSupported() const
780 return mIsSurfacelessContextSupported;
783 void EglImplementation::WaitClient()
785 // Wait for EGL to finish executing all rendering calls for the current context
786 if(eglWaitClient() != EGL_TRUE)
788 TEST_EGL_ERROR("eglWaitClient");
792 bool EglImplementation::IsPartialUpdateRequired() const
794 return mPartialUpdateRequired;
797 } // namespace Adaptor
799 } // namespace Internal
803 #pragma GCC diagnostic pop