Fixed using uninitialized display data in iMX6 initialization
authorSam Lantinga <slouken@libsdl.org>
Fri, 12 Sep 2014 15:09:33 -0700
changeset 9134dbd8fe54ebb9
parent 9133 52f185c2d019
child 9135 6cd8e6b54f4d
Fixed using uninitialized display data in iMX6 initialization
src/video/mx6/SDL_mx6opengles.c
src/video/mx6/SDL_mx6video.c
src/video/mx6/SDL_mx6video.h
     1.1 --- a/src/video/mx6/SDL_mx6opengles.c	Thu Sep 11 19:24:42 2014 -0700
     1.2 +++ b/src/video/mx6/SDL_mx6opengles.c	Fri Sep 12 15:09:33 2014 -0700
     1.3 @@ -48,12 +48,12 @@
     1.4  /* EGL implementation of SDL OpenGL support */
     1.5  
     1.6  int
     1.7 -MX6_GLES_LoadLibrary(_THIS, const char *egl_path) {
     1.8 +MX6_GLES_LoadLibrary(_THIS, const char *egl_path)
     1.9 +{
    1.10      /* The definitions of egl_dll_handle and dll_handle were interchanged for some reason.
    1.11         Just left them as is for compatibility */
    1.12      void *dll_handle = NULL, *egl_dll_handle = NULL;
    1.13      char *path = NULL;
    1.14 -    SDL_DisplayData *displaydata;
    1.15  
    1.16      if (_this->egl_data) {
    1.17          return SDL_SetError("OpenGL ES context already created");
    1.18 @@ -75,7 +75,7 @@
    1.19      }
    1.20  
    1.21      if (egl_dll_handle == NULL) {
    1.22 -        if(_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
    1.23 +        if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
    1.24              if (_this->gl_config.major_version > 1) {
    1.25                  path = DEFAULT_OGL_ES2;
    1.26                  egl_dll_handle = SDL_LoadObject(path);
    1.27 @@ -84,11 +84,11 @@
    1.28                  path = DEFAULT_OGL_ES;
    1.29                  egl_dll_handle = SDL_LoadObject(path);
    1.30              }
    1.31 -        }      
    1.32 +        }
    1.33          else {
    1.34              path = DEFAULT_OGL;
    1.35              egl_dll_handle = SDL_LoadObject(path);
    1.36 -        }     
    1.37 +        }
    1.38      }
    1.39      _this->egl_data->egl_dll_handle = egl_dll_handle;
    1.40  
    1.41 @@ -98,8 +98,8 @@
    1.42  
    1.43      if (egl_path != NULL) {
    1.44          dll_handle = SDL_LoadObject(egl_path);
    1.45 -    }   
    1.46 -    
    1.47 +    }
    1.48 +
    1.49      if (SDL_LoadFunction(dll_handle, "eglChooseConfig") == NULL) {
    1.50          if (dll_handle != NULL) {
    1.51              SDL_UnloadObject(dll_handle);
    1.52 @@ -148,20 +148,16 @@
    1.53      LOAD_VIV_FUNC(fbGetPixmapGeometry);
    1.54      LOAD_VIV_FUNC(fbGetPixmapInfo);
    1.55      LOAD_VIV_FUNC(fbDestroyPixmap);
    1.56 -   
    1.57 -    displaydata = SDL_GetDisplayDriverData(0);
    1.58  
    1.59 -    _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(displaydata->native_display);
    1.60 +    _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(egl_viv_data->fbGetDisplayByIndex(0));
    1.61      if (!_this->egl_data->egl_display) {
    1.62          return SDL_SetError("Could not get EGL display");
    1.63      }
    1.64 -    
    1.65 +
    1.66      if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) {
    1.67          return SDL_SetError("Could not initialize EGL");
    1.68      }
    1.69  
    1.70 -    displaydata->egl_display = _this->egl_data->egl_display;
    1.71 -
    1.72      _this->gl_config.driver_loaded = 1;
    1.73  
    1.74      if (path) {
    1.75 @@ -169,7 +165,7 @@
    1.76      } else {
    1.77          *_this->gl_config.driver_path = '\0';
    1.78      }
    1.79 -    
    1.80 +
    1.81      return 0;
    1.82  }
    1.83  
    1.84 @@ -190,7 +186,7 @@
    1.85              SDL_UnloadObject(_this->egl_data->egl_dll_handle);
    1.86              _this->egl_data->egl_dll_handle = NULL;
    1.87          }
    1.88 -        
    1.89 +
    1.90          SDL_free(_this->egl_data);
    1.91          _this->egl_data = NULL;
    1.92  
     2.1 --- a/src/video/mx6/SDL_mx6video.c	Thu Sep 11 19:24:42 2014 -0700
     2.2 +++ b/src/video/mx6/SDL_mx6video.c	Fri Sep 12 15:09:33 2014 -0700
     2.3 @@ -163,7 +163,7 @@
     2.4      SDL_VideoDisplay display;
     2.5      SDL_DisplayMode current_mode;
     2.6      SDL_DisplayData *data;
     2.7 -    
     2.8 +
     2.9      data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
    2.10      if (data == NULL) {
    2.11          return SDL_OutOfMemory();
    2.12 @@ -181,9 +181,9 @@
    2.13      }
    2.14      MX6_UpdateDisplay(_this);
    2.15  
    2.16 -#ifdef SDL_INPUT_LINUXEV    
    2.17 +#ifdef SDL_INPUT_LINUXEV
    2.18      SDL_EVDEV_Init();
    2.19 -#endif    
    2.20 +#endif
    2.21  
    2.22      return 1;
    2.23  }
    2.24 @@ -191,9 +191,9 @@
    2.25  void
    2.26  MX6_VideoQuit(_THIS)
    2.27  {
    2.28 -#ifdef SDL_INPUT_LINUXEV    
    2.29 +#ifdef SDL_INPUT_LINUXEV
    2.30      SDL_EVDEV_Quit();
    2.31 -#endif    
    2.32 +#endif
    2.33  }
    2.34  
    2.35  void
    2.36 @@ -214,9 +214,9 @@
    2.37  {
    2.38      SDL_DisplayData *displaydata;
    2.39      SDL_WindowData *wdata;
    2.40 -    
    2.41 +
    2.42      displaydata = SDL_GetDisplayDriverData(0);
    2.43 -    
    2.44 +
    2.45      /* Allocate window internal data */
    2.46      wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
    2.47      if (wdata == NULL) {
    2.48 @@ -226,12 +226,12 @@
    2.49      /* Setup driver data for this window */
    2.50      window->driverdata = wdata;
    2.51      window->flags |= SDL_WINDOW_OPENGL;
    2.52 -    
    2.53 +
    2.54      if (!_this->egl_data) {
    2.55          return -1;
    2.56      }
    2.57  
    2.58 -    wdata->native_window = egl_viv_data->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);    
    2.59 +    wdata->native_window = egl_viv_data->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
    2.60      if (!wdata->native_window) {
    2.61          return SDL_SetError("MX6: Can't create native window");
    2.62      }
    2.63 @@ -249,7 +249,7 @@
    2.64  MX6_DestroyWindow(_THIS, SDL_Window * window)
    2.65  {
    2.66      SDL_WindowData *wdata;
    2.67 -    
    2.68 +
    2.69      wdata = window->driverdata;
    2.70      if (wdata) {
    2.71          SDL_EGL_DestroySurface(_this, wdata->egl_surface);
     3.1 --- a/src/video/mx6/SDL_mx6video.h	Thu Sep 11 19:24:42 2014 -0700
     3.2 +++ b/src/video/mx6/SDL_mx6video.h	Fri Sep 12 15:09:33 2014 -0700
     3.3 @@ -34,7 +34,6 @@
     3.4  typedef struct SDL_DisplayData
     3.5  {
     3.6      EGLNativeDisplayType native_display;
     3.7 -    EGLDisplay egl_display;
     3.8  } SDL_DisplayData;
     3.9  
    3.10  typedef struct SDL_WindowData