Mercurial > sdl-ios-xcode
diff src/video/x11/SDL_x11render.c @ 4585:21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
author | Sunny Sachanandani <sunnysachanandani@gmail.com> |
---|---|
date | Tue, 15 Jun 2010 19:10:06 +0530 |
parents | 9907c8cc6015 |
children | e479c1e57c52 |
line wrap: on
line diff
--- a/src/video/x11/SDL_x11render.c Mon Jun 14 18:22:48 2010 +0530 +++ b/src/video/x11/SDL_x11render.c Tue Jun 15 19:10:06 2010 +0530 @@ -799,7 +799,6 @@ { X11_RenderData *data = (X11_RenderData *) renderer->driverdata; SDL_Window *window = renderer->window; - unsigned long foreground; XPoint *xpoints, *xpoint; int i, xcount; @@ -818,9 +817,6 @@ SDL_AddDirtyRect(&data->dirty, &rect); } - foreground = renderdrawcolor(renderer, 1); - XSetForeground(data->display, data->gc, foreground); - xpoint = xpoints = SDL_stack_alloc(XPoint, count); xcount = 0; for (i = 0; i < count; ++i) { @@ -834,9 +830,30 @@ ++xpoint; ++xcount; } - if (xcount > 0) { - XDrawPoints(data->display, data->drawable, data->gc, xpoints, xcount, +#ifdef SDL_VIDEO_DRIVER_X11_XRENDER + if (data->use_xrender == SDL_TRUE) { + XRenderComposite(data->display, PictOpClear, data->mask_pict, None, data->mask_pict, + 0, 0, 0, 0, 0, 0, window->w, window->h); + XDrawPoints(data->display, data->mask, data->mask_gc, xpoints, xcount, CoordModeOrigin); + XRenderColor foreground = xrenderdrawcolor(renderer); + Picture fill = + XRenderCreateSolidFill(data->display, &foreground); + XRenderComposite(data->display, PictOpOver, fill, data->mask_pict, data->drawable_pict, + 0, 0, 0, 0, 0, 0, window->w, window->h); + XRenderFreePicture(data->display, fill); + } + else +#endif + { + unsigned long foreground = renderdrawcolor(renderer, 1); + XSetForeground(data->display, data->gc, foreground); + + + if (xcount > 0) { + XDrawPoints(data->display, data->drawable, data->gc, xpoints, xcount, + CoordModeOrigin); + } } SDL_stack_free(xpoints); @@ -861,6 +878,22 @@ clip.w = window->w; clip.h = window->h; + Pixmap drawable; + GC gc; +#ifdef SDL_VIDEO_DRIVER_X11_XRENDER + 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); + } + else +#endif + { + drawable = data->drawable; + gc = data->gc; + } + foreground = renderdrawcolor(renderer, 1); XSetForeground(data->display, data->gc, foreground); @@ -915,10 +948,10 @@ ++xpoint; ++xcount; } - XDrawLines(data->display, data->drawable, data->gc, + XDrawLines(data->display, drawable, gc, xpoints, xcount, CoordModeOrigin); if (xpoints[0].x != x2 || xpoints[0].y != y2) { - XDrawPoint(data->display, data->drawable, data->gc, x2, y2); + XDrawPoint(data->display, drawable, gc, x2, y2); } if (data->makedirty) { SDL_Rect rect; @@ -962,10 +995,10 @@ if (xcount > 1) { int x2 = xpoint[-1].x; int y2 = xpoint[-1].y; - XDrawLines(data->display, data->drawable, data->gc, xpoints, xcount, + XDrawLines(data->display, drawable, gc, xpoints, xcount, CoordModeOrigin); if (xpoints[0].x != x2 || xpoints[0].y != y2) { - XDrawPoint(data->display, data->drawable, data->gc, x2, y2); + XDrawPoint(data->display, drawable, gc, x2, y2); } if (data->makedirty) { SDL_Rect rect; @@ -977,6 +1010,15 @@ SDL_AddDirtyRect(&data->dirty, &rect); } } +#ifdef SDL_VIDEO_DRIVER_X11_XRENDER + if(data->use_xrender == SDL_TRUE) { + XRenderColor xrforeground = xrenderdrawcolor(renderer); + Picture fill = XRenderCreateSolidFill(data->display, &xrforeground); + XRenderComposite(data->display, PictOpOver, fill, data->mask_pict, data->drawable_pict, + 0, 0, 0, 0, 0, 0, window->w, window->h); + XRenderFreePicture(data->display, fill); + } +#endif SDL_stack_free(xpoints); return 0;