Mercurial > sdl-ios-xcode
diff src/video/picogui/SDL_pgvideo.c @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
line wrap: on
line diff
--- a/src/video/picogui/SDL_pgvideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/picogui/SDL_pgvideo.c Mon May 29 04:04:35 2006 +0000 @@ -36,23 +36,22 @@ #define PGVID_DRIVER_NAME "picogui" /* Initialization/Query functions */ -static int PG_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **PG_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *PG_SetVideoMode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -static int PG_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void PG_VideoQuit (_THIS); +static int PG_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **PG_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags); +static SDL_Surface *PG_SetVideoMode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); +static int PG_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void PG_VideoQuit(_THIS); /* Hardware surface functions */ -static int PG_AllocHWSurface (_THIS, SDL_Surface * surface); -static int PG_LockHWSurface (_THIS, SDL_Surface * surface); -static void PG_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void PG_FreeHWSurface (_THIS, SDL_Surface * surface); +static int PG_AllocHWSurface(_THIS, SDL_Surface * surface); +static int PG_LockHWSurface(_THIS, SDL_Surface * surface); +static void PG_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void PG_FreeHWSurface(_THIS, SDL_Surface * surface); /* etc. */ -static void PG_UpdateRects (_THIS, int numrects, SDL_Rect * rects); +static void PG_UpdateRects(_THIS, int numrects, SDL_Rect * rects); // The implementation dependent data for the window manager cursor struct WMcursor @@ -62,17 +61,17 @@ }; /* WM functions */ -void PG_SetCaption (_THIS, const char *title, const char *icon); -WMcursor *PG_CreateWMCursor (_THIS, Uint8 * data, Uint8 * mask, - int w, int h, int hot_x, int hot_y); -void PG_FreeWMCursor (_THIS, WMcursor * cursor); -void PG_WarpWMCursor (_THIS, Uint16 x, Uint16 y); -int PG_ShowWMCursor (_THIS, WMcursor * cursor); +void PG_SetCaption(_THIS, const char *title, const char *icon); +WMcursor *PG_CreateWMCursor(_THIS, Uint8 * data, Uint8 * mask, + int w, int h, int hot_x, int hot_y); +void PG_FreeWMCursor(_THIS, WMcursor * cursor); +void PG_WarpWMCursor(_THIS, Uint16 x, Uint16 y); +int PG_ShowWMCursor(_THIS, WMcursor * cursor); /* PicoGUI driver bootstrap functions */ static int -PG_Available (void) +PG_Available(void) { /* FIXME: The current client lib doesn't give a way to see if the picogui * server is reachable without causing a fatal error if it isn't. @@ -84,32 +83,32 @@ } static void -PG_DeleteDevice (SDL_VideoDevice * device) +PG_DeleteDevice(SDL_VideoDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice * -PG_CreateDevice (int devindex) +PG_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) { - SDL_free (device); + SDL_free(device); } return (0); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = PG_VideoInit; @@ -153,7 +152,7 @@ int -PG_VideoInit (_THIS, SDL_PixelFormat * vformat) +PG_VideoInit(_THIS, SDL_PixelFormat * vformat) { /* Connect to the PicoGUI server. No way to process command line args yet, * but since this is based on SHM it's not important to be able to specify @@ -162,15 +161,15 @@ * FIXME: Another nitpick about the current client lib is there's no * clean way to indicate that command line args are not available. */ - pgInit (0, (char **) ""); - this->hidden->mi = *pgGetVideoMode (); + pgInit(0, (char **) ""); + this->hidden->mi = *pgGetVideoMode(); /* Create a picogui application and canvas. We'll populate the canvas later. */ - this->hidden->wApp = pgRegisterApp (PG_APP_NORMAL, "SDL", 0); - this->hidden->wCanvas = pgNewWidget (PG_WIDGET_CANVAS, 0, 0); - pgSetWidget (PGDEFAULT, PG_WP_SIDE, PG_S_ALL, 0); + this->hidden->wApp = pgRegisterApp(PG_APP_NORMAL, "SDL", 0); + this->hidden->wCanvas = pgNewWidget(PG_WIDGET_CANVAS, 0, 0); + pgSetWidget(PGDEFAULT, PG_WP_SIDE, PG_S_ALL, 0); - PG_InitEvents (this); + PG_InitEvents(this); /* Determine the current screen size */ this->info.current_w = this->hidden->mi.lxres; @@ -190,63 +189,61 @@ } SDL_Rect ** -PG_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +PG_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { return (SDL_Rect **) - 1; } SDL_Surface * -PG_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +PG_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { if (this->hidden->bitmap) { /* Free old bitmap */ if (current->pixels) { - shmdt (current->pixels); + shmdt(current->pixels); current->pixels = NULL; } - pgDelete (this->hidden->bitmap); + pgDelete(this->hidden->bitmap); } /* Allocate the new pixel format for the screen */ - if (!SDL_ReallocFormat (current, bpp, 0, 0, 0, 0)) { - SDL_SetError - ("Couldn't allocate new pixel format for requested mode"); + if (!SDL_ReallocFormat(current, bpp, 0, 0, 0, 0)) { + SDL_SetError("Couldn't allocate new pixel format for requested mode"); return (NULL); } /* Create a new picogui bitmap */ - this->hidden->bitmap = pgCreateBitmap (width, height); - this->hidden->shm = *pgMakeSHMBitmap (this->hidden->bitmap); - current->pixels = shmat (shmget (this->hidden->shm.shm_key, - this->hidden->shm.shm_length, 0), NULL, - 0); + this->hidden->bitmap = pgCreateBitmap(width, height); + this->hidden->shm = *pgMakeSHMBitmap(this->hidden->bitmap); + current->pixels = shmat(shmget(this->hidden->shm.shm_key, + this->hidden->shm.shm_length, 0), NULL, 0); /* Reset the canvas, and draw persistent and incremental grops. * Use mapping and offsets to center it. */ - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_NUKE, 0); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_NUKE, 0); /* 0. Set the source position during incremental rendering */ - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_GROP, 5, PG_GROP_SETSRC, 0, 0, - 0, 0); - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_GROPFLAGS, 1, - PG_GROPF_INCREMENTAL); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROP, 5, PG_GROP_SETSRC, 0, 0, + 0, 0); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROPFLAGS, 1, + PG_GROPF_INCREMENTAL); /* 1. Incremental bitmap rendering */ - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_GROP, 6, PG_GROP_BITMAP, - 0, 0, 0, 0, this->hidden->bitmap); - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_GROPFLAGS, 1, - PG_GROPF_INCREMENTAL); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROP, 6, PG_GROP_BITMAP, + 0, 0, 0, 0, this->hidden->bitmap); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROPFLAGS, 1, + PG_GROPF_INCREMENTAL); /* 2. Normal bitmap rendering */ - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_GROP, 6, PG_GROP_BITMAP, - 0, 0, this->hidden->shm.width, this->hidden->shm.height, - this->hidden->bitmap); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROP, 6, PG_GROP_BITMAP, + 0, 0, this->hidden->shm.width, this->hidden->shm.height, + this->hidden->bitmap); /* Set up the new mode framebuffer */ current->flags = 0; @@ -274,7 +271,7 @@ current->format->Aloss = 8 - this->hidden->shm.alpha_length; /* Draw the app */ - pgUpdate (); + pgUpdate(); /* We're done */ return (current); @@ -282,31 +279,31 @@ /* We don't actually allow hardware surfaces other than the main one */ static int -PG_AllocHWSurface (_THIS, SDL_Surface * surface) +PG_AllocHWSurface(_THIS, SDL_Surface * surface) { return (-1); } static void -PG_FreeHWSurface (_THIS, SDL_Surface * surface) +PG_FreeHWSurface(_THIS, SDL_Surface * surface) { return; } /* We need to wait for vertical retrace on page flipped displays */ static int -PG_LockHWSurface (_THIS, SDL_Surface * surface) +PG_LockHWSurface(_THIS, SDL_Surface * surface) { return (0); } static void -PG_UnlockHWSurface (_THIS, SDL_Surface * surface) +PG_UnlockHWSurface(_THIS, SDL_Surface * surface) { return; } static void -PG_UpdateRects (_THIS, int numrects, SDL_Rect * rects) +PG_UpdateRects(_THIS, int numrects, SDL_Rect * rects) { int i; @@ -317,21 +314,21 @@ /* Schedule an incremental update for this rectangle, using * the canvas gropnodes we've loaded beforehand. */ - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_FINDGROP, 1, 0); - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_MOVEGROP, 4, - rects[i].x, rects[i].y, rects[i].w, rects[i].h); - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_FINDGROP, 1, 1); - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_MOVEGROP, 4, - rects[i].x, rects[i].y, rects[i].w, rects[i].h); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_FINDGROP, 1, 0); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_MOVEGROP, 4, + rects[i].x, rects[i].y, rects[i].w, rects[i].h); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_FINDGROP, 1, 1); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_MOVEGROP, 4, + rects[i].x, rects[i].y, rects[i].w, rects[i].h); /* Go perform the update */ - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_INCREMENTAL, 0); - pgSubUpdate (this->hidden->wCanvas); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_INCREMENTAL, 0); + pgSubUpdate(this->hidden->wCanvas); } } int -PG_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +PG_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { /* do nothing of note. */ return (1); @@ -341,47 +338,47 @@ another SDL video routine -- notably UpdateRects. */ void -PG_VideoQuit (_THIS) +PG_VideoQuit(_THIS) { if (this->screen->pixels != NULL) { - shmdt (this->screen->pixels); + shmdt(this->screen->pixels); this->screen->pixels = NULL; - pgDelete (this->hidden->bitmap); + pgDelete(this->hidden->bitmap); } - pgDelete (this->hidden->wCanvas); - pgDelete (this->hidden->wApp); + pgDelete(this->hidden->wCanvas); + pgDelete(this->hidden->wApp); } void -PG_SetCaption (_THIS, const char *title, const char *icon) +PG_SetCaption(_THIS, const char *title, const char *icon) { if (title != NULL) - pgReplaceText (this->hidden->wApp, title); - pgUpdate (); + pgReplaceText(this->hidden->wApp, title); + pgUpdate(); } /* FIXME: The cursor stuff isn't implemented yet! */ WMcursor * -PG_CreateWMCursor (_THIS, Uint8 * data, Uint8 * mask, - int w, int h, int hot_x, int hot_y) +PG_CreateWMCursor(_THIS, Uint8 * data, Uint8 * mask, + int w, int h, int hot_x, int hot_y) { static WMcursor dummy; return &dummy; } void -PG_FreeWMCursor (_THIS, WMcursor * cursor) +PG_FreeWMCursor(_THIS, WMcursor * cursor) { } void -PG_WarpWMCursor (_THIS, Uint16 x, Uint16 y) +PG_WarpWMCursor(_THIS, Uint16 x, Uint16 y) { } int -PG_ShowWMCursor (_THIS, WMcursor * cursor) +PG_ShowWMCursor(_THIS, WMcursor * cursor) { return 1; }