changeset 4572:266ec93f49af

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.
author Sunny Sachanandani <sunnysachanandani@gmail.com>
date Wed, 26 May 2010 20:11:56 +0530
parents 97dcf6f6213c
children 6399178be313
files src/video/x11/SDL_x11render.c
diffstat 1 files changed, 47 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/x11/SDL_x11render.c	Mon May 24 21:02:58 2010 +0530
+++ b/src/video/x11/SDL_x11render.c	Wed May 26 20:11:56 2010 +0530
@@ -97,6 +97,8 @@
     Pixmap pixmaps[3];
 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
     Picture xwindow_pict;
+    Picture pixmap_picts[3];
+    Picture * drawable_pict;
     XRenderPictFormat* xwindow_pict_fmt;
     XRenderPictureAttributes xwindow_pict_attr;
     unsigned int xwindow_pict_attr_valuemask;
@@ -117,6 +119,9 @@
     Pixmap pixmap;
 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
     Picture picture;
+    XRenderPictFormat* picture_fmt;
+    XRenderPictureAttributes picture_attr;
+    unsigned int picture_attr_valuemask;
 #endif
     XImage *image;
 #ifndef NO_SHARED_MEMORY
@@ -213,12 +218,10 @@
     if(XRenderQueryExtension(data->display, &event_basep, &error_basep) == True) {
         data->xrender_available = SDL_TRUE;
         data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display, data->visual);
-        data->xwindow_pict_attr_valuemask = 0; // FIXME
-        data->xwindow_pict = XRenderCreatePicture(data->display,
-                                                  data->xwindow,
-                                                  data->xwindow_pict_fmt,
-                                                  data->xwindow_pict_attr_valuemask,
-                                                  &data->xwindow_pict_attr);
+        data->xwindow_pict_attr.graphics_exposures = False;
+        data->xwindow_pict_attr_valuemask = CPGraphicsExposure;
+        data->xwindow_pict = XRenderCreatePicture(data->display, data->xwindow, data->xwindow_pict_fmt,
+                                                  data->xwindow_pict_attr_valuemask, &data->xwindow_pict_attr);
     }
     else {
         data->xrender_available = SDL_FALSE;
@@ -272,12 +275,23 @@
             SDL_SetError("XCreatePixmap() failed");
             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) {
         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;
     } else {
         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->current_pixmap = 0;
@@ -325,6 +339,9 @@
         if (data->pixmaps[i] != None) {
             XFreePixmap(data->display, data->pixmaps[i]);
             data->pixmaps[i] = None;
+#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
+            data->pictures[i] = None;
+#endif
         }
     }
     for (i = 0; i < n; ++i) {
@@ -335,9 +352,17 @@
             SDL_SetError("XCreatePixmap() failed");
             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) {
         data->drawable = data->pixmaps[0];
+#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
+        data->drawable_pict = &(data->pictures[0]);
+#endif
     }
     data->current_pixmap = 0;
 
@@ -360,7 +385,6 @@
     }
 
     texture->driverdata = data;
-
     if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
         data->yuv =
             SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
@@ -371,11 +395,21 @@
     } else {
         /* The image/pixmap depth must be the same as the window or you
            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) {
             SDL_SetError("Texture format doesn't match window format");
             return -1;
         }
+#endif
         data->format = texture->format;
     }
     data->pitch = texture->w * SDL_BYTESPERPIXEL(data->format);
@@ -455,6 +489,12 @@
             SDL_SetError("XCreatePixmap() failed");
             return -1;
         }
+        
+#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
+        data->picture_fmt = 
+            XRenderFindVisualFormat(renderdata->display, 
+        data->picture = 
+            XCreatePicture(renderdata->display, data->pixmap, 
 
         data->image =
             XCreateImage(renderdata->display, renderdata->visual,