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 mGlesInitialized = true;
196 // We want to display this information all the time, so use the LogMessage directly
197 Integration::Log::LogMessage(Integration::Log::INFO,
199 " PartialUpdate %d\n"
204 mPartialUpdateRequired,
205 eglQueryString(mEglDisplay, EGL_VENDOR),
207 eglQueryString(mEglDisplay, EGL_CLIENT_APIS),
210 return mGlesInitialized;
213 bool EglImplementation::CreateContext()
215 // make sure a context isn't created twice
216 DALI_ASSERT_ALWAYS((mEglContext == 0) && "EGL context recreated");
218 mEglContext = eglCreateContext(mEglDisplay, mEglConfig, NULL, &(mContextAttribs[0]));
219 TEST_EGL_ERROR("eglCreateContext render thread");
221 DALI_ASSERT_ALWAYS(EGL_NO_CONTEXT != mEglContext && "EGL context not created");
223 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VENDOR : %s ***\n", glGetString(GL_VENDOR));
224 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_RENDERER : %s ***\n", glGetString(GL_RENDERER));
225 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VERSION : %s ***\n", glGetString(GL_VERSION));
226 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_SHADING_LANGUAGE_VERSION : %s***\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
227 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** Supported Extensions ***\n%s\n\n", glGetString(GL_EXTENSIONS));
229 mEglSetDamageRegionKHR = reinterpret_cast<PFNEGLSETDAMAGEREGIONKHRPROC>(eglGetProcAddress("eglSetDamageRegionKHR"));
230 if(!mEglSetDamageRegionKHR)
232 DALI_LOG_ERROR("Coudn't find eglSetDamageRegionKHR!\n");
233 mPartialUpdateRequired = false;
235 mEglSwapBuffersWithDamageKHR = reinterpret_cast<PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC>(eglGetProcAddress("eglSwapBuffersWithDamageKHR"));
236 if(!mEglSwapBuffersWithDamageKHR)
238 DALI_LOG_ERROR("Coudn't find eglSwapBuffersWithDamageKHR!\n");
239 mPartialUpdateRequired = false;
244 bool EglImplementation::CreateWindowContext(EGLContext& eglContext)
246 // make sure a context isn't created twice
247 DALI_ASSERT_ALWAYS((eglContext == 0) && "EGL context recreated");
249 eglContext = eglCreateContext(mEglDisplay, mEglConfig, mEglContext, &(mContextAttribs[0]));
250 TEST_EGL_ERROR("eglCreateContext render thread");
252 DALI_ASSERT_ALWAYS(EGL_NO_CONTEXT != eglContext && "EGL context not created");
254 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VENDOR : %s ***\n", glGetString(GL_VENDOR));
255 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_RENDERER : %s ***\n", glGetString(GL_RENDERER));
256 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VERSION : %s ***\n", glGetString(GL_VERSION));
257 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_SHADING_LANGUAGE_VERSION : %s***\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
258 DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** Supported Extensions ***\n%s\n\n", glGetString(GL_EXTENSIONS));
260 mEglWindowContexts.push_back(eglContext);
262 mEglSetDamageRegionKHR = reinterpret_cast<PFNEGLSETDAMAGEREGIONKHRPROC>(eglGetProcAddress("eglSetDamageRegionKHR"));
263 if(!mEglSetDamageRegionKHR)
265 DALI_LOG_ERROR("Coudn't find eglSetDamageRegionKHR!\n");
266 mPartialUpdateRequired = false;
268 mEglSwapBuffersWithDamageKHR = reinterpret_cast<PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC>(eglGetProcAddress("eglSwapBuffersWithDamageKHR"));
269 if(!mEglSwapBuffersWithDamageKHR)
271 DALI_LOG_ERROR("Coudn't find eglSwapBuffersWithDamageKHR!\n");
272 mPartialUpdateRequired = false;
277 void EglImplementation::DestroyContext(EGLContext& eglContext)
281 eglDestroyContext(mEglDisplay, eglContext);
286 void EglImplementation::DestroySurface(EGLSurface& eglSurface)
288 if(mIsOwnSurface && eglSurface)
290 // Make context null to prevent crash in driver side
292 eglDestroySurface(mEglDisplay, eglSurface);
297 void EglImplementation::MakeContextCurrent(EGLSurface eglSurface, EGLContext eglContext)
299 if(mCurrentEglContext == eglContext)
304 mCurrentEglSurface = eglSurface;
308 eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, eglContext);
310 mCurrentEglContext = eglContext;
313 EGLint error = eglGetError();
315 if(error != EGL_SUCCESS)
317 Egl::PrintError(error);
319 DALI_ASSERT_ALWAYS(false && "MakeContextCurrent failed!");
323 void EglImplementation::MakeCurrent(EGLNativePixmapType pixmap, EGLSurface eglSurface)
325 if(mCurrentEglContext == mEglContext)
330 mCurrentEglNativePixmap = pixmap;
331 mCurrentEglSurface = eglSurface;
335 eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, mEglContext);
337 mCurrentEglContext = mEglContext;
340 EGLint error = eglGetError();
342 if(error != EGL_SUCCESS)
344 Egl::PrintError(error);
346 DALI_ASSERT_ALWAYS(false && "MakeCurrent failed!");
350 void EglImplementation::MakeContextNull()
352 // clear the current context
353 eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
354 mCurrentEglContext = EGL_NO_CONTEXT;
357 void EglImplementation::TerminateGles()
361 // Make context null to prevent crash in driver side
364 for(auto eglSurface : mEglWindowSurfaces)
366 if(mIsOwnSurface && eglSurface)
368 eglDestroySurface(mEglDisplay, eglSurface);
371 eglDestroyContext(mEglDisplay, mEglContext);
372 for(auto eglContext : mEglWindowContexts)
374 eglDestroyContext(mEglDisplay, eglContext);
377 eglTerminate(mEglDisplay);
382 mCurrentEglSurface = NULL;
383 mCurrentEglContext = EGL_NO_CONTEXT;
385 mGlesInitialized = false;
389 bool EglImplementation::IsGlesInitialized() const
391 return mGlesInitialized;
394 void EglImplementation::SwapBuffers(EGLSurface& eglSurface)
396 if(eglSurface != EGL_NO_SURFACE) // skip if using surfaceless context
398 #ifndef DALI_PROFILE_UBUNTU
399 if(mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT)
401 DALI_LOG_RELEASE_INFO("EglImplementation::eglSwapBuffers started. eglSurface(%p)\n", eglSurface);
402 DALI_TRACE_BEGIN(gTraceFilter, "DALI_EGL_SWAP_BUFFERS");
404 #endif //DALI_PROFILE_UBUNTU
406 // DALI_LOG_ERROR("EglImplementation::SwapBuffers()\n");
407 eglSwapBuffers(mEglDisplay, eglSurface);
409 #ifndef DALI_PROFILE_UBUNTU
410 if(mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT)
412 DALI_TRACE_END(gTraceFilter, "DALI_EGL_SWAP_BUFFERS");
413 DALI_LOG_RELEASE_INFO("EglImplementation::eglSwapBuffers finished.\n");
414 mSwapBufferCountAfterResume++;
416 #endif //DALI_PROFILE_UBUNTU
420 EGLint EglImplementation::GetBufferAge(EGLSurface& eglSurface) const
422 static uint32_t logThreshold = GetPerformanceLogThresholdTime();
423 static bool logEnabled = logThreshold > 0 ? true : false;
425 uint32_t startTime, endTime;
428 startTime = TimeService::GetMilliSeconds();
432 eglQuerySurface(mEglDisplay, eglSurface, EGL_BUFFER_AGE_EXT, &age);
435 DALI_LOG_ERROR("eglQuerySurface(%d)\n", eglGetError());
441 endTime = TimeService::GetMilliSeconds();
442 if(endTime - startTime > logThreshold)
444 DALI_LOG_DEBUG_INFO("eglQuerySurface takes long time! [%u ms]\n", endTime - startTime);
450 void EglImplementation::SetDamageRegion(EGLSurface& eglSurface, std::vector<Rect<int>>& damagedRects)
452 if(!mPartialUpdateRequired)
457 if(eglSurface != EGL_NO_SURFACE) // skip if using surfaceless context
459 EGLBoolean result = mEglSetDamageRegionKHR(mEglDisplay, eglSurface, reinterpret_cast<int*>(damagedRects.data()), 1);
460 if(result == EGL_FALSE)
462 DALI_LOG_ERROR("eglSetDamageRegionKHR(0x%x)\n", eglGetError());
467 void EglImplementation::SwapBuffers(EGLSurface& eglSurface, const std::vector<Rect<int>>& damagedRects)
469 if(eglSurface != EGL_NO_SURFACE) // skip if using surfaceless context
471 if(!mPartialUpdateRequired)
473 SwapBuffers(eglSurface);
477 #ifndef DALI_PROFILE_UBUNTU
478 if(mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT)
480 DALI_LOG_RELEASE_INFO("EglImplementation::eglSwapBuffersWithDamageKHR started. eglSurface(%p)\n", eglSurface);
481 DALI_TRACE_BEGIN(gTraceFilter, "DALI_EGL_SWAP_BUFFERS_KHR");
483 #endif //DALI_PROFILE_UBUNTU
485 EGLBoolean result = mEglSwapBuffersWithDamageKHR(mEglDisplay, eglSurface, reinterpret_cast<int*>(const_cast<std::vector<Rect<int>>&>(damagedRects).data()), damagedRects.size());
486 if(result == EGL_FALSE)
488 DALI_LOG_ERROR("eglSwapBuffersWithDamageKHR(%d)\n", eglGetError());
491 #ifndef DALI_PROFILE_UBUNTU
492 if(mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT)
494 DALI_TRACE_END(gTraceFilter, "DALI_EGL_SWAP_BUFFERS_KHR");
495 DALI_LOG_RELEASE_INFO("EglImplementation::eglSwapBuffersWithDamageKHR finished.\n");
496 mSwapBufferCountAfterResume++;
498 #endif //DALI_PROFILE_UBUNTU
502 void EglImplementation::CopyBuffers(EGLSurface& eglSurface)
504 eglCopyBuffers(mEglDisplay, eglSurface, mCurrentEglNativePixmap);
507 void EglImplementation::WaitGL()
512 bool EglImplementation::ChooseConfig(bool isWindowType, ColorDepth depth)
514 if(mEglConfig && isWindowType == mIsWindow && mColorDepth == depth)
520 mIsWindow = isWindowType;
523 Vector<EGLint> configAttribs;
524 configAttribs.Reserve(31);
528 configAttribs.PushBack(EGL_SURFACE_TYPE);
529 configAttribs.PushBack(EGL_WINDOW_BIT);
533 configAttribs.PushBack(EGL_SURFACE_TYPE);
534 configAttribs.PushBack(EGL_PIXMAP_BIT);
537 configAttribs.PushBack(EGL_RENDERABLE_TYPE);
539 if(mGlesVersion >= 30)
541 configAttribs.PushBack(EGL_OPENGL_ES3_BIT_KHR);
545 configAttribs.PushBack(EGL_OPENGL_ES2_BIT);
548 // TODO: enable this flag when it becomes supported
549 // configAttribs.PushBack( EGL_CONTEXT_FLAGS_KHR );
550 // configAttribs.PushBack( EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR );
552 configAttribs.PushBack(EGL_RED_SIZE);
553 configAttribs.PushBack(8);
554 configAttribs.PushBack(EGL_GREEN_SIZE);
555 configAttribs.PushBack(8);
556 configAttribs.PushBack(EGL_BLUE_SIZE);
557 configAttribs.PushBack(8);
559 // For underlay video playback, we also need to set the alpha value of the 24/32bit window.
560 // TODO: When the tbm queue of GlView is 24bit, do we have to set the alpha size??
561 configAttribs.PushBack(EGL_ALPHA_SIZE);
562 configAttribs.PushBack(8);
564 configAttribs.PushBack(EGL_DEPTH_SIZE);
565 configAttribs.PushBack(mDepthBufferRequired ? 24 : 0);
566 configAttribs.PushBack(EGL_STENCIL_SIZE);
567 configAttribs.PushBack(mStencilBufferRequired ? 8 : 0);
569 #ifndef DALI_PROFILE_UBUNTU
570 if(mMultiSamplingLevel != EGL_DONT_CARE)
572 configAttribs.PushBack(EGL_SAMPLES);
573 configAttribs.PushBack(mMultiSamplingLevel);
574 configAttribs.PushBack(EGL_SAMPLE_BUFFERS);
575 configAttribs.PushBack(1);
577 #endif // DALI_PROFILE_UBUNTU
578 configAttribs.PushBack(EGL_NONE);
580 // Ensure number of configs is set to 1 as on some drivers,
581 // eglChooseConfig succeeds but does not actually create a proper configuration.
582 if((eglChooseConfig(mEglDisplay, &(configAttribs[0]), &mEglConfig, 1, &numConfigs) != EGL_TRUE) ||
585 if(mGlesVersion >= 30)
588 DALI_LOG_ERROR("Fail to use OpenGL es 3.0. Retrying to use OpenGL es 2.0.");
594 DALI_LOG_ERROR("No configurations found.\n");
596 TEST_EGL_ERROR("eglChooseConfig");
599 EGLint error = eglGetError();
602 case EGL_BAD_DISPLAY:
604 DALI_LOG_ERROR("Display is not an EGL display connection\n");
607 case EGL_BAD_ATTRIBUTE:
609 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");
612 case EGL_NOT_INITIALIZED:
614 DALI_LOG_ERROR("Display has not been initialized\n");
617 case EGL_BAD_PARAMETER:
619 DALI_LOG_ERROR("The parameter numConfig is NULL\n");
624 DALI_LOG_ERROR("Unknown error.\n");
627 DALI_ASSERT_ALWAYS(false && "eglChooseConfig failed!");
630 Integration::Log::LogMessage(Integration::Log::INFO, "Using OpenGL es %d.%d.\n", mGlesVersion / 10, mGlesVersion % 10);
632 mContextAttribs.Clear();
633 if(mIsKhrCreateContextSupported)
635 mContextAttribs.Reserve(5);
636 mContextAttribs.PushBack(EGL_CONTEXT_MAJOR_VERSION_KHR);
637 mContextAttribs.PushBack(mGlesVersion / 10);
638 mContextAttribs.PushBack(EGL_CONTEXT_MINOR_VERSION_KHR);
639 mContextAttribs.PushBack(mGlesVersion % 10);
643 mContextAttribs.Reserve(3);
644 mContextAttribs.PushBack(EGL_CONTEXT_CLIENT_VERSION);
645 mContextAttribs.PushBack(mGlesVersion / 10);
647 mContextAttribs.PushBack(EGL_NONE);
652 EGLSurface EglImplementation::CreateSurfaceWindow(EGLNativeWindowType window, ColorDepth depth)
654 mEglNativeWindow = window;
659 ChooseConfig(mIsWindow, mColorDepth);
661 mCurrentEglSurface = eglCreateWindowSurface(mEglDisplay, mEglConfig, mEglNativeWindow, NULL);
662 TEST_EGL_ERROR("eglCreateWindowSurface");
664 DALI_ASSERT_ALWAYS(mCurrentEglSurface && "Create window surface failed");
666 return mCurrentEglSurface;
669 EGLSurface EglImplementation::CreateSurfacePixmap(EGLNativePixmapType pixmap, ColorDepth depth)
671 mCurrentEglNativePixmap = pixmap;
676 ChooseConfig(mIsWindow, mColorDepth);
678 mCurrentEglSurface = eglCreatePixmapSurface(mEglDisplay, mEglConfig, mCurrentEglNativePixmap, NULL);
679 TEST_EGL_ERROR("eglCreatePixmapSurface");
681 DALI_ASSERT_ALWAYS(mCurrentEglSurface && "Create pixmap surface failed");
683 return mCurrentEglSurface;
686 bool EglImplementation::ReplaceSurfaceWindow(EGLNativeWindowType window, EGLSurface& eglSurface, EGLContext& eglContext)
688 bool contextLost = false;
690 // display connection has not changed, then we can just create a new surface
691 // the surface is bound to the context, so set the context to null
696 // destroy the surface
697 DestroySurface(eglSurface);
700 // create the EGL surface
701 EGLSurface newEglSurface = CreateSurfaceWindow(window, mColorDepth);
703 // set the context to be current with the new surface
704 MakeContextCurrent(newEglSurface, eglContext);
709 bool EglImplementation::ReplaceSurfacePixmap(EGLNativePixmapType pixmap, EGLSurface& eglSurface)
711 bool contextLost = false;
713 // display connection has not changed, then we can just create a new surface
714 // create the EGL surface
715 eglSurface = CreateSurfacePixmap(pixmap, mColorDepth);
717 // set the eglSurface to be current
718 MakeCurrent(pixmap, eglSurface);
723 void EglImplementation::SetGlesVersion(const int32_t glesVersion)
725 mGlesVersion = glesVersion;
728 void EglImplementation::SetFirstFrameAfterResume()
730 mSwapBufferCountAfterResume = 0;
733 EGLDisplay EglImplementation::GetDisplay() const
738 EGLContext EglImplementation::GetContext() const
743 int32_t EglImplementation::GetGlesVersion() const
748 bool EglImplementation::IsSurfacelessContextSupported() const
750 return mIsSurfacelessContextSupported;
753 void EglImplementation::WaitClient()
755 // Wait for EGL to finish executing all rendering calls for the current context
756 if(eglWaitClient() != EGL_TRUE)
758 TEST_EGL_ERROR("eglWaitClient");
762 bool EglImplementation::IsPartialUpdateRequired() const
764 return mPartialUpdateRequired;
767 } // namespace Adaptor
769 } // namespace Internal
773 #pragma GCC diagnostic pop