2 * Copyright (c) 2024 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>
29 #include <dali/devel-api/adaptor-framework/environment-variable.h>
30 #include <dali/internal/graphics/gles/egl-debug.h>
31 #include <dali/internal/graphics/gles/gl-implementation.h>
32 #include <dali/internal/system/common/environment-variables.h>
33 #include <dali/internal/system/common/time-service.h>
34 #include <dali/public-api/dali-adaptor-common.h>
36 // EGL constants use C style casts
37 #pragma GCC diagnostic push
38 #pragma GCC diagnostic ignored "-Wold-style-cast"
42 #ifndef DALI_PROFILE_UBUNTU
43 const uint32_t THRESHOLD_SWAPBUFFER_COUNT = 20;
45 const uint32_t THRESHOLD_SWAPBUFFER_COUNT = 5;
47 const uint32_t CHECK_EXTENSION_NUMBER = 4;
48 const uint32_t EGL_VERSION_SUPPORT_SURFACELESS_CONTEXT = 15;
49 const char* EGL_KHR_SURFACELESS_CONTEXT = "EGL_KHR_surfaceless_context";
50 const char* EGL_KHR_CREATE_CONTEXT = "EGL_KHR_create_context";
51 const char* EGL_KHR_PARTIAL_UPDATE = "EGL_KHR_partial_update";
52 const char* EGL_KHR_SWAP_BUFFERS_WITH_DAMAGE = "EGL_KHR_swap_buffers_with_damage";
54 DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_EGL, true);
56 static uint32_t GetPerformanceLogThresholdTime()
58 auto timeString = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_EGL_PERFORMANCE_LOG_THRESHOLD_TIME);
59 uint32_t time = timeString ? static_cast<uint32_t>(std::atoi(timeString)) : std::numeric_limits<uint32_t>::max();
63 #define START_DURATION_CHECK() \
64 uint64_t startTimeNanoSeconds = 0ull; \
65 uint64_t endTimeNanoSeconds = 0ull; \
68 TimeService::GetNanoseconds(startTimeNanoSeconds); \
71 #define FINISH_DURATION_CHECK(functionName) \
74 TimeService::GetNanoseconds(endTimeNanoSeconds); \
75 if(static_cast<uint32_t>((endTimeNanoSeconds - startTimeNanoSeconds) / 1000000ull) >= mLogThreshold) \
77 DALI_LOG_RELEASE_INFO("%s takes long time! [%.6lf ms]\n", functionName, static_cast<double>(endTimeNanoSeconds - startTimeNanoSeconds) / 1000000.0); \
89 #define TEST_EGL_ERROR(lastCommand) \
91 EGLint err = eglGetError(); \
92 if(err != EGL_SUCCESS) \
94 DALI_LOG_ERROR("EGL error after %s\n", lastCommand); \
95 Egl::PrintError(err); \
96 DALI_ASSERT_ALWAYS(0 && "EGL error"); \
100 EglImplementation::EglImplementation(int multiSamplingLevel,
101 Integration::DepthBufferAvailable depthBufferRequired,
102 Integration::StencilBufferAvailable stencilBufferRequired,
103 Integration::PartialUpdateAvailable partialUpdateRequired)
105 mEglNativeDisplay(0),
107 mCurrentEglNativePixmap(0),
111 mCurrentEglSurface(0),
112 mCurrentEglContext(EGL_NO_CONTEXT),
113 mMultiSamplingLevel(multiSamplingLevel),
115 mColorDepth(COLOR_DEPTH_24),
116 mGlesInitialized(false),
119 mDepthBufferRequired(depthBufferRequired == Integration::DepthBufferAvailable::TRUE),
120 mStencilBufferRequired(stencilBufferRequired == Integration::StencilBufferAvailable::TRUE),
121 mPartialUpdateRequired(partialUpdateRequired == Integration::PartialUpdateAvailable::TRUE),
122 mIsSurfacelessContextSupported(false),
123 mIsKhrCreateContextSupported(false),
124 mSwapBufferCountAfterResume(0),
125 mEglSetDamageRegionKHR(0),
126 mEglSwapBuffersWithDamageKHR(0)
130 EglImplementation::~EglImplementation()
135 bool EglImplementation::InitializeGles(EGLNativeDisplayType display, bool isOwnSurface)
137 if(!mGlesInitialized)
139 mEglNativeDisplay = display;
141 // Try to get the display connection for the native display first
142 mEglDisplay = eglGetDisplay(mEglNativeDisplay);
144 if(mEglDisplay == EGL_NO_DISPLAY)
146 // If failed, try to get the default display connection
147 mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
150 if(mEglDisplay == EGL_NO_DISPLAY)
152 // Still failed to get a display connection
153 throw Dali::DaliException("", "OpenGL ES is not supported");
156 EGLint majorVersion = 0;
157 EGLint minorVersion = 0;
158 if(!eglInitialize(mEglDisplay, &majorVersion, &minorVersion))
162 eglBindAPI(EGL_OPENGL_ES_API);
164 mIsOwnSurface = isOwnSurface;
167 const char* const versionStr = eglQueryString(mEglDisplay, EGL_VERSION);
168 const char* const extensionStr = eglQueryString(mEglDisplay, EGL_EXTENSIONS);
170 // Query EGL extensions to check whether required extensions are supported
171 std::istringstream versionStream(versionStr);
172 std::string majorVersion, minorVersion;
173 std::getline(versionStream, majorVersion, '.');
174 std::getline(versionStream, minorVersion);
175 uint32_t extensionCheckCount = 0;
176 if(stoul(majorVersion) * 10 + stoul(minorVersion) >= EGL_VERSION_SUPPORT_SURFACELESS_CONTEXT)
178 mIsSurfacelessContextSupported = true;
179 mIsKhrCreateContextSupported = true;
180 extensionCheckCount += 2;
183 std::istringstream stream(extensionStr);
184 std::string currentExtension;
185 bool isKhrPartialUpdateSupported = false;
186 bool isKhrSwapBuffersWithDamageSupported = false;
187 while(std::getline(stream, currentExtension, ' ') && extensionCheckCount < CHECK_EXTENSION_NUMBER)
189 if(currentExtension == EGL_KHR_SURFACELESS_CONTEXT && !mIsSurfacelessContextSupported)
191 mIsSurfacelessContextSupported = true;
192 extensionCheckCount++;
194 if(currentExtension == EGL_KHR_CREATE_CONTEXT && !mIsKhrCreateContextSupported)
196 mIsKhrCreateContextSupported = true;
197 extensionCheckCount++;
199 if(currentExtension == EGL_KHR_PARTIAL_UPDATE)
201 isKhrPartialUpdateSupported = true;
202 extensionCheckCount++;
204 if(currentExtension == EGL_KHR_SWAP_BUFFERS_WITH_DAMAGE)
206 isKhrSwapBuffersWithDamageSupported = true;
207 extensionCheckCount++;
211 if(!isKhrPartialUpdateSupported || !isKhrSwapBuffersWithDamageSupported)
213 mPartialUpdateRequired = false;
216 mLogThreshold = GetPerformanceLogThresholdTime();
217 mLogEnabled = mLogThreshold < std::numeric_limits<uint32_t>::max() ? true : false;
219 mGlesInitialized = true;
221 // We want to display this information all the time, so use the LogMessage directly
222 Integration::Log::LogMessage(Integration::Log::INFO,
224 " PartialUpdate %d\n"
229 mPartialUpdateRequired,
230 eglQueryString(mEglDisplay, EGL_VENDOR),
232 eglQueryString(mEglDisplay, EGL_CLIENT_APIS),
235 return mGlesInitialized;
238 bool EglImplementation::CreateContext()
240 // make sure a context isn't created twice
241 DALI_ASSERT_ALWAYS((mEglContext == 0) && "EGL context recreated");
243 mEglContext = eglCreateContext(mEglDisplay, mEglConfig, NULL, &(mContextAttribs[0]));
244 TEST_EGL_ERROR("eglCreateContext render thread");
246 DALI_ASSERT_ALWAYS(EGL_NO_CONTEXT != mEglContext && "EGL context not created");
248 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VENDOR : %s ***\n", glGetString(GL_VENDOR));
249 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_RENDERER : %s ***\n", glGetString(GL_RENDERER));
250 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VERSION : %s ***\n", glGetString(GL_VERSION));
251 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_SHADING_LANGUAGE_VERSION : %s***\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
252 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** Supported Extensions ***\n%s\n\n", glGetString(GL_EXTENSIONS));
254 mEglSetDamageRegionKHR = reinterpret_cast<PFNEGLSETDAMAGEREGIONKHRPROC>(eglGetProcAddress("eglSetDamageRegionKHR"));
255 if(!mEglSetDamageRegionKHR)
257 DALI_LOG_ERROR("Coudn't find eglSetDamageRegionKHR!\n");
258 mPartialUpdateRequired = false;
260 mEglSwapBuffersWithDamageKHR = reinterpret_cast<PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC>(eglGetProcAddress("eglSwapBuffersWithDamageKHR"));
261 if(!mEglSwapBuffersWithDamageKHR)
263 DALI_LOG_ERROR("Coudn't find eglSwapBuffersWithDamageKHR!\n");
264 mPartialUpdateRequired = false;
269 bool EglImplementation::CreateWindowContext(EGLContext& eglContext)
271 // make sure a context isn't created twice
272 DALI_ASSERT_ALWAYS((eglContext == 0) && "EGL context recreated");
274 eglContext = eglCreateContext(mEglDisplay, mEglConfig, mEglContext, &(mContextAttribs[0]));
275 TEST_EGL_ERROR("eglCreateContext render thread");
277 DALI_ASSERT_ALWAYS(EGL_NO_CONTEXT != eglContext && "EGL context not created");
279 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VENDOR : %s ***\n", glGetString(GL_VENDOR));
280 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_RENDERER : %s ***\n", glGetString(GL_RENDERER));
281 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VERSION : %s ***\n", glGetString(GL_VERSION));
282 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_SHADING_LANGUAGE_VERSION : %s***\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
283 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** Supported Extensions ***\n%s\n\n", glGetString(GL_EXTENSIONS));
285 mEglWindowContexts.push_back(eglContext);
287 mEglSetDamageRegionKHR = reinterpret_cast<PFNEGLSETDAMAGEREGIONKHRPROC>(eglGetProcAddress("eglSetDamageRegionKHR"));
288 if(!mEglSetDamageRegionKHR)
290 DALI_LOG_ERROR("Coudn't find eglSetDamageRegionKHR!\n");
291 mPartialUpdateRequired = false;
293 mEglSwapBuffersWithDamageKHR = reinterpret_cast<PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC>(eglGetProcAddress("eglSwapBuffersWithDamageKHR"));
294 if(!mEglSwapBuffersWithDamageKHR)
296 DALI_LOG_ERROR("Coudn't find eglSwapBuffersWithDamageKHR!\n");
297 mPartialUpdateRequired = false;
302 void EglImplementation::DestroyContext(EGLContext& eglContext)
306 eglDestroyContext(mEglDisplay, eglContext);
311 void EglImplementation::DestroySurface(EGLSurface& eglSurface)
313 if(mIsOwnSurface && eglSurface)
315 // Make context null to prevent crash in driver side
317 eglDestroySurface(mEglDisplay, eglSurface);
322 void EglImplementation::MakeContextCurrent(EGLSurface eglSurface, EGLContext eglContext)
324 if(mCurrentEglContext == eglContext)
329 mCurrentEglSurface = eglSurface;
333 eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, eglContext);
335 mCurrentEglContext = eglContext;
338 EGLint error = eglGetError();
340 if(error != EGL_SUCCESS)
342 Egl::PrintError(error);
344 DALI_ASSERT_ALWAYS(false && "MakeContextCurrent failed!");
348 void EglImplementation::MakeCurrent(EGLNativePixmapType pixmap, EGLSurface eglSurface)
350 if(mCurrentEglContext == mEglContext)
355 mCurrentEglNativePixmap = pixmap;
356 mCurrentEglSurface = eglSurface;
360 eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, mEglContext);
362 mCurrentEglContext = mEglContext;
365 EGLint error = eglGetError();
367 if(error != EGL_SUCCESS)
369 Egl::PrintError(error);
371 DALI_ASSERT_ALWAYS(false && "MakeCurrent failed!");
375 void EglImplementation::MakeContextNull()
377 // clear the current context
378 eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
379 mCurrentEglContext = EGL_NO_CONTEXT;
382 void EglImplementation::TerminateGles()
386 // Make context null to prevent crash in driver side
389 for(auto eglSurface : mEglWindowSurfaces)
391 if(mIsOwnSurface && eglSurface)
393 eglDestroySurface(mEglDisplay, eglSurface);
396 eglDestroyContext(mEglDisplay, mEglContext);
397 for(auto eglContext : mEglWindowContexts)
399 eglDestroyContext(mEglDisplay, eglContext);
402 eglTerminate(mEglDisplay);
407 mCurrentEglSurface = NULL;
408 mCurrentEglContext = EGL_NO_CONTEXT;
410 mGlesInitialized = false;
414 bool EglImplementation::IsGlesInitialized() const
416 return mGlesInitialized;
419 void EglImplementation::SwapBuffers(EGLSurface& eglSurface)
421 if(eglSurface != EGL_NO_SURFACE) // skip if using surfaceless context
423 START_DURATION_CHECK();
425 #ifndef DALI_PROFILE_UBUNTU
426 if(mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT)
428 DALI_LOG_RELEASE_INFO("EglImplementation::eglSwapBuffers started. eglSurface(%p)\n", eglSurface);
430 DALI_TRACE_BEGIN(gTraceFilter, "DALI_EGL_SWAP_BUFFERS");
431 #endif //DALI_PROFILE_UBUNTU
433 // DALI_LOG_ERROR("EglImplementation::SwapBuffers()\n");
434 eglSwapBuffers(mEglDisplay, eglSurface);
436 #ifndef DALI_PROFILE_UBUNTU
437 DALI_TRACE_END(gTraceFilter, "DALI_EGL_SWAP_BUFFERS");
438 if(mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT)
440 DALI_LOG_RELEASE_INFO("EglImplementation::eglSwapBuffers finished.\n");
441 mSwapBufferCountAfterResume++;
443 #endif //DALI_PROFILE_UBUNTU
445 FINISH_DURATION_CHECK("eglSwapBuffers");
449 EGLint EglImplementation::GetBufferAge(EGLSurface& eglSurface) const
451 START_DURATION_CHECK();
454 eglQuerySurface(mEglDisplay, eglSurface, EGL_BUFFER_AGE_EXT, &age);
457 DALI_LOG_ERROR("eglQuerySurface(%d)\n", eglGetError());
461 FINISH_DURATION_CHECK("eglQuerySurface");
466 void EglImplementation::SetDamageRegion(EGLSurface& eglSurface, std::vector<Rect<int>>& damagedRects)
468 if(!mPartialUpdateRequired)
473 if(eglSurface != EGL_NO_SURFACE) // skip if using surfaceless context
475 EGLBoolean result = mEglSetDamageRegionKHR(mEglDisplay, eglSurface, reinterpret_cast<int*>(damagedRects.data()), 1);
476 if(result == EGL_FALSE)
478 DALI_LOG_ERROR("eglSetDamageRegionKHR(0x%x)\n", eglGetError());
483 void EglImplementation::SwapBuffers(EGLSurface& eglSurface, const std::vector<Rect<int>>& damagedRects)
485 if(eglSurface != EGL_NO_SURFACE) // skip if using surfaceless context
487 if(!mPartialUpdateRequired)
489 SwapBuffers(eglSurface);
493 START_DURATION_CHECK();
495 #ifndef DALI_PROFILE_UBUNTU
496 if(mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT)
498 DALI_LOG_RELEASE_INFO("EglImplementation::eglSwapBuffersWithDamageKHR started. eglSurface(%p)\n", eglSurface);
500 DALI_TRACE_BEGIN(gTraceFilter, "DALI_EGL_SWAP_BUFFERS_KHR");
501 #endif //DALI_PROFILE_UBUNTU
503 EGLBoolean result = mEglSwapBuffersWithDamageKHR(mEglDisplay, eglSurface, reinterpret_cast<int*>(const_cast<std::vector<Rect<int>>&>(damagedRects).data()), damagedRects.size());
504 if(result == EGL_FALSE)
506 DALI_LOG_ERROR("eglSwapBuffersWithDamageKHR(%d)\n", eglGetError());
509 #ifndef DALI_PROFILE_UBUNTU
510 DALI_TRACE_END(gTraceFilter, "DALI_EGL_SWAP_BUFFERS_KHR");
511 if(mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT)
513 DALI_LOG_RELEASE_INFO("EglImplementation::eglSwapBuffersWithDamageKHR finished.\n");
514 mSwapBufferCountAfterResume++;
516 #endif //DALI_PROFILE_UBUNTU
518 FINISH_DURATION_CHECK("eglSwapBuffersWithDamageKHR");
522 void EglImplementation::CopyBuffers(EGLSurface& eglSurface)
524 eglCopyBuffers(mEglDisplay, eglSurface, mCurrentEglNativePixmap);
527 void EglImplementation::WaitGL()
532 bool EglImplementation::ChooseConfig(bool isWindowType, ColorDepth depth)
534 if(mEglConfig && isWindowType == mIsWindow && mColorDepth == depth)
540 mIsWindow = isWindowType;
543 Vector<EGLint> configAttribs;
544 configAttribs.Reserve(31);
548 configAttribs.PushBack(EGL_SURFACE_TYPE);
549 configAttribs.PushBack(EGL_WINDOW_BIT);
553 configAttribs.PushBack(EGL_SURFACE_TYPE);
554 configAttribs.PushBack(EGL_PIXMAP_BIT);
557 configAttribs.PushBack(EGL_RENDERABLE_TYPE);
559 if(mGlesVersion >= 30)
561 configAttribs.PushBack(EGL_OPENGL_ES3_BIT_KHR);
565 configAttribs.PushBack(EGL_OPENGL_ES2_BIT);
568 // TODO: enable this flag when it becomes supported
569 // configAttribs.PushBack( EGL_CONTEXT_FLAGS_KHR );
570 // configAttribs.PushBack( EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR );
572 configAttribs.PushBack(EGL_RED_SIZE);
573 configAttribs.PushBack(8);
574 configAttribs.PushBack(EGL_GREEN_SIZE);
575 configAttribs.PushBack(8);
576 configAttribs.PushBack(EGL_BLUE_SIZE);
577 configAttribs.PushBack(8);
579 // For underlay video playback, we also need to set the alpha value of the 24/32bit window.
580 // TODO: When the tbm queue of GlView is 24bit, do we have to set the alpha size??
581 configAttribs.PushBack(EGL_ALPHA_SIZE);
582 configAttribs.PushBack(8);
584 configAttribs.PushBack(EGL_DEPTH_SIZE);
585 configAttribs.PushBack(mDepthBufferRequired ? 24 : 0);
586 configAttribs.PushBack(EGL_STENCIL_SIZE);
587 configAttribs.PushBack(mStencilBufferRequired ? 8 : 0);
589 if(mMultiSamplingLevel != EGL_DONT_CARE)
591 configAttribs.PushBack(EGL_SAMPLES);
592 configAttribs.PushBack(mMultiSamplingLevel);
593 configAttribs.PushBack(EGL_SAMPLE_BUFFERS);
594 configAttribs.PushBack(1);
597 configAttribs.PushBack(EGL_NONE);
599 // Ensure number of configs is set to 1 as on some drivers,
600 // eglChooseConfig succeeds but does not actually create a proper configuration.
601 if((eglChooseConfig(mEglDisplay, &(configAttribs[0]), &mEglConfig, 1, &numConfigs) != EGL_TRUE) ||
604 if(mGlesVersion >= 30)
607 DALI_LOG_ERROR("Fail to use OpenGL es 3.0. Retrying to use OpenGL es 2.0.");
613 DALI_LOG_ERROR("No configurations found.\n");
615 TEST_EGL_ERROR("eglChooseConfig");
618 EGLint error = eglGetError();
621 case EGL_BAD_DISPLAY:
623 DALI_LOG_ERROR("Display is not an EGL display connection\n");
626 case EGL_BAD_ATTRIBUTE:
628 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");
631 case EGL_NOT_INITIALIZED:
633 DALI_LOG_ERROR("Display has not been initialized\n");
636 case EGL_BAD_PARAMETER:
638 DALI_LOG_ERROR("The parameter numConfig is NULL\n");
643 DALI_LOG_ERROR("Unknown error.\n");
646 DALI_ASSERT_ALWAYS(false && "eglChooseConfig failed!");
649 Integration::Log::LogMessage(Integration::Log::INFO, "Using OpenGL es %d.%d.\n", mGlesVersion / 10, mGlesVersion % 10);
651 mContextAttribs.Clear();
652 if(mIsKhrCreateContextSupported)
654 mContextAttribs.Reserve(5);
655 mContextAttribs.PushBack(EGL_CONTEXT_MAJOR_VERSION_KHR);
656 mContextAttribs.PushBack(mGlesVersion / 10);
657 mContextAttribs.PushBack(EGL_CONTEXT_MINOR_VERSION_KHR);
658 mContextAttribs.PushBack(mGlesVersion % 10);
662 mContextAttribs.Reserve(3);
663 mContextAttribs.PushBack(EGL_CONTEXT_CLIENT_VERSION);
664 mContextAttribs.PushBack(mGlesVersion / 10);
666 mContextAttribs.PushBack(EGL_NONE);
671 EGLSurface EglImplementation::CreateSurfaceWindow(EGLNativeWindowType window, ColorDepth depth)
673 mEglNativeWindow = window;
678 ChooseConfig(mIsWindow, mColorDepth);
680 mCurrentEglSurface = eglCreateWindowSurface(mEglDisplay, mEglConfig, mEglNativeWindow, NULL);
681 TEST_EGL_ERROR("eglCreateWindowSurface");
683 DALI_ASSERT_ALWAYS(mCurrentEglSurface && "Create window surface failed");
685 return mCurrentEglSurface;
688 EGLSurface EglImplementation::CreateSurfacePixmap(EGLNativePixmapType pixmap, ColorDepth depth)
690 mCurrentEglNativePixmap = pixmap;
695 ChooseConfig(mIsWindow, mColorDepth);
697 mCurrentEglSurface = eglCreatePixmapSurface(mEglDisplay, mEglConfig, mCurrentEglNativePixmap, NULL);
698 TEST_EGL_ERROR("eglCreatePixmapSurface");
700 DALI_ASSERT_ALWAYS(mCurrentEglSurface && "Create pixmap surface failed");
702 return mCurrentEglSurface;
705 bool EglImplementation::ReplaceSurfaceWindow(EGLNativeWindowType window, EGLSurface& eglSurface, EGLContext& eglContext)
707 bool contextLost = false;
709 // display connection has not changed, then we can just create a new surface
710 // the surface is bound to the context, so set the context to null
715 // destroy the surface
716 DestroySurface(eglSurface);
719 // create the EGL surface
720 EGLSurface newEglSurface = CreateSurfaceWindow(window, mColorDepth);
722 // set the context to be current with the new surface
723 MakeContextCurrent(newEglSurface, eglContext);
728 bool EglImplementation::ReplaceSurfacePixmap(EGLNativePixmapType pixmap, EGLSurface& eglSurface)
730 bool contextLost = false;
732 // display connection has not changed, then we can just create a new surface
733 // create the EGL surface
734 eglSurface = CreateSurfacePixmap(pixmap, mColorDepth);
736 // set the eglSurface to be current
737 MakeCurrent(pixmap, eglSurface);
742 void EglImplementation::SetGlesVersion(const int32_t glesVersion)
744 mGlesVersion = glesVersion;
747 void EglImplementation::SetFirstFrameAfterResume()
749 mSwapBufferCountAfterResume = 0;
752 EGLDisplay EglImplementation::GetDisplay() const
757 EGLContext EglImplementation::GetContext() const
762 int32_t EglImplementation::GetGlesVersion() const
767 bool EglImplementation::IsSurfacelessContextSupported() const
769 return mIsSurfacelessContextSupported;
772 void EglImplementation::WaitClient()
774 // Wait for EGL to finish executing all rendering calls for the current context
775 if(eglWaitClient() != EGL_TRUE)
777 TEST_EGL_ERROR("eglWaitClient");
781 bool EglImplementation::IsPartialUpdateRequired() const
783 return mPartialUpdateRequired;
786 } // namespace Adaptor
788 } // namespace Internal
792 #pragma GCC diagnostic pop