Mercurial > sdl-ios-xcode
diff src/video/x11/SDL_x11render.c @ 4596:dc26c37ad70e
Got testsprite2 to work reasonably.
author | Sunny Sachanandani <sunnysachanandani@gmail.com> |
---|---|
date | Sun, 18 Jul 2010 08:28:35 +0530 |
parents | 73eeadf7ed8e |
children | 95be206b3cb7 |
line wrap: on
line diff
--- a/src/video/x11/SDL_x11render.c Sat Jul 17 15:53:29 2010 +0530 +++ b/src/video/x11/SDL_x11render.c Sun Jul 18 08:28:35 2010 +0530 @@ -101,7 +101,6 @@ Picture xwindow_pict; Picture pixmap_picts[3]; Picture drawable_pict; - Picture mask_pict; int blend_op; XRenderPictFormat* xwindow_pict_fmt; GC mask_gc; @@ -182,6 +181,7 @@ 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_ARGB8888; for (i = 0; i < _this->num_displays; ++i) { SDL_AddRenderDriver(&_this->displays[i], &X11_RenderDriver); @@ -197,6 +197,7 @@ SDL_Renderer *renderer; X11_RenderData *data; XGCValues gcv; + gcv.graphics_exposures = False; int i, n; int bpp; Uint32 Rmask, Gmask, Bmask, Amask; @@ -291,25 +292,15 @@ SDL_SetError("XCreatePixmap() failed"); return NULL; } - data->mask_pict = - XRenderCreatePicture(data->display, data->mask, - XRenderFindStandardFormat(data->display, - PictStandardA1), - 0, NULL); - if (!data->mask_pict) { - SDL_SetError("XRenderCreatePicture() failed"); - return NULL; - } // Create the GC for the clip mask. - XGCValues gcv_mask; - gcv_mask.foreground = 1; - gcv_mask.background = 0; data->mask_gc = XCreateGC(data->display, data->mask, - GCBackground | GCForeground, &gcv_mask); + GCGraphicsExposures, &gcv); if (!data->mask_gc) { SDL_SetError("XCreateGC() failed"); return NULL; } + XSetBackground(data->display, data->mask_gc, 0); + XSetForeground(data->display, data->mask_gc, 1); // Set the default blending mode. renderer->blendMode = SDL_BLENDMODE_BLEND; data->blend_op = PictOpOver; @@ -425,6 +416,16 @@ SDL_Window *window = renderer->window; int i, n; +#ifdef SDL_VIDEO_DRIVER_X11_XRENDER + if (data->use_xrender) { + XRenderFreePicture(data->display, data->xwindow_pict); + data->xwindow_pict_fmt = + XRenderFindVisualFormat(data->display, data->visual); + data->xwindow_pict = + XRenderCreatePicture(data->display, data->xwindow, + data->xwindow_pict_fmt, 0, NULL); + } +#endif if (renderer->info.flags & SDL_RENDERER_SINGLEBUFFER) { n = 0; } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) { @@ -439,6 +440,7 @@ XFreePixmap(data->display, data->pixmaps[i]); data->pixmaps[i] = None; #ifdef SDL_VIDEO_DRIVER_X11_XRENDER + XRenderFreePicture(data->display, data->pixmap_picts[i]); data->pixmap_picts[i] = None; #endif } @@ -1038,27 +1040,20 @@ */ attributes.clip_mask = data->mask; valuemask = CPClipMask; - - XRenderComposite(data->display, PictOpClear, data->mask_pict, None, data->mask_pict, - 0, 0, 0, 0, 0, 0, window->w, window->h); + + XSetForeground(data->display, data->mask_gc, 0); + XFillRectangle(data->display, data->mask, data->mask_gc, + 0, 0, window->w, window->h); + XSetForeground(data->display, data->mask_gc, 1); XDrawPoints(data->display, data->mask, data->mask_gc, xpoints, xcount, CoordModeOrigin); XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes); - Picture fill = - XRenderCreateSolidFill(data->display, &foreground); - if (!fill) { - SDL_SetError("XRenderCreateSolidFill() failed"); - return -1; - } - - XRenderComposite(data->display, data->blend_op, fill, data->mask_pict, - data->drawable_pict, 0, 0, 0, 0, 0, 0, window->w, window->h); - + /*XRenderFillRectangle(data->display, data->blend_op, data->drawable_pict, + &foreground, 0, 0, window->w, window->h);*/ // Reset the clip_mask attributes.clip_mask = None; XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes); - XRenderFreePicture(data->display, fill); } else #endif @@ -1101,8 +1096,10 @@ if (data->use_xrender == SDL_TRUE) { drawable = data->mask; gc = data->mask_gc; - XRenderComposite(data->display, PictOpClear, data->mask_pict, None, data->mask_pict, - 0, 0, 0, 0, 0, 0, window->w, window->h); + XSetForeground(data->display, data->mask_gc, 0); + XFillRectangle(data->display, data->mask, data->mask_gc, + 0, 0, window->w, window->h); + XSetForeground(data->display, data->mask_gc, 1); } else #endif @@ -1234,16 +1231,10 @@ attributes.clip_mask = data->mask; unsigned long valuemask = CPClipMask; XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes); - Picture fill = XRenderCreateSolidFill(data->display, &xrforeground); - if (!fill) { - SDL_SetError("XRenderCreateSolidFill() failed"); - return -1; - } - XRenderComposite(data->display, data->blend_op, fill, data->mask_pict, - data->drawable_pict, 0, 0, 0, 0, 0, 0, window->w, window->h); + /*XRenderFillRectangle(data->display, data->blend_op, data->drawable_pict, + &xrforeground, 0, 0, window->w, window->h);*/ attributes.clip_mask = None; XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes); - XRenderFreePicture(data->display, fill); } #endif SDL_stack_free(xpoints); @@ -1294,21 +1285,17 @@ valuemask = CPClipMask; attributes.clip_mask = data->mask; - XRenderComposite(data->display, PictOpClear, data->mask_pict, None, data->mask_pict, - 0, 0, 0, 0, 0, 0, window->w, window->h); + XSetForeground(data->display, data->mask_gc, 0); + XFillRectangle(data->display, data->mask, data->mask_gc, + 0, 0, window->w, window->h); + XSetForeground(data->display, data->mask_gc, 1); + XDrawRectangles(data->display, data->mask, data->mask_gc, xrects, xcount); XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes); - Picture fill = - XRenderCreateSolidFill(data->display, &foreground); - if (!fill) { - SDL_SetError("XRenderCreateSolidFill() failed"); - return -1; - } - XRenderComposite(data->display, data->blend_op, fill, data->mask_pict, - data->drawable_pict, 0, 0, 0, 0, 0, 0, window->w, window->h); + /*XRenderFillRectangle(data->display, data->blend_op, data->drawable_pict, + &foreground, 0, 0, window->w, window->h);*/ attributes.clip_mask = None; XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes); - XRenderFreePicture(data->display, fill); } else #endif @@ -1369,23 +1356,19 @@ foreground = xrenderdrawcolor(renderer); attributes.clip_mask = data->mask; - XRenderComposite(data->display, PictOpClear, data->mask_pict, None, data->mask_pict, - 0, 0, 0, 0, 0, 0, window->w, window->h); + XSetForeground(data->display, data->mask_gc, 0); + XFillRectangle(data->display, data->mask, data->mask_gc, + 0, 0, window->w, window->h); + XSetForeground(data->display, data->mask_gc, 1); + XFillRectangles(data->display, data->mask, data->mask_gc, xrects, xcount); XRenderChangePicture(data->display, data->drawable_pict, CPClipMask, &attributes); - Picture fill = XRenderCreateSolidFill(data->display, - &foreground); - if (!fill) { - SDL_SetError("XRenderCreateSolidFill() failed"); - return -1; - } - XRenderComposite(data->display, data->blend_op, fill, None, - data->drawable_pict, 0, 0, 0, 0, 0, 0, window->w, window->h); + /*XRenderFillRectangle(data->display, data->blend_op, data->drawable_pict, + &foreground, 0, 0, window->w, window->h);*/ attributes.clip_mask = None; XRenderChangePicture(data->display, data->drawable_pict, CPClipMask, &attributes); - XRenderFreePicture(data->display, fill); } else #endif @@ -1746,9 +1729,6 @@ if (data->mask_gc) { XFreeGC(data->display, data->mask_gc); } - if (data->mask_pict) { - XRenderFreePicture(data->display, data->mask_pict); - } if (data->mask) { XFreePixmap(data->display, data->mask); }