Fixed using uninitialized display data in iMX6 initialization
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
diff --git a/src/video/mx6/SDL_mx6opengles.c b/src/video/mx6/SDL_mx6opengles.c
index 375a14a..1e51375 100644
--- a/src/video/mx6/SDL_mx6opengles.c
+++ b/src/video/mx6/SDL_mx6opengles.c
@@ -48,12 +48,12 @@ if (!egl_viv_data->NAME) \
/* EGL implementation of SDL OpenGL support */
int
-MX6_GLES_LoadLibrary(_THIS, const char *egl_path) {
+MX6_GLES_LoadLibrary(_THIS, const char *egl_path)
+{
/* The definitions of egl_dll_handle and dll_handle were interchanged for some reason.
Just left them as is for compatibility */
void *dll_handle = NULL, *egl_dll_handle = NULL;
char *path = NULL;
- SDL_DisplayData *displaydata;
if (_this->egl_data) {
return SDL_SetError("OpenGL ES context already created");
@@ -75,7 +75,7 @@ MX6_GLES_LoadLibrary(_THIS, const char *egl_path) {
}
if (egl_dll_handle == NULL) {
- if(_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
+ if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
if (_this->gl_config.major_version > 1) {
path = DEFAULT_OGL_ES2;
egl_dll_handle = SDL_LoadObject(path);
@@ -84,11 +84,11 @@ MX6_GLES_LoadLibrary(_THIS, const char *egl_path) {
path = DEFAULT_OGL_ES;
egl_dll_handle = SDL_LoadObject(path);
}
- }
+ }
else {
path = DEFAULT_OGL;
egl_dll_handle = SDL_LoadObject(path);
- }
+ }
}
_this->egl_data->egl_dll_handle = egl_dll_handle;
@@ -98,8 +98,8 @@ MX6_GLES_LoadLibrary(_THIS, const char *egl_path) {
if (egl_path != NULL) {
dll_handle = SDL_LoadObject(egl_path);
- }
-
+ }
+
if (SDL_LoadFunction(dll_handle, "eglChooseConfig") == NULL) {
if (dll_handle != NULL) {
SDL_UnloadObject(dll_handle);
@@ -148,20 +148,16 @@ MX6_GLES_LoadLibrary(_THIS, const char *egl_path) {
LOAD_VIV_FUNC(fbGetPixmapGeometry);
LOAD_VIV_FUNC(fbGetPixmapInfo);
LOAD_VIV_FUNC(fbDestroyPixmap);
-
- displaydata = SDL_GetDisplayDriverData(0);
- _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(displaydata->native_display);
+ _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(egl_viv_data->fbGetDisplayByIndex(0));
if (!_this->egl_data->egl_display) {
return SDL_SetError("Could not get EGL display");
}
-
+
if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) {
return SDL_SetError("Could not initialize EGL");
}
- displaydata->egl_display = _this->egl_data->egl_display;
-
_this->gl_config.driver_loaded = 1;
if (path) {
@@ -169,7 +165,7 @@ MX6_GLES_LoadLibrary(_THIS, const char *egl_path) {
} else {
*_this->gl_config.driver_path = '\0';
}
-
+
return 0;
}
@@ -190,7 +186,7 @@ MX6_GLES_UnloadLibrary(_THIS)
SDL_UnloadObject(_this->egl_data->egl_dll_handle);
_this->egl_data->egl_dll_handle = NULL;
}
-
+
SDL_free(_this->egl_data);
_this->egl_data = NULL;
diff --git a/src/video/mx6/SDL_mx6video.c b/src/video/mx6/SDL_mx6video.c
index 2f9c04f..d449ef6 100644
--- a/src/video/mx6/SDL_mx6video.c
+++ b/src/video/mx6/SDL_mx6video.c
@@ -163,7 +163,7 @@ MX6_VideoInit(_THIS)
SDL_VideoDisplay display;
SDL_DisplayMode current_mode;
SDL_DisplayData *data;
-
+
data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
if (data == NULL) {
return SDL_OutOfMemory();
@@ -181,9 +181,9 @@ MX6_VideoInit(_THIS)
}
MX6_UpdateDisplay(_this);
-#ifdef SDL_INPUT_LINUXEV
+#ifdef SDL_INPUT_LINUXEV
SDL_EVDEV_Init();
-#endif
+#endif
return 1;
}
@@ -191,9 +191,9 @@ MX6_VideoInit(_THIS)
void
MX6_VideoQuit(_THIS)
{
-#ifdef SDL_INPUT_LINUXEV
+#ifdef SDL_INPUT_LINUXEV
SDL_EVDEV_Quit();
-#endif
+#endif
}
void
@@ -214,9 +214,9 @@ MX6_CreateWindow(_THIS, SDL_Window * window)
{
SDL_DisplayData *displaydata;
SDL_WindowData *wdata;
-
+
displaydata = SDL_GetDisplayDriverData(0);
-
+
/* Allocate window internal data */
wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
if (wdata == NULL) {
@@ -226,12 +226,12 @@ MX6_CreateWindow(_THIS, SDL_Window * window)
/* Setup driver data for this window */
window->driverdata = wdata;
window->flags |= SDL_WINDOW_OPENGL;
-
+
if (!_this->egl_data) {
return -1;
}
- wdata->native_window = egl_viv_data->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
+ wdata->native_window = egl_viv_data->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
if (!wdata->native_window) {
return SDL_SetError("MX6: Can't create native window");
}
@@ -249,7 +249,7 @@ void
MX6_DestroyWindow(_THIS, SDL_Window * window)
{
SDL_WindowData *wdata;
-
+
wdata = window->driverdata;
if (wdata) {
SDL_EGL_DestroySurface(_this, wdata->egl_surface);
diff --git a/src/video/mx6/SDL_mx6video.h b/src/video/mx6/SDL_mx6video.h
index 7827337..9dcae5a 100644
--- a/src/video/mx6/SDL_mx6video.h
+++ b/src/video/mx6/SDL_mx6video.h
@@ -34,7 +34,6 @@ typedef struct SDL_VideoData
typedef struct SDL_DisplayData
{
EGLNativeDisplayType native_display;
- EGLDisplay egl_display;
} SDL_DisplayData;
typedef struct SDL_WindowData