Mercurial > sdl-ios-xcode
changeset 2814:e841aa93e6be
indent
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 01 Dec 2008 00:07:45 +0000 |
parents | 49243a6e9ff1 |
children | e759ad5e6f43 |
files | src/video/SDL_video.c src/video/x11/SDL_x11render.c |
diffstat | 2 files changed, 82 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/src/video/SDL_video.c Mon Dec 01 00:05:31 2008 +0000 +++ b/src/video/SDL_video.c Mon Dec 01 00:07:45 2008 +0000 @@ -1977,7 +1977,7 @@ if (!renderer) { return -1; } - if(!renderer->RenderFill) { + if (!renderer->RenderFill) { SDL_Unsupported(); return -1; }
--- a/src/video/x11/SDL_x11render.c Mon Dec 01 00:05:31 2008 +0000 +++ b/src/video/x11/SDL_x11render.c Mon Dec 01 00:07:45 2008 +0000 @@ -104,15 +104,16 @@ #ifndef NO_SHARED_MEMORY /* Shared memory error handler routine */ static int shm_error; -static int (*X_handler)(Display *, XErrorEvent *) = NULL; -static int shm_errhandler(Display *d, XErrorEvent *e) +static int (*X_handler) (Display *, XErrorEvent *) = NULL; +static int +shm_errhandler(Display * d, XErrorEvent * e) { - if (e->error_code == BadAccess) { - shm_error = True; - return(0); - } else { - return(X_handler(d,e)); - } + if (e->error_code == BadAccess) { + shm_error = True; + return (0); + } else { + return (X_handler(d, e)); + } } #endif /* ! NO_SHARED_MEMORY */ @@ -131,7 +132,7 @@ } static Uint32 -X11_GetPixelFormatFromDepth(Display *display, int screen, int depth, int bpp) +X11_GetPixelFormatFromDepth(Display * display, int screen, int depth, int bpp) { XVisualInfo vinfo; @@ -152,12 +153,12 @@ /* No matching visual, try to pick a safe default */ switch (depth) { - case 15: - return SDL_PIXELFORMAT_RGB555; - case 16: - return SDL_PIXELFORMAT_RGB565; - default: - break; + case 15: + return SDL_PIXELFORMAT_RGB555; + case 16: + return SDL_PIXELFORMAT_RGB565; + default: + break; } return SDL_PIXELFORMAT_UNKNOWN; } @@ -182,7 +183,10 @@ } else { bpp = pixmapFormats[i].depth; } - format = X11_GetPixelFormatFromDepth(data->display, DefaultScreen(data->display), pixmapFormats[i].depth, bpp); + format = + X11_GetPixelFormatFromDepth(data->display, + DefaultScreen(data->display), + pixmapFormats[i].depth, bpp); if (format != SDL_PIXELFORMAT_UNKNOWN) { info->texture_formats[info->num_texture_formats++] = format; } @@ -192,11 +196,16 @@ if (info->num_texture_formats == 0) { return; } - info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YV12; - info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_IYUV; - info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YUY2; - info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_UYVY; - info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YVYU; + info->texture_formats[info->num_texture_formats++] = + SDL_PIXELFORMAT_YV12; + info->texture_formats[info->num_texture_formats++] = + SDL_PIXELFORMAT_IYUV; + info->texture_formats[info->num_texture_formats++] = + SDL_PIXELFORMAT_YUY2; + info->texture_formats[info->num_texture_formats++] = + SDL_PIXELFORMAT_UYVY; + info->texture_formats[info->num_texture_formats++] = + SDL_PIXELFORMAT_YVYU; } SDL_AddRenderDriver(0, &X11_RenderDriver); @@ -268,7 +277,9 @@ } XGetWindowAttributes(data->display, data->window, &attributes); for (i = 0; i < n; ++i) { - data->pixmaps[i] = XCreatePixmap(data->display, data->window, window->w, window->h, attributes.depth); + data->pixmaps[i] = + XCreatePixmap(data->display, data->window, window->w, window->h, + attributes.depth); if (data->pixmaps[i] == None) { X11_DestroyRenderer(renderer); SDL_SetError("XCreatePixmap() failed"); @@ -314,7 +325,8 @@ /* Create the drawing context */ gcv.graphics_exposures = False; - data->gc = XCreateGC(data->display, data->window, GCGraphicsExposures, &gcv); + data->gc = + XCreateGC(data->display, data->window, GCGraphicsExposures, &gcv); if (!data->gc) { X11_DestroyRenderer(renderer); SDL_SetError("XCreateGC() failed"); @@ -349,7 +361,9 @@ } XGetWindowAttributes(data->display, data->window, &attributes); for (i = 0; i < n; ++i) { - data->pixmaps[i] = XCreatePixmap(data->display, data->window, window->w, window->h, attributes.depth); + data->pixmaps[i] = + XCreatePixmap(data->display, data->window, window->w, window->h, + attributes.depth); if (data->pixmaps[i] == None) { SDL_SetError("XCreatePixmap() failed"); return -1; @@ -391,12 +405,15 @@ } else { data->format = texture->format; } - data->pitch = texture->w*SDL_BYTESPERPIXEL(data->format); + data->pitch = texture->w * SDL_BYTESPERPIXEL(data->format); - XGetWindowAttributes(renderdata->display, renderdata->window, &attributes); + XGetWindowAttributes(renderdata->display, renderdata->window, + &attributes); depth = SDL_BITSPERPIXEL(data->format); order = SDL_PIXELORDER(data->format); - if (depth == 32 && (order == SDL_PACKEDORDER_XRGB || order == SDL_PACKEDORDER_RGBX || SDL_PACKEDORDER_XBGR || order == SDL_PACKEDORDER_BGRX)) { + if (depth == 32 + && (order == SDL_PACKEDORDER_XRGB || order == SDL_PACKEDORDER_RGBX + || SDL_PACKEDORDER_XBGR || order == SDL_PACKEDORDER_BGRX)) { depth = 24; } @@ -407,11 +424,13 @@ shm_error = True; if (SDL_X11_HAVE_SHM) { - shminfo->shmid = shmget(IPC_PRIVATE, texture->h*data->pitch, IPC_CREAT | 0777); + shminfo->shmid = + shmget(IPC_PRIVATE, texture->h * data->pitch, + IPC_CREAT | 0777); if (shminfo->shmid >= 0) { - shminfo->shmaddr = (char *)shmat(shminfo->shmid, 0, 0); + shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0); shminfo->readOnly = False; - if (shminfo->shmaddr != (char *)-1) { + if (shminfo->shmaddr != (char *) -1) { shm_error = False; X_handler = XSetErrorHandler(shm_errhandler); XShmAttach(renderdata->display, shminfo); @@ -427,8 +446,11 @@ if (!shm_error) { data->pixels = shminfo->shmaddr; - data->image = XShmCreateImage(renderdata->display, attributes.visual, depth, ZPixmap, shminfo->shmaddr, shminfo, texture->w, texture->h); - if(!data->image) { + data->image = + XShmCreateImage(renderdata->display, attributes.visual, depth, + ZPixmap, shminfo->shmaddr, shminfo, + texture->w, texture->h); + if (!data->image) { XShmDetach(renderdata->display, shminfo); XSync(renderdata->display, False); shmdt(shminfo->shmaddr); @@ -447,20 +469,29 @@ return -1; } - data->image = XCreateImage(renderdata->display, attributes.visual, depth, ZPixmap, 0, data->pixels, texture->w, texture->h, SDL_BYTESPERPIXEL(data->format)*8, data->pitch); + data->image = + XCreateImage(renderdata->display, attributes.visual, depth, + ZPixmap, 0, data->pixels, texture->w, texture->h, + SDL_BYTESPERPIXEL(data->format) * 8, + data->pitch); if (!data->image) { SDL_SetError("XCreateImage() failed"); return -1; } } } else { - data->pixmap = XCreatePixmap(renderdata->display, renderdata->window, texture->w, texture->h, depth); + data->pixmap = + XCreatePixmap(renderdata->display, renderdata->window, texture->w, + texture->h, depth); if (data->pixmap == None) { SDL_SetError("XCteatePixmap() failed"); return -1; } - data->image = XCreateImage(renderdata->display, attributes.visual, depth, ZPixmap, 0, NULL, texture->w, texture->h, SDL_BYTESPERPIXEL(data->format)*8, data->pitch); + data->image = + XCreateImage(renderdata->display, attributes.visual, depth, + ZPixmap, 0, NULL, texture->w, texture->h, + SDL_BYTESPERPIXEL(data->format) * 8, data->pitch); if (!data->image) { SDL_SetError("XCreateImage() failed"); return -1; @@ -545,9 +576,10 @@ } else { data->image->width = rect->w; data->image->height = rect->h; - data->image->data = (char *)pixels; + data->image->data = (char *) pixels; data->image->bytes_per_line = pitch; - XPutImage(renderdata->display, data->pixmap, renderdata->gc, data->image, 0, 0, rect->x, rect->y, rect->w, rect->h); + XPutImage(renderdata->display, data->pixmap, renderdata->gc, + data->image, 0, 0, rect->x, rect->y, rect->w, rect->h); } return 0; } @@ -599,7 +631,8 @@ foreground = SDL_MapRGBA(data->format, r, g, b, a); XSetForeground(data->display, data->gc, foreground); - XDrawRectangle(data->display, data->drawable, data->gc, rect->x, rect->y, rect->w, rect->h); + XDrawRectangle(data->display, data->drawable, data->gc, rect->x, rect->y, + rect->w, rect->h); return 0; } @@ -617,16 +650,20 @@ if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) { #ifndef NO_SHARED_MEMORY if (texturedata->shminfo.shmaddr) { - XShmPutImage(data->display, data->drawable, data->gc, texturedata->image, srcrect->x, srcrect->y, dstrect->x, dstrect->y, dstrect->w, dstrect->h, False); - } - else + XShmPutImage(data->display, data->drawable, data->gc, + texturedata->image, srcrect->x, srcrect->y, + dstrect->x, dstrect->y, dstrect->w, dstrect->h, + False); + } else #endif if (texturedata->pixels) { - XPutImage(data->display, data->drawable, data->gc, texturedata->image, srcrect->x, srcrect->y, dstrect->x, dstrect->y, dstrect->w, dstrect->h); + XPutImage(data->display, data->drawable, data->gc, + texturedata->image, srcrect->x, srcrect->y, dstrect->x, + dstrect->y, dstrect->w, dstrect->h); } else { XCopyArea(data->display, texturedata->pixmap, data->drawable, - data->gc, srcrect->x, srcrect->y, dstrect->w, dstrect->h, - dstrect->x, dstrect->y); + data->gc, srcrect->x, srcrect->y, dstrect->w, + dstrect->h, dstrect->x, dstrect->y); } } else { SDL_SetError("Scaling not supported in the X11 renderer");