egl_manager.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. /**************************************************************************/
  2. /* egl_manager.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #include "egl_manager.h"
  31. #include "core/crypto/crypto_core.h"
  32. #include "core/io/dir_access.h"
  33. #include "core/io/file_access.h"
  34. #include "drivers/gles3/rasterizer_gles3.h"
  35. #ifdef EGL_ENABLED
  36. #if defined(EGL_STATIC)
  37. #define GLAD_EGL_VERSION_1_5 true
  38. #ifdef EGL_EXT_platform_base
  39. #define GLAD_EGL_EXT_platform_base 1
  40. #endif
  41. #define KHRONOS_STATIC 1
  42. extern "C" EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get);
  43. extern "C" EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplayEXT(EGLenum platform, void *native_display, const EGLint *attrib_list);
  44. #undef KHRONOS_STATIC
  45. #endif // defined(EGL_STATIC)
  46. #ifndef EGL_EXT_platform_base
  47. #define GLAD_EGL_EXT_platform_base 0
  48. #endif
  49. #ifdef WINDOWS_ENABLED
  50. // Unofficial ANGLE extension: EGL_ANGLE_surface_orientation
  51. #ifndef EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE
  52. #define EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE 0x33A7
  53. #define EGL_SURFACE_ORIENTATION_ANGLE 0x33A8
  54. #define EGL_SURFACE_ORIENTATION_INVERT_X_ANGLE 0x0001
  55. #define EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE 0x0002
  56. #endif
  57. #endif
  58. // Creates and caches a GLDisplay. Returns -1 on error.
  59. int EGLManager::_get_gldisplay_id(void *p_display) {
  60. // Look for a cached GLDisplay.
  61. for (unsigned int i = 0; i < displays.size(); i++) {
  62. if (displays[i].display == p_display) {
  63. return i;
  64. }
  65. }
  66. // We didn't find any, so we'll have to create one, along with its own
  67. // EGLDisplay and EGLContext.
  68. GLDisplay new_gldisplay;
  69. new_gldisplay.display = p_display;
  70. if (GLAD_EGL_VERSION_1_5) {
  71. Vector<EGLAttrib> attribs = _get_platform_display_attributes();
  72. new_gldisplay.egl_display = eglGetPlatformDisplay(_get_platform_extension_enum(), new_gldisplay.display, (attribs.size() > 0) ? attribs.ptr() : nullptr);
  73. } else if (GLAD_EGL_EXT_platform_base) {
  74. #ifdef EGL_EXT_platform_base
  75. // eglGetPlatformDisplayEXT wants its attributes as EGLint, so we'll truncate
  76. // what we already have. It's a bit naughty but I'm really not sure what else
  77. // we could do here.
  78. Vector<EGLint> attribs;
  79. for (const EGLAttrib &attrib : _get_platform_display_attributes()) {
  80. attribs.push_back((EGLint)attrib);
  81. }
  82. new_gldisplay.egl_display = eglGetPlatformDisplayEXT(_get_platform_extension_enum(), new_gldisplay.display, (attribs.size() > 0) ? attribs.ptr() : nullptr);
  83. #endif // EGL_EXT_platform_base
  84. } else {
  85. NativeDisplayType *native_display_type = (NativeDisplayType *)new_gldisplay.display;
  86. new_gldisplay.egl_display = eglGetDisplay(*native_display_type);
  87. }
  88. ERR_FAIL_COND_V(eglGetError() != EGL_SUCCESS, -1);
  89. ERR_FAIL_COND_V_MSG(new_gldisplay.egl_display == EGL_NO_DISPLAY, -1, "Can't create an EGL display.");
  90. if (!eglInitialize(new_gldisplay.egl_display, nullptr, nullptr)) {
  91. ERR_FAIL_V_MSG(-1, "Can't initialize an EGL display.");
  92. }
  93. if (!eglBindAPI(_get_platform_api_enum())) {
  94. ERR_FAIL_V_MSG(-1, "OpenGL not supported.");
  95. }
  96. Error err = _gldisplay_create_context(new_gldisplay);
  97. if (err != OK) {
  98. eglTerminate(new_gldisplay.egl_display);
  99. ERR_FAIL_V(-1);
  100. }
  101. #ifdef EGL_ANDROID_blob_cache
  102. #if defined(EGL_STATIC)
  103. bool has_blob_cache = true;
  104. #else
  105. bool has_blob_cache = (eglSetBlobCacheFuncsANDROID != nullptr);
  106. #endif
  107. if (has_blob_cache && !shader_cache_dir.is_empty()) {
  108. eglSetBlobCacheFuncsANDROID(new_gldisplay.egl_display, &EGLManager::_set_cache, &EGLManager::_get_cache);
  109. }
  110. #endif
  111. #ifdef WINDOWS_ENABLED
  112. String client_extensions_string = eglQueryString(new_gldisplay.egl_display, EGL_EXTENSIONS);
  113. if (eglGetError() == EGL_SUCCESS) {
  114. Vector<String> egl_extensions = client_extensions_string.split(" ");
  115. if (egl_extensions.has("EGL_ANGLE_surface_orientation")) {
  116. new_gldisplay.has_EGL_ANGLE_surface_orientation = true;
  117. print_verbose("EGL: EGL_ANGLE_surface_orientation is supported.");
  118. }
  119. }
  120. #endif
  121. displays.push_back(new_gldisplay);
  122. // Return the new GLDisplay's ID.
  123. return displays.size() - 1;
  124. }
  125. #ifdef EGL_ANDROID_blob_cache
  126. String EGLManager::shader_cache_dir;
  127. void EGLManager::_set_cache(const void *p_key, EGLsizeiANDROID p_key_size, const void *p_value, EGLsizeiANDROID p_value_size) {
  128. String name = CryptoCore::b64_encode_str((const uint8_t *)p_key, p_key_size).replace_char('/', '_');
  129. String path = shader_cache_dir.path_join(name) + ".cache";
  130. Error err = OK;
  131. Ref<FileAccess> file = FileAccess::open(path, FileAccess::WRITE, &err);
  132. if (err != OK) {
  133. return;
  134. }
  135. file->store_buffer((const uint8_t *)p_value, p_value_size);
  136. }
  137. EGLsizeiANDROID EGLManager::_get_cache(const void *p_key, EGLsizeiANDROID p_key_size, void *p_value, EGLsizeiANDROID p_value_size) {
  138. String name = CryptoCore::b64_encode_str((const uint8_t *)p_key, p_key_size).replace_char('/', '_');
  139. String path = shader_cache_dir.path_join(name) + ".cache";
  140. Error err = OK;
  141. Ref<FileAccess> file = FileAccess::open(path, FileAccess::READ, &err);
  142. if (err != OK) {
  143. return 0;
  144. }
  145. EGLsizeiANDROID len = file->get_length();
  146. if (len <= p_value_size) {
  147. file->get_buffer((uint8_t *)p_value, len);
  148. }
  149. return len;
  150. }
  151. #endif
  152. Error EGLManager::_gldisplay_create_context(GLDisplay &p_gldisplay) {
  153. EGLint attribs[] = {
  154. EGL_RED_SIZE,
  155. 1,
  156. EGL_BLUE_SIZE,
  157. 1,
  158. EGL_GREEN_SIZE,
  159. 1,
  160. EGL_DEPTH_SIZE,
  161. 24,
  162. EGL_NONE,
  163. };
  164. EGLint attribs_layered[] = {
  165. EGL_RED_SIZE,
  166. 8,
  167. EGL_GREEN_SIZE,
  168. 8,
  169. EGL_GREEN_SIZE,
  170. 8,
  171. EGL_ALPHA_SIZE,
  172. 8,
  173. EGL_DEPTH_SIZE,
  174. 24,
  175. EGL_NONE,
  176. };
  177. EGLint config_count = 0;
  178. if (OS::get_singleton()->is_layered_allowed()) {
  179. eglChooseConfig(p_gldisplay.egl_display, attribs_layered, &p_gldisplay.egl_config, 1, &config_count);
  180. } else {
  181. eglChooseConfig(p_gldisplay.egl_display, attribs, &p_gldisplay.egl_config, 1, &config_count);
  182. }
  183. ERR_FAIL_COND_V(eglGetError() != EGL_SUCCESS, ERR_BUG);
  184. ERR_FAIL_COND_V(config_count == 0, ERR_UNCONFIGURED);
  185. Vector<EGLint> context_attribs = _get_platform_context_attribs();
  186. p_gldisplay.egl_context = eglCreateContext(p_gldisplay.egl_display, p_gldisplay.egl_config, EGL_NO_CONTEXT, (context_attribs.size() > 0) ? context_attribs.ptr() : nullptr);
  187. ERR_FAIL_COND_V_MSG(p_gldisplay.egl_context == EGL_NO_CONTEXT, ERR_CANT_CREATE, vformat("Can't create an EGL context. Error code: %d", eglGetError()));
  188. return OK;
  189. }
  190. Error EGLManager::open_display(void *p_display) {
  191. int gldisplay_id = _get_gldisplay_id(p_display);
  192. if (gldisplay_id < 0) {
  193. return ERR_CANT_CREATE;
  194. } else {
  195. return OK;
  196. }
  197. }
  198. int EGLManager::display_get_native_visual_id(void *p_display) {
  199. int gldisplay_id = _get_gldisplay_id(p_display);
  200. ERR_FAIL_COND_V(gldisplay_id < 0, ERR_CANT_CREATE);
  201. GLDisplay gldisplay = displays[gldisplay_id];
  202. EGLint native_visual_id = -1;
  203. if (!eglGetConfigAttrib(gldisplay.egl_display, gldisplay.egl_config, EGL_NATIVE_VISUAL_ID, &native_visual_id)) {
  204. ERR_FAIL_V(-1);
  205. }
  206. return native_visual_id;
  207. }
  208. Error EGLManager::window_create(DisplayServer::WindowID p_window_id, void *p_display, void *p_native_window, int p_width, int p_height) {
  209. int gldisplay_id = _get_gldisplay_id(p_display);
  210. ERR_FAIL_COND_V(gldisplay_id < 0, ERR_CANT_CREATE);
  211. GLDisplay &gldisplay = displays[gldisplay_id];
  212. // In order to ensure a fast lookup, make sure we got enough elements in the
  213. // windows local vector to use the window id as an index.
  214. if (p_window_id >= (int)windows.size()) {
  215. windows.resize(p_window_id + 1);
  216. }
  217. GLWindow &glwindow = windows[p_window_id];
  218. glwindow.gldisplay_id = gldisplay_id;
  219. Vector<EGLAttrib> egl_attribs;
  220. #ifdef WINDOWS_ENABLED
  221. if (gldisplay.has_EGL_ANGLE_surface_orientation) {
  222. EGLint optimal_orientation;
  223. if (eglGetConfigAttrib(gldisplay.egl_display, gldisplay.egl_config, EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE, &optimal_orientation)) {
  224. // We only need to support inverting Y for optimizing ANGLE on D3D11.
  225. if (optimal_orientation & EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE && !(optimal_orientation & EGL_SURFACE_ORIENTATION_INVERT_X_ANGLE)) {
  226. egl_attribs.push_back(EGL_SURFACE_ORIENTATION_ANGLE);
  227. egl_attribs.push_back(EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE);
  228. }
  229. } else {
  230. ERR_PRINT(vformat("Failed to get EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE, error: 0x%08X", eglGetError()));
  231. }
  232. }
  233. if (!egl_attribs.is_empty()) {
  234. egl_attribs.push_back(EGL_NONE);
  235. }
  236. #endif
  237. if (GLAD_EGL_VERSION_1_5) {
  238. glwindow.egl_surface = eglCreatePlatformWindowSurface(gldisplay.egl_display, gldisplay.egl_config, p_native_window, egl_attribs.ptr());
  239. } else {
  240. EGLNativeWindowType *native_window_type = (EGLNativeWindowType *)p_native_window;
  241. glwindow.egl_surface = eglCreateWindowSurface(gldisplay.egl_display, gldisplay.egl_config, *native_window_type, nullptr);
  242. }
  243. if (glwindow.egl_surface == EGL_NO_SURFACE) {
  244. return ERR_CANT_CREATE;
  245. }
  246. glwindow.initialized = true;
  247. #ifdef WINDOWS_ENABLED
  248. if (gldisplay.has_EGL_ANGLE_surface_orientation) {
  249. EGLint orientation;
  250. if (eglQuerySurface(gldisplay.egl_display, glwindow.egl_surface, EGL_SURFACE_ORIENTATION_ANGLE, &orientation)) {
  251. if (orientation & EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE && !(orientation & EGL_SURFACE_ORIENTATION_INVERT_X_ANGLE)) {
  252. glwindow.flipped_y = true;
  253. print_verbose("EGL: Using optimal surface orientation: Invert Y");
  254. }
  255. } else {
  256. ERR_PRINT(vformat("Failed to get EGL_SURFACE_ORIENTATION_ANGLE, error: 0x%08X", eglGetError()));
  257. }
  258. }
  259. #endif
  260. window_make_current(p_window_id);
  261. return OK;
  262. }
  263. void EGLManager::window_destroy(DisplayServer::WindowID p_window_id) {
  264. ERR_FAIL_INDEX(p_window_id, (int)windows.size());
  265. GLWindow &glwindow = windows[p_window_id];
  266. if (!glwindow.initialized) {
  267. return;
  268. }
  269. glwindow.initialized = false;
  270. ERR_FAIL_INDEX(glwindow.gldisplay_id, (int)displays.size());
  271. GLDisplay &gldisplay = displays[glwindow.gldisplay_id];
  272. if (glwindow.egl_surface != EGL_NO_SURFACE) {
  273. eglDestroySurface(gldisplay.egl_display, glwindow.egl_surface);
  274. glwindow.egl_surface = nullptr;
  275. }
  276. }
  277. void EGLManager::release_current() {
  278. if (!current_window) {
  279. return;
  280. }
  281. GLDisplay &current_display = displays[current_window->gldisplay_id];
  282. eglMakeCurrent(current_display.egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
  283. }
  284. void EGLManager::swap_buffers() {
  285. if (!current_window) {
  286. return;
  287. }
  288. if (!current_window->initialized) {
  289. WARN_PRINT("Current OpenGL window is uninitialized!");
  290. return;
  291. }
  292. GLDisplay &current_display = displays[current_window->gldisplay_id];
  293. eglSwapBuffers(current_display.egl_display, current_window->egl_surface);
  294. }
  295. void EGLManager::window_make_current(DisplayServer::WindowID p_window_id) {
  296. if (p_window_id == DisplayServer::INVALID_WINDOW_ID) {
  297. return;
  298. }
  299. GLWindow &glwindow = windows[p_window_id];
  300. if (&glwindow == current_window || !glwindow.initialized) {
  301. return;
  302. }
  303. current_window = &glwindow;
  304. GLDisplay &current_display = displays[current_window->gldisplay_id];
  305. eglMakeCurrent(current_display.egl_display, current_window->egl_surface, current_window->egl_surface, current_display.egl_context);
  306. #ifdef WINDOWS_ENABLED
  307. RasterizerGLES3::set_screen_flipped_y(glwindow.flipped_y);
  308. #endif
  309. }
  310. void EGLManager::set_use_vsync(bool p_use) {
  311. // We need an active window to get a display to set the vsync.
  312. if (!current_window) {
  313. return;
  314. }
  315. GLDisplay &disp = displays[current_window->gldisplay_id];
  316. int swap_interval = p_use ? 1 : 0;
  317. if (!eglSwapInterval(disp.egl_display, swap_interval)) {
  318. WARN_PRINT("Could not set V-Sync mode.");
  319. }
  320. use_vsync = p_use;
  321. }
  322. bool EGLManager::is_using_vsync() const {
  323. return use_vsync;
  324. }
  325. EGLContext EGLManager::get_context(DisplayServer::WindowID p_window_id) {
  326. GLWindow &glwindow = windows[p_window_id];
  327. if (!glwindow.initialized) {
  328. return EGL_NO_CONTEXT;
  329. }
  330. GLDisplay &display = displays[glwindow.gldisplay_id];
  331. return display.egl_context;
  332. }
  333. EGLDisplay EGLManager::get_display(DisplayServer::WindowID p_window_id) {
  334. GLWindow &glwindow = windows[p_window_id];
  335. if (!glwindow.initialized) {
  336. return EGL_NO_CONTEXT;
  337. }
  338. GLDisplay &display = displays[glwindow.gldisplay_id];
  339. return display.egl_display;
  340. }
  341. EGLConfig EGLManager::get_config(DisplayServer::WindowID p_window_id) {
  342. GLWindow &glwindow = windows[p_window_id];
  343. if (!glwindow.initialized) {
  344. return nullptr;
  345. }
  346. GLDisplay &display = displays[glwindow.gldisplay_id];
  347. return display.egl_config;
  348. }
  349. Error EGLManager::initialize(void *p_native_display) {
  350. #if defined(GLAD_ENABLED) && !defined(EGL_STATIC)
  351. // Loading EGL with a new display gets us just the bare minimum API. We'll then
  352. // have to temporarily get a proper display and reload EGL once again to
  353. // initialize everything else.
  354. if (!gladLoaderLoadEGL(EGL_NO_DISPLAY)) {
  355. ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Can't load EGL dynamic library.");
  356. }
  357. EGLDisplay tmp_display = EGL_NO_DISPLAY;
  358. if (GLAD_EGL_EXT_platform_base) {
  359. #ifdef EGL_EXT_platform_base
  360. // eglGetPlatformDisplayEXT wants its attributes as EGLint.
  361. Vector<EGLint> attribs;
  362. for (const EGLAttrib &attrib : _get_platform_display_attributes()) {
  363. attribs.push_back((EGLint)attrib);
  364. }
  365. tmp_display = eglGetPlatformDisplayEXT(_get_platform_extension_enum(), p_native_display, attribs.ptr());
  366. #endif // EGL_EXT_platform_base
  367. } else {
  368. WARN_PRINT("EGL: EGL_EXT_platform_base not found during init, using default platform.");
  369. EGLNativeDisplayType *native_display_type = (EGLNativeDisplayType *)p_native_display;
  370. tmp_display = eglGetDisplay(*native_display_type);
  371. }
  372. if (tmp_display == EGL_NO_DISPLAY) {
  373. eglTerminate(tmp_display);
  374. ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Can't get a valid initial EGL display.");
  375. }
  376. eglInitialize(tmp_display, nullptr, nullptr);
  377. int version = gladLoaderLoadEGL(tmp_display);
  378. if (!version) {
  379. eglTerminate(tmp_display);
  380. ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Can't load EGL dynamic library.");
  381. }
  382. int major = GLAD_VERSION_MAJOR(version);
  383. int minor = GLAD_VERSION_MINOR(version);
  384. print_verbose(vformat("Loaded EGL %d.%d", major, minor));
  385. ERR_FAIL_COND_V_MSG(!GLAD_EGL_VERSION_1_4, ERR_UNAVAILABLE, vformat("EGL version is too old! %d.%d < 1.4", major, minor));
  386. eglTerminate(tmp_display);
  387. #endif
  388. #ifdef EGL_ANDROID_blob_cache
  389. shader_cache_dir = Engine::get_singleton()->get_shader_cache_path();
  390. if (shader_cache_dir.is_empty()) {
  391. shader_cache_dir = "user://";
  392. }
  393. Error err = OK;
  394. Ref<DirAccess> da = DirAccess::open(shader_cache_dir);
  395. if (da.is_null()) {
  396. ERR_PRINT("EGL: Can't create shader cache folder, no shader caching will happen: " + shader_cache_dir);
  397. shader_cache_dir = String();
  398. } else {
  399. err = da->change_dir(String("shader_cache").path_join("EGL"));
  400. if (err != OK) {
  401. err = da->make_dir_recursive(String("shader_cache").path_join("EGL"));
  402. }
  403. if (err != OK) {
  404. ERR_PRINT("EGL: Can't create shader cache folder, no shader caching will happen: " + shader_cache_dir);
  405. shader_cache_dir = String();
  406. } else {
  407. shader_cache_dir = shader_cache_dir.path_join(String("shader_cache").path_join("EGL"));
  408. }
  409. }
  410. #endif
  411. String client_extensions_string = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
  412. // If the above method fails, we don't support client extensions, so there's nothing to check.
  413. if (eglGetError() == EGL_SUCCESS) {
  414. const char *platform = _get_platform_extension_name();
  415. if (!client_extensions_string.split(" ").has(platform)) {
  416. ERR_FAIL_V_MSG(ERR_UNAVAILABLE, vformat("EGL platform extension \"%s\" not found.", platform));
  417. }
  418. }
  419. return OK;
  420. }
  421. EGLManager::EGLManager() {
  422. }
  423. EGLManager::~EGLManager() {
  424. for (unsigned int i = 0; i < displays.size(); i++) {
  425. eglTerminate(displays[i].egl_display);
  426. }
  427. }
  428. #endif // EGL_ENABLED