summaryrefslogtreecommitdiff
path: root/Source/3rdParty/SDL2/src/video/SDL_egl.c
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-01-31 18:38:35 +0800
committerchai <chaifix@163.com>2019-01-31 18:38:35 +0800
commit2ec55fd974a63b705a4777c256d2222c874fa043 (patch)
tree48f1fea59ee9fc713a28a9aac3f05b98dc5ae66f /Source/3rdParty/SDL2/src/video/SDL_egl.c
parentc581dfbf1e849f393861d15e82aa6446c0c1c310 (diff)
*SDL project
Diffstat (limited to 'Source/3rdParty/SDL2/src/video/SDL_egl.c')
-rw-r--r--Source/3rdParty/SDL2/src/video/SDL_egl.c88
1 files changed, 85 insertions, 3 deletions
diff --git a/Source/3rdParty/SDL2/src/video/SDL_egl.c b/Source/3rdParty/SDL2/src/video/SDL_egl.c
index 0daf98a..78abc03 100644
--- a/Source/3rdParty/SDL2/src/video/SDL_egl.c
+++ b/Source/3rdParty/SDL2/src/video/SDL_egl.c
@@ -406,6 +406,9 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
}
}
+ _this->egl_data->egl_version_major = egl_version_major;
+ _this->egl_data->egl_version_minor = egl_version_minor;
+
if (egl_version_major == 1 && egl_version_minor == 5) {
LOAD_FUNC(eglGetPlatformDisplay);
}
@@ -446,6 +449,64 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
return 0;
}
+#ifdef DUMP_EGL_CONFIG
+
+#define ATTRIBUTE(_attr) { _attr, #_attr }
+
+typedef struct {
+ EGLint attribute;
+ char const* name;
+} Attribute;
+
+Attribute attributes[] = {
+ ATTRIBUTE( EGL_BUFFER_SIZE ),
+ ATTRIBUTE( EGL_ALPHA_SIZE ),
+ ATTRIBUTE( EGL_BLUE_SIZE ),
+ ATTRIBUTE( EGL_GREEN_SIZE ),
+ ATTRIBUTE( EGL_RED_SIZE ),
+ ATTRIBUTE( EGL_DEPTH_SIZE ),
+ ATTRIBUTE( EGL_STENCIL_SIZE ),
+ ATTRIBUTE( EGL_CONFIG_CAVEAT ),
+ ATTRIBUTE( EGL_CONFIG_ID ),
+ ATTRIBUTE( EGL_LEVEL ),
+ ATTRIBUTE( EGL_MAX_PBUFFER_HEIGHT ),
+ ATTRIBUTE( EGL_MAX_PBUFFER_WIDTH ),
+ ATTRIBUTE( EGL_MAX_PBUFFER_PIXELS ),
+ ATTRIBUTE( EGL_NATIVE_RENDERABLE ),
+ ATTRIBUTE( EGL_NATIVE_VISUAL_ID ),
+ ATTRIBUTE( EGL_NATIVE_VISUAL_TYPE ),
+ ATTRIBUTE( EGL_SAMPLES ),
+ ATTRIBUTE( EGL_SAMPLE_BUFFERS ),
+ ATTRIBUTE( EGL_SURFACE_TYPE ),
+ ATTRIBUTE( EGL_TRANSPARENT_TYPE ),
+ ATTRIBUTE( EGL_TRANSPARENT_BLUE_VALUE ),
+ ATTRIBUTE( EGL_TRANSPARENT_GREEN_VALUE ),
+ ATTRIBUTE( EGL_TRANSPARENT_RED_VALUE ),
+ ATTRIBUTE( EGL_BIND_TO_TEXTURE_RGB ),
+ ATTRIBUTE( EGL_BIND_TO_TEXTURE_RGBA ),
+ ATTRIBUTE( EGL_MIN_SWAP_INTERVAL ),
+ ATTRIBUTE( EGL_MAX_SWAP_INTERVAL ),
+ ATTRIBUTE( EGL_LUMINANCE_SIZE ),
+ ATTRIBUTE( EGL_ALPHA_MASK_SIZE ),
+ ATTRIBUTE( EGL_COLOR_BUFFER_TYPE ),
+ ATTRIBUTE( EGL_RENDERABLE_TYPE ),
+ ATTRIBUTE( EGL_MATCH_NATIVE_PIXMAP ),
+ ATTRIBUTE( EGL_CONFORMANT ),
+};
+
+
+static void dumpconfig(_THIS, EGLConfig config)
+{
+ int attr;
+ for (attr = 0 ; attr<sizeof(attributes)/sizeof(Attribute) ; attr++) {
+ EGLint value;
+ _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, config, attributes[attr].attribute, &value);
+ SDL_Log("\t%-32s: %10d (0x%08x)\n", attributes[attr].name, value, value);
+ }
+}
+
+#endif /* DUMP_EGL_CONFIG */
+
int
SDL_EGL_ChooseConfig(_THIS)
{
@@ -570,6 +631,10 @@ SDL_EGL_ChooseConfig(_THIS)
break; /* we found an exact match! */
}
}
+
+#ifdef DUMP_EGL_CONFIG
+ dumpconfig(_this, _this->egl_data->egl_config);
+#endif
return 0;
}
@@ -596,6 +661,24 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
share_context = (EGLContext)SDL_GL_GetCurrentContext();
}
+#if SDL_VIDEO_DRIVER_ANDROID
+ if ((_this->gl_config.flags & SDL_GL_CONTEXT_DEBUG_FLAG) != 0) {
+ /* If SDL_GL_CONTEXT_DEBUG_FLAG is set but EGL_KHR_debug unsupported, unset.
+ * This is required because some Android devices like to complain about it
+ * by "silently" failing, logging a hint which could be easily overlooked:
+ * E/libEGL (26984): validate_display:255 error 3008 (EGL_BAD_DISPLAY)
+ * The following explicitly checks for EGL_KHR_debug before EGL 1.5
+ */
+ int egl_version_major = _this->egl_data->egl_version_major;
+ int egl_version_minor = _this->egl_data->egl_version_minor;
+ if (((egl_version_major < 1) || (egl_version_major == 1 && egl_version_minor < 5)) &&
+ !SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_debug")) {
+ /* SDL profile bits match EGL profile bits. */
+ _this->gl_config.flags &= ~SDL_GL_CONTEXT_DEBUG_FLAG;
+ }
+ }
+#endif
+
/* Set the context version and other attributes. */
if ((major_version < 3 || (minor_version == 0 && profile_es)) &&
_this->gl_config.flags == 0 &&
@@ -763,7 +846,6 @@ SDL_EGL_DeleteContext(_THIS, SDL_GLContext context)
}
if (egl_context != NULL && egl_context != EGL_NO_CONTEXT) {
- SDL_EGL_MakeCurrent(_this, NULL, NULL);
_this->egl_data->eglDestroyContext(_this->egl_data->egl_display, egl_context);
}
@@ -775,7 +857,7 @@ SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
/* max 2 values plus terminator. */
EGLint attribs[3];
int attr = 0;
-
+
EGLSurface * surface;
if (SDL_EGL_ChooseConfig(_this) != 0) {
@@ -807,7 +889,7 @@ SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
return EGL_NO_SURFACE;
}
}
-
+
attribs[attr++] = EGL_NONE;
surface = _this->egl_data->eglCreateWindowSurface(