Minor cleanups
authorSam Lantinga <slouken@libsdl.org>
Mon, 13 Oct 2014 10:46:27 -0700
changeset 9156f68bd6205580
parent 9155 dfeb88fc5a9d
child 9157 c4f435c99e16
Minor cleanups
src/video/directfb/SDL_DirectFB_render.c
src/video/mx6/SDL_mx6video.c
src/video/x11/SDL_x11opengles.c
     1.1 --- a/src/video/directfb/SDL_DirectFB_render.c	Mon Oct 13 10:43:10 2014 -0700
     1.2 +++ b/src/video/directfb/SDL_DirectFB_render.c	Mon Oct 13 10:46:27 2014 -0700
     1.3 @@ -52,7 +52,7 @@
     1.4  #define SDL_DFB_RENDERERDATA(rend) DirectFB_RenderData *renddata = ((rend) ? (DirectFB_RenderData *) (rend)->driverdata : NULL)
     1.5  
     1.6  
     1.7 -/* GDI renderer implementation */
     1.8 +/* DirectFB renderer implementation */
     1.9  
    1.10  static SDL_Renderer *DirectFB_CreateRenderer(SDL_Window * window,
    1.11                                               Uint32 flags);
     2.1 --- a/src/video/mx6/SDL_mx6video.c	Mon Oct 13 10:43:10 2014 -0700
     2.2 +++ b/src/video/mx6/SDL_mx6video.c	Mon Oct 13 10:46:27 2014 -0700
     2.3 @@ -48,6 +48,7 @@
     2.4  MX6_Destroy(SDL_VideoDevice * device)
     2.5  {
     2.6      if (device->driverdata != NULL) {
     2.7 +        SDL_free(device->driverdata);
     2.8          device->driverdata = NULL;
     2.9      }
    2.10  }
    2.11 @@ -56,7 +57,7 @@
    2.12  MX6_Create()
    2.13  {
    2.14      SDL_VideoDevice *device;
    2.15 -    SDL_VideoData *phdata;
    2.16 +    SDL_VideoData *data;
    2.17  
    2.18      /* Initialize SDL_VideoDevice structure */
    2.19      device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
    2.20 @@ -66,14 +67,14 @@
    2.21      }
    2.22  
    2.23      /* Initialize internal data */
    2.24 -    phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
    2.25 -    if (phdata == NULL) {
    2.26 +    data = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
    2.27 +    if (data == NULL) {
    2.28          SDL_OutOfMemory();
    2.29          SDL_free(device);
    2.30          return NULL;
    2.31      }
    2.32  
    2.33 -    device->driverdata = phdata;
    2.34 +    device->driverdata = data;
    2.35  
    2.36      /* Setup amount of available displays and current display */
    2.37      device->num_displays = 0;
    2.38 @@ -185,7 +186,7 @@
    2.39      SDL_EVDEV_Init();
    2.40  #endif
    2.41  
    2.42 -    return 1;
    2.43 +    return 0;
    2.44  }
    2.45  
    2.46  void
    2.47 @@ -213,31 +214,31 @@
    2.48  MX6_CreateWindow(_THIS, SDL_Window * window)
    2.49  {
    2.50      SDL_DisplayData *displaydata;
    2.51 -    SDL_WindowData *wdata;
    2.52 +    SDL_WindowData *data;
    2.53  
    2.54      displaydata = SDL_GetDisplayDriverData(0);
    2.55  
    2.56      /* Allocate window internal data */
    2.57 -    wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
    2.58 -    if (wdata == NULL) {
    2.59 +    data = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
    2.60 +    if (data == NULL) {
    2.61          return SDL_OutOfMemory();
    2.62      }
    2.63  
    2.64      /* Setup driver data for this window */
    2.65 -    window->driverdata = wdata;
    2.66 +    window->driverdata = data;
    2.67      window->flags |= SDL_WINDOW_OPENGL;
    2.68  
    2.69      if (!_this->egl_data) {
    2.70          return -1;
    2.71      }
    2.72  
    2.73 -    wdata->native_window = egl_viv_data->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
    2.74 -    if (!wdata->native_window) {
    2.75 +    data->native_window = egl_viv_data->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
    2.76 +    if (!data->native_window) {
    2.77          return SDL_SetError("MX6: Can't create native window");
    2.78      }
    2.79  
    2.80 -    wdata->egl_surface = SDL_EGL_CreateSurface(_this, wdata->native_window);
    2.81 -    if (wdata->egl_surface == EGL_NO_SURFACE) {
    2.82 +    data->egl_surface = SDL_EGL_CreateSurface(_this, data->native_window);
    2.83 +    if (data->egl_surface == EGL_NO_SURFACE) {
    2.84          return SDL_SetError("MX6: Can't create EGL surface");
    2.85      }
    2.86  
    2.87 @@ -248,22 +249,27 @@
    2.88  void
    2.89  MX6_DestroyWindow(_THIS, SDL_Window * window)
    2.90  {
    2.91 -    SDL_WindowData *wdata;
    2.92 +    SDL_WindowData *data;
    2.93  
    2.94 -    wdata = window->driverdata;
    2.95 -    if (wdata) {
    2.96 -        SDL_EGL_DestroySurface(_this, wdata->egl_surface);
    2.97 +    data = window->driverdata;
    2.98 +    if (data) {
    2.99 +        if (data->egl_surface != EGL_NO_SURFACE) {
   2.100 +            SDL_EGL_DestroySurface(_this, data->egl_surface);
   2.101 +        }
   2.102 +
   2.103 +        if (data->native_window) {
   2.104 +            egl_viv_data->fbDestroyWindow(data->native_window);
   2.105 +        }
   2.106 +
   2.107 +        SDL_free(data);
   2.108      }
   2.109 -
   2.110 -    if (egl_viv_data) {
   2.111 -        egl_viv_data->fbDestroyWindow(wdata->native_window);
   2.112 -    }
   2.113 +    window->driverdata = NULL;
   2.114  }
   2.115  
   2.116  int
   2.117  MX6_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
   2.118  {
   2.119 -    return -1;
   2.120 +    return SDL_Unsupported();
   2.121  }
   2.122  
   2.123  void
     3.1 --- a/src/video/x11/SDL_x11opengles.c	Mon Oct 13 10:43:10 2014 -0700
     3.2 +++ b/src/video/x11/SDL_x11opengles.c	Mon Oct 13 10:46:27 2014 -0700
     3.3 @@ -29,8 +29,8 @@
     3.4  /* EGL implementation of SDL OpenGL support */
     3.5  
     3.6  int
     3.7 -X11_GLES_LoadLibrary(_THIS, const char *path) {
     3.8 -        
     3.9 +X11_GLES_LoadLibrary(_THIS, const char *path)
    3.10 +{
    3.11      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    3.12  
    3.13      /* If the profile requested is not GL ES, switch over to X11_GL functions  */