Got testsprite2 to work reasonably.
This commit is contained in:
parent
f927fc59ba
commit
7c46b950ed
3 changed files with 47 additions and 64 deletions
|
@ -101,7 +101,6 @@ typedef struct
|
||||||
Picture xwindow_pict;
|
Picture xwindow_pict;
|
||||||
Picture pixmap_picts[3];
|
Picture pixmap_picts[3];
|
||||||
Picture drawable_pict;
|
Picture drawable_pict;
|
||||||
Picture mask_pict;
|
|
||||||
int blend_op;
|
int blend_op;
|
||||||
XRenderPictFormat* xwindow_pict_fmt;
|
XRenderPictFormat* xwindow_pict_fmt;
|
||||||
GC mask_gc;
|
GC mask_gc;
|
||||||
|
@ -182,6 +181,7 @@ X11_AddRenderDriver(_THIS)
|
||||||
info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YUY2;
|
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_UYVY;
|
||||||
info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YVYU;
|
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) {
|
for (i = 0; i < _this->num_displays; ++i) {
|
||||||
SDL_AddRenderDriver(&_this->displays[i], &X11_RenderDriver);
|
SDL_AddRenderDriver(&_this->displays[i], &X11_RenderDriver);
|
||||||
|
@ -197,6 +197,7 @@ X11_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||||
SDL_Renderer *renderer;
|
SDL_Renderer *renderer;
|
||||||
X11_RenderData *data;
|
X11_RenderData *data;
|
||||||
XGCValues gcv;
|
XGCValues gcv;
|
||||||
|
gcv.graphics_exposures = False;
|
||||||
int i, n;
|
int i, n;
|
||||||
int bpp;
|
int bpp;
|
||||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||||
|
@ -291,25 +292,15 @@ X11_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||||
SDL_SetError("XCreatePixmap() failed");
|
SDL_SetError("XCreatePixmap() failed");
|
||||||
return NULL;
|
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.
|
// 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,
|
data->mask_gc = XCreateGC(data->display, data->mask,
|
||||||
GCBackground | GCForeground, &gcv_mask);
|
GCGraphicsExposures, &gcv);
|
||||||
if (!data->mask_gc) {
|
if (!data->mask_gc) {
|
||||||
SDL_SetError("XCreateGC() failed");
|
SDL_SetError("XCreateGC() failed");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
XSetBackground(data->display, data->mask_gc, 0);
|
||||||
|
XSetForeground(data->display, data->mask_gc, 1);
|
||||||
// Set the default blending mode.
|
// Set the default blending mode.
|
||||||
renderer->blendMode = SDL_BLENDMODE_BLEND;
|
renderer->blendMode = SDL_BLENDMODE_BLEND;
|
||||||
data->blend_op = PictOpOver;
|
data->blend_op = PictOpOver;
|
||||||
|
@ -425,6 +416,16 @@ X11_DisplayModeChanged(SDL_Renderer * renderer)
|
||||||
SDL_Window *window = renderer->window;
|
SDL_Window *window = renderer->window;
|
||||||
int i, n;
|
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) {
|
if (renderer->info.flags & SDL_RENDERER_SINGLEBUFFER) {
|
||||||
n = 0;
|
n = 0;
|
||||||
} else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
|
} else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
|
||||||
|
@ -439,6 +440,7 @@ X11_DisplayModeChanged(SDL_Renderer * renderer)
|
||||||
XFreePixmap(data->display, data->pixmaps[i]);
|
XFreePixmap(data->display, data->pixmaps[i]);
|
||||||
data->pixmaps[i] = None;
|
data->pixmaps[i] = None;
|
||||||
#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
|
#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
|
||||||
|
XRenderFreePicture(data->display, data->pixmap_picts[i]);
|
||||||
data->pixmap_picts[i] = None;
|
data->pixmap_picts[i] = None;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1039,26 +1041,19 @@ X11_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
|
||||||
attributes.clip_mask = data->mask;
|
attributes.clip_mask = data->mask;
|
||||||
valuemask = CPClipMask;
|
valuemask = CPClipMask;
|
||||||
|
|
||||||
XRenderComposite(data->display, PictOpClear, data->mask_pict, None, data->mask_pict,
|
XSetForeground(data->display, data->mask_gc, 0);
|
||||||
0, 0, 0, 0, 0, 0, window->w, window->h);
|
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,
|
XDrawPoints(data->display, data->mask, data->mask_gc, xpoints, xcount,
|
||||||
CoordModeOrigin);
|
CoordModeOrigin);
|
||||||
XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes);
|
XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes);
|
||||||
Picture fill =
|
/*XRenderFillRectangle(data->display, data->blend_op, data->drawable_pict,
|
||||||
XRenderCreateSolidFill(data->display, &foreground);
|
&foreground, 0, 0, window->w, window->h);*/
|
||||||
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);
|
|
||||||
|
|
||||||
// Reset the clip_mask
|
// Reset the clip_mask
|
||||||
attributes.clip_mask = None;
|
attributes.clip_mask = None;
|
||||||
XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes);
|
XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes);
|
||||||
XRenderFreePicture(data->display, fill);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -1101,8 +1096,10 @@ X11_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
|
||||||
if (data->use_xrender == SDL_TRUE) {
|
if (data->use_xrender == SDL_TRUE) {
|
||||||
drawable = data->mask;
|
drawable = data->mask;
|
||||||
gc = data->mask_gc;
|
gc = data->mask_gc;
|
||||||
XRenderComposite(data->display, PictOpClear, data->mask_pict, None, data->mask_pict,
|
XSetForeground(data->display, data->mask_gc, 0);
|
||||||
0, 0, 0, 0, 0, 0, window->w, window->h);
|
XFillRectangle(data->display, data->mask, data->mask_gc,
|
||||||
|
0, 0, window->w, window->h);
|
||||||
|
XSetForeground(data->display, data->mask_gc, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -1234,16 +1231,10 @@ X11_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
|
||||||
attributes.clip_mask = data->mask;
|
attributes.clip_mask = data->mask;
|
||||||
unsigned long valuemask = CPClipMask;
|
unsigned long valuemask = CPClipMask;
|
||||||
XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes);
|
XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes);
|
||||||
Picture fill = XRenderCreateSolidFill(data->display, &xrforeground);
|
/*XRenderFillRectangle(data->display, data->blend_op, data->drawable_pict,
|
||||||
if (!fill) {
|
&xrforeground, 0, 0, window->w, window->h);*/
|
||||||
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);
|
|
||||||
attributes.clip_mask = None;
|
attributes.clip_mask = None;
|
||||||
XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes);
|
XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes);
|
||||||
XRenderFreePicture(data->display, fill);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
SDL_stack_free(xpoints);
|
SDL_stack_free(xpoints);
|
||||||
|
@ -1294,21 +1285,17 @@ X11_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
|
||||||
valuemask = CPClipMask;
|
valuemask = CPClipMask;
|
||||||
attributes.clip_mask = data->mask;
|
attributes.clip_mask = data->mask;
|
||||||
|
|
||||||
XRenderComposite(data->display, PictOpClear, data->mask_pict, None, data->mask_pict,
|
XSetForeground(data->display, data->mask_gc, 0);
|
||||||
0, 0, 0, 0, 0, 0, window->w, window->h);
|
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);
|
XDrawRectangles(data->display, data->mask, data->mask_gc, xrects, xcount);
|
||||||
XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes);
|
XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes);
|
||||||
Picture fill =
|
/*XRenderFillRectangle(data->display, data->blend_op, data->drawable_pict,
|
||||||
XRenderCreateSolidFill(data->display, &foreground);
|
&foreground, 0, 0, window->w, window->h);*/
|
||||||
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);
|
|
||||||
attributes.clip_mask = None;
|
attributes.clip_mask = None;
|
||||||
XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes);
|
XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes);
|
||||||
XRenderFreePicture(data->display, fill);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -1369,23 +1356,19 @@ X11_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
|
||||||
foreground = xrenderdrawcolor(renderer);
|
foreground = xrenderdrawcolor(renderer);
|
||||||
attributes.clip_mask = data->mask;
|
attributes.clip_mask = data->mask;
|
||||||
|
|
||||||
XRenderComposite(data->display, PictOpClear, data->mask_pict, None, data->mask_pict,
|
XSetForeground(data->display, data->mask_gc, 0);
|
||||||
0, 0, 0, 0, 0, 0, window->w, window->h);
|
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,
|
XFillRectangles(data->display, data->mask, data->mask_gc,
|
||||||
xrects, xcount);
|
xrects, xcount);
|
||||||
|
|
||||||
XRenderChangePicture(data->display, data->drawable_pict, CPClipMask, &attributes);
|
XRenderChangePicture(data->display, data->drawable_pict, CPClipMask, &attributes);
|
||||||
Picture fill = XRenderCreateSolidFill(data->display,
|
/*XRenderFillRectangle(data->display, data->blend_op, data->drawable_pict,
|
||||||
&foreground);
|
&foreground, 0, 0, window->w, window->h);*/
|
||||||
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);
|
|
||||||
attributes.clip_mask = None;
|
attributes.clip_mask = None;
|
||||||
XRenderChangePicture(data->display, data->drawable_pict, CPClipMask, &attributes);
|
XRenderChangePicture(data->display, data->drawable_pict, CPClipMask, &attributes);
|
||||||
XRenderFreePicture(data->display, fill);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -1746,9 +1729,6 @@ X11_DestroyRenderer(SDL_Renderer * renderer)
|
||||||
if (data->mask_gc) {
|
if (data->mask_gc) {
|
||||||
XFreeGC(data->display, data->mask_gc);
|
XFreeGC(data->display, data->mask_gc);
|
||||||
}
|
}
|
||||||
if (data->mask_pict) {
|
|
||||||
XRenderFreePicture(data->display, data->mask_pict);
|
|
||||||
}
|
|
||||||
if (data->mask) {
|
if (data->mask) {
|
||||||
XFreePixmap(data->display, data->mask);
|
XFreePixmap(data->display, data->mask);
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,6 +151,8 @@ SDL_X11_SYM(SDL_X11_XSynchronizeRetType,XSynchronize,(Display* a,Bool b),(a,b),r
|
||||||
SDL_X11_SYM(SDL_X11_XESetWireToEventRetType,XESetWireToEvent,(Display* a,int b,SDL_X11_XESetWireToEventRetType c),(a,b,c),return)
|
SDL_X11_SYM(SDL_X11_XESetWireToEventRetType,XESetWireToEvent,(Display* a,int b,SDL_X11_XESetWireToEventRetType c),(a,b,c),return)
|
||||||
SDL_X11_SYM(SDL_X11_XESetEventToWireRetType,XESetEventToWire,(Display* a,int b,SDL_X11_XESetEventToWireRetType c),(a,b,c),return)
|
SDL_X11_SYM(SDL_X11_XESetEventToWireRetType,XESetEventToWire,(Display* a,int b,SDL_X11_XESetEventToWireRetType c),(a,b,c),return)
|
||||||
SDL_X11_SYM(XExtensionErrorHandler,XSetExtensionErrorHandler,(XExtensionErrorHandler a),(a),return)
|
SDL_X11_SYM(XExtensionErrorHandler,XSetExtensionErrorHandler,(XExtensionErrorHandler a),(a),return)
|
||||||
|
SDL_X11_SYM(int,XFillRectangle,(Display *dpy,Drawable d,GC gc,int x,int y,unsigned int width,unsigned int height),(dpy,d,gc,x,y,width,height),return)
|
||||||
|
SDL_X11_SYM(int,XSetBackground,(Display *dpy,GC gc,unsigned long background),(dpy,gc,background),return)
|
||||||
|
|
||||||
#if NeedWidePrototypes
|
#if NeedWidePrototypes
|
||||||
SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display* a,unsigned int b,int c),(a,b,c),return)
|
SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display* a,unsigned int b,int c),(a,b,c),return)
|
||||||
|
@ -246,6 +248,7 @@ SDL_X11_SYM(void,XRenderChangePicture,(Display *dpy,Picture picture,unsigned lon
|
||||||
SDL_X11_SYM(void,XRenderComposite,(Display *dpy,int op,Picture src,Picture mask,Picture dst,int src_x,int src_y,int mask_x,int mask_y,int dst_x,int dst_y,unsigned int width,unsigned int height),(dpy,op,src,mask,dst,src_x,src_y,mask_x,mask_y,dst_x,dst_y,width,height),return)
|
SDL_X11_SYM(void,XRenderComposite,(Display *dpy,int op,Picture src,Picture mask,Picture dst,int src_x,int src_y,int mask_x,int mask_y,int dst_x,int dst_y,unsigned int width,unsigned int height),(dpy,op,src,mask,dst,src_x,src_y,mask_x,mask_y,dst_x,dst_y,width,height),return)
|
||||||
SDL_X11_SYM(Picture,XRenderCreateSolidFill,(Display *dpy,const XRenderColor *color),(dpy,color),return)
|
SDL_X11_SYM(Picture,XRenderCreateSolidFill,(Display *dpy,const XRenderColor *color),(dpy,color),return)
|
||||||
SDL_X11_SYM(void,XRenderSetPictureTransform,(Display *dpy,Picture picture,XTransform *transform),(dpy,picture,transform),return)
|
SDL_X11_SYM(void,XRenderSetPictureTransform,(Display *dpy,Picture picture,XTransform *transform),(dpy,picture,transform),return)
|
||||||
|
SDL_X11_SYM(void,XRenderFillRectangle,(Display *dpy,int op,Picture dst,_Xconst XRenderColor *color,int x,int y,unsigned int width,unsigned int height),(dpy,op,dst,color,x,y,width,height),return)
|
||||||
#endif
|
#endif
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ static int current_color = 0;
|
||||||
static SDL_Rect *positions;
|
static SDL_Rect *positions;
|
||||||
static SDL_Rect *velocities;
|
static SDL_Rect *velocities;
|
||||||
static int sprite_w, sprite_h;
|
static int sprite_w, sprite_h;
|
||||||
static SDL_BlendMode blendMode = SDL_BLENDMODE_MASK;
|
static SDL_BlendMode blendMode = SDL_BLENDMODE_BLEND;
|
||||||
static SDL_TextureScaleMode scaleMode = SDL_TEXTURESCALEMODE_NONE;
|
static SDL_TextureScaleMode scaleMode = SDL_TEXTURESCALEMODE_NONE;
|
||||||
|
|
||||||
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
|
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue