Commit aef21681 authored by Sunny Sachanandani's avatar Sunny Sachanandani

Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.

Fixed the XRenderPictureAttributes value in X11_CreateRenderer with graphics_exposures = False.

Start work on Xrender specific additions to X11_TextureData and X11_CreateTexture.
parent dabea238
...@@ -97,6 +97,8 @@ typedef struct ...@@ -97,6 +97,8 @@ typedef struct
Pixmap pixmaps[3]; Pixmap pixmaps[3];
#ifdef SDL_VIDEO_DRIVER_X11_XRENDER #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
Picture xwindow_pict; Picture xwindow_pict;
Picture pixmap_picts[3];
Picture * drawable_pict;
XRenderPictFormat* xwindow_pict_fmt; XRenderPictFormat* xwindow_pict_fmt;
XRenderPictureAttributes xwindow_pict_attr; XRenderPictureAttributes xwindow_pict_attr;
unsigned int xwindow_pict_attr_valuemask; unsigned int xwindow_pict_attr_valuemask;
...@@ -117,6 +119,9 @@ typedef struct ...@@ -117,6 +119,9 @@ typedef struct
Pixmap pixmap; Pixmap pixmap;
#ifdef SDL_VIDEO_DRIVER_X11_XRENDER #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
Picture picture; Picture picture;
XRenderPictFormat* picture_fmt;
XRenderPictureAttributes picture_attr;
unsigned int picture_attr_valuemask;
#endif #endif
XImage *image; XImage *image;
#ifndef NO_SHARED_MEMORY #ifndef NO_SHARED_MEMORY
...@@ -213,12 +218,10 @@ X11_CreateRenderer(SDL_Window * window, Uint32 flags) ...@@ -213,12 +218,10 @@ X11_CreateRenderer(SDL_Window * window, Uint32 flags)
if(XRenderQueryExtension(data->display, &event_basep, &error_basep) == True) { if(XRenderQueryExtension(data->display, &event_basep, &error_basep) == True) {
data->xrender_available = SDL_TRUE; data->xrender_available = SDL_TRUE;
data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display, data->visual); data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display, data->visual);
data->xwindow_pict_attr_valuemask = 0; // FIXME data->xwindow_pict_attr.graphics_exposures = False;
data->xwindow_pict = XRenderCreatePicture(data->display, data->xwindow_pict_attr_valuemask = CPGraphicsExposure;
data->xwindow, data->xwindow_pict = XRenderCreatePicture(data->display, data->xwindow, data->xwindow_pict_fmt,
data->xwindow_pict_fmt, data->xwindow_pict_attr_valuemask, &data->xwindow_pict_attr);
data->xwindow_pict_attr_valuemask,
&data->xwindow_pict_attr);
} }
else { else {
data->xrender_available = SDL_FALSE; data->xrender_available = SDL_FALSE;
...@@ -272,12 +275,23 @@ X11_CreateRenderer(SDL_Window * window, Uint32 flags) ...@@ -272,12 +275,23 @@ X11_CreateRenderer(SDL_Window * window, Uint32 flags)
SDL_SetError("XCreatePixmap() failed"); SDL_SetError("XCreatePixmap() failed");
return NULL; return NULL;
} }
data->pixmap_picts[i] =
XCreatePicture(data->display, data->pixmap[i], data->xwindow_pict_fmt,
data->xwindow_pict_attr_valuemask, &xwindow_pict_attr);
} }
if (n > 0) { if (n > 0) {
data->drawable = data->pixmaps[0]; data->drawable = data->pixmaps[0];
#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
if(data->xrender_available == SDL_TRUE)
data->drawable_pict = &(data->pixmap_picts[0]);
#endif
data->makedirty = SDL_TRUE; data->makedirty = SDL_TRUE;
} else { } else {
data->drawable = data->xwindow; data->drawable = data->xwindow;
#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
if(data->xrender_available == SDL_TRUE)
data->drawable_pict = &(data->xwindow_pict);
#endif
data->makedirty = SDL_FALSE; data->makedirty = SDL_FALSE;
} }
data->current_pixmap = 0; data->current_pixmap = 0;
...@@ -325,6 +339,9 @@ X11_DisplayModeChanged(SDL_Renderer * renderer) ...@@ -325,6 +339,9 @@ X11_DisplayModeChanged(SDL_Renderer * renderer)
if (data->pixmaps[i] != None) { if (data->pixmaps[i] != None) {
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
data->pictures[i] = None;
#endif
} }
} }
for (i = 0; i < n; ++i) { for (i = 0; i < n; ++i) {
...@@ -335,9 +352,17 @@ X11_DisplayModeChanged(SDL_Renderer * renderer) ...@@ -335,9 +352,17 @@ X11_DisplayModeChanged(SDL_Renderer * renderer)
SDL_SetError("XCreatePixmap() failed"); SDL_SetError("XCreatePixmap() failed");
return -1; return -1;
} }
#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
data->pictures[i] =
XCreatePicture(data->display, data->pixmap[i], data->xwindow_pict_fmt,
data->xwindow_pict_attr_valuemask, &data->xwindow_pict_attr);
#endif
} }
if (n > 0) { if (n > 0) {
data->drawable = data->pixmaps[0]; data->drawable = data->pixmaps[0];
#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
data->drawable_pict = &(data->pictures[0]);
#endif
} }
data->current_pixmap = 0; data->current_pixmap = 0;
...@@ -360,7 +385,6 @@ X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) ...@@ -360,7 +385,6 @@ X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
} }
texture->driverdata = data; texture->driverdata = data;
if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
data->yuv = data->yuv =
SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h); SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
...@@ -371,11 +395,21 @@ X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) ...@@ -371,11 +395,21 @@ X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
} else { } else {
/* The image/pixmap depth must be the same as the window or you /* The image/pixmap depth must be the same as the window or you
get a BadMatch error when trying to putimage or copyarea. get a BadMatch error when trying to putimage or copyarea.
This BadMatch error
*/ */
#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
if(renderdata->xrender_available == SDL_False) {
if (texture->format != display->current_mode.format) {
SDL_SetError("Texture format doesn't match window format");
return -1;
}
}
#else
if (texture->format != display->current_mode.format) { if (texture->format != display->current_mode.format) {
SDL_SetError("Texture format doesn't match window format"); SDL_SetError("Texture format doesn't match window format");
return -1; return -1;
} }
#endif
data->format = texture->format; data->format = texture->format;
} }
data->pitch = texture->w * SDL_BYTESPERPIXEL(data->format); data->pitch = texture->w * SDL_BYTESPERPIXEL(data->format);
...@@ -455,6 +489,12 @@ X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) ...@@ -455,6 +489,12 @@ X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
SDL_SetError("XCreatePixmap() failed"); SDL_SetError("XCreatePixmap() failed");
return -1; return -1;
} }
#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
data->picture_fmt =
XRenderFindVisualFormat(renderdata->display,
data->picture =
XCreatePicture(renderdata->display, data->pixmap,
data->image = data->image =
XCreateImage(renderdata->display, renderdata->visual, XCreateImage(renderdata->display, renderdata->visual,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment