Minor cleanups

This commit is contained in:
Sam Lantinga 2014-10-13 10:46:27 -07:00
parent bebc8d126d
commit 557d43e69a
3 changed files with 30 additions and 24 deletions

View File

@ -52,7 +52,7 @@
#define SDL_DFB_RENDERERDATA(rend) DirectFB_RenderData *renddata = ((rend) ? (DirectFB_RenderData *) (rend)->driverdata : NULL) #define SDL_DFB_RENDERERDATA(rend) DirectFB_RenderData *renddata = ((rend) ? (DirectFB_RenderData *) (rend)->driverdata : NULL)
/* GDI renderer implementation */ /* DirectFB renderer implementation */
static SDL_Renderer *DirectFB_CreateRenderer(SDL_Window * window, static SDL_Renderer *DirectFB_CreateRenderer(SDL_Window * window,
Uint32 flags); Uint32 flags);

View File

@ -48,6 +48,7 @@ static void
MX6_Destroy(SDL_VideoDevice * device) MX6_Destroy(SDL_VideoDevice * device)
{ {
if (device->driverdata != NULL) { if (device->driverdata != NULL) {
SDL_free(device->driverdata);
device->driverdata = NULL; device->driverdata = NULL;
} }
} }
@ -56,7 +57,7 @@ static SDL_VideoDevice *
MX6_Create() MX6_Create()
{ {
SDL_VideoDevice *device; SDL_VideoDevice *device;
SDL_VideoData *phdata; SDL_VideoData *data;
/* Initialize SDL_VideoDevice structure */ /* Initialize SDL_VideoDevice structure */
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
@ -66,14 +67,14 @@ MX6_Create()
} }
/* Initialize internal data */ /* Initialize internal data */
phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); data = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
if (phdata == NULL) { if (data == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
SDL_free(device); SDL_free(device);
return NULL; return NULL;
} }
device->driverdata = phdata; device->driverdata = data;
/* Setup amount of available displays and current display */ /* Setup amount of available displays and current display */
device->num_displays = 0; device->num_displays = 0;
@ -185,7 +186,7 @@ MX6_VideoInit(_THIS)
SDL_EVDEV_Init(); SDL_EVDEV_Init();
#endif #endif
return 1; return 0;
} }
void void
@ -213,31 +214,31 @@ int
MX6_CreateWindow(_THIS, SDL_Window * window) MX6_CreateWindow(_THIS, SDL_Window * window)
{ {
SDL_DisplayData *displaydata; SDL_DisplayData *displaydata;
SDL_WindowData *wdata; SDL_WindowData *data;
displaydata = SDL_GetDisplayDriverData(0); displaydata = SDL_GetDisplayDriverData(0);
/* Allocate window internal data */ /* Allocate window internal data */
wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); data = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
if (wdata == NULL) { if (data == NULL) {
return SDL_OutOfMemory(); return SDL_OutOfMemory();
} }
/* Setup driver data for this window */ /* Setup driver data for this window */
window->driverdata = wdata; window->driverdata = data;
window->flags |= SDL_WINDOW_OPENGL; window->flags |= SDL_WINDOW_OPENGL;
if (!_this->egl_data) { if (!_this->egl_data) {
return -1; return -1;
} }
wdata->native_window = egl_viv_data->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h); data->native_window = egl_viv_data->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
if (!wdata->native_window) { if (!data->native_window) {
return SDL_SetError("MX6: Can't create native window"); return SDL_SetError("MX6: Can't create native window");
} }
wdata->egl_surface = SDL_EGL_CreateSurface(_this, wdata->native_window); data->egl_surface = SDL_EGL_CreateSurface(_this, data->native_window);
if (wdata->egl_surface == EGL_NO_SURFACE) { if (data->egl_surface == EGL_NO_SURFACE) {
return SDL_SetError("MX6: Can't create EGL surface"); return SDL_SetError("MX6: Can't create EGL surface");
} }
@ -248,22 +249,27 @@ MX6_CreateWindow(_THIS, SDL_Window * window)
void void
MX6_DestroyWindow(_THIS, SDL_Window * window) MX6_DestroyWindow(_THIS, SDL_Window * window)
{ {
SDL_WindowData *wdata; SDL_WindowData *data;
wdata = window->driverdata; data = window->driverdata;
if (wdata) { if (data) {
SDL_EGL_DestroySurface(_this, wdata->egl_surface); if (data->egl_surface != EGL_NO_SURFACE) {
} SDL_EGL_DestroySurface(_this, data->egl_surface);
}
if (egl_viv_data) { if (data->native_window) {
egl_viv_data->fbDestroyWindow(wdata->native_window); egl_viv_data->fbDestroyWindow(data->native_window);
}
SDL_free(data);
} }
window->driverdata = NULL;
} }
int int
MX6_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) MX6_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
{ {
return -1; return SDL_Unsupported();
} }
void void

View File

@ -29,8 +29,8 @@
/* EGL implementation of SDL OpenGL support */ /* EGL implementation of SDL OpenGL support */
int int
X11_GLES_LoadLibrary(_THIS, const char *path) { X11_GLES_LoadLibrary(_THIS, const char *path)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
/* If the profile requested is not GL ES, switch over to X11_GL functions */ /* If the profile requested is not GL ES, switch over to X11_GL functions */