Integrate XFixes and XDamage into the build system.
authorSunny Sachanandani <sunnysachanandani@gmail.com>
Mon, 19 Jul 2010 20:05:53 +0530
changeset 4604 d7535d7a40ea
parent 4603 dffa432f0e2b
child 4605 0b3a509c53a0
Integrate XFixes and XDamage into the build system.
configure.in
include/SDL_config.h.in
src/video/x11/SDL_x11dyn.h
src/video/x11/SDL_x11render.c
src/video/x11/SDL_x11sym.h
--- a/configure.in	Mon Jul 19 18:57:02 2010 +0530
+++ b/configure.in	Mon Jul 19 20:05:53 2010 +0530
@@ -1055,7 +1055,9 @@
                     xrandr_lib=[`find_lib "libXrandr.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
                     xinput_lib=[`find_lib "libXi.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
                     xss_lib=[`find_lib "libXss.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
-                    ;;
+                    xdamage_lib=[`find_lib "libXdamage.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
+                    xfixes_lib=[`find_lib "libXfixes.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
+;;
             esac
 
             if test x$ac_cv_func_shmat != xyes; then
@@ -1222,14 +1224,50 @@
             if test x$definitely_enable_video_x11_xrender = xyes; then
                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRENDER)
             fi
-
+            AC_ARG_ENABLE(video-x11-xdamage-xfixes,
+AC_HELP_STRING([--enable-video-x11-xdamage-xfixes], [enable X11 Xdamage and Xfixes extensions [[default=yes]]]),
+                            , enable_video_x11_xdamage=yes)
+            if test x$enable_video_x11_xdamage = xyes && test x$definitely_enable_video_x11_xrender = xyes ; then
+                AC_CHECK_HEADER(X11/extensions/Xdamage.h,
+                                have_xdamage_h_hdr=yes,
+                                have_xdamage_h_hdr=no,
+                                [#include <X11/Xlib.h>
+                                ])
+                AC_CHECK_HEADER(X11/extensions/Xfixes.h,
+                                have_xfixes_h_hdr=yes,
+                                have_xfixes_h_hdr=no,
+                                [#include <X11/Xlib.h>
+                                ])
+                if test x$have_xdamage_h_hdr = xyes && test x$have_xfixes_h_hdr = xyes ; then
+                    if test x$enable_x11_shared = xyes && test x$xdamage_lib != x && test x$xfixes_lib != x ; then
+                        echo "-- dynamic libXdamage -> $xdamage_lib"
+                        echo "-- dynamic libXfixes -> $xfixes_lib"
+                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XDAMAGE, "$xdamage_lib")
+                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES, "$xfixes_lib")
+                        definitely_enable_video_x11_xdamage=yes
+                        definitely_enable_video_x11_xfixes=yes
+                    else
+                        AC_CHECK_LIB(Xdamage, XDamageQueryExtension, have_xdamage_lib=yes)
+                        AC_CHECK_LIB(Xfixes, XFixesQueryExtension, have_xfixes_lib=yes)
+                        if test x$have_xdamage_lib = xyes && test x$have_xfixes_lib = xyes ; then
+                            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXdamage -lXfixes"
+                            definitely_enable_video_x11_xdamage=yes
+                            definitely_enable_video_x11_xfixes=yes
+                        fi
+                    fi
+                fi
+            fi
+            if test x$definitely_enable_video_x11_xdamage = xyes && test x$definitely_enable_video_x11_xfixes = xyes ; then
+                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XDAMAGE)
+                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XFIXES)
+            fi
             AC_ARG_ENABLE(render-x11,
 AC_HELP_STRING([--enable-render-x11], [enable the X11 render driver [[default=yes]]]),
                                 , enable_render_x11=yes)
             if test x$enable_render_x11 = xyes; then
                 AC_DEFINE(SDL_VIDEO_RENDER_X11)
             fi
-        fi
+       fi
     fi
 }
 
--- a/include/SDL_config.h.in	Mon Jul 19 18:57:02 2010 +0530
+++ b/include/SDL_config.h.in	Mon Jul 19 20:05:53 2010 +0530
@@ -272,6 +272,8 @@
 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER
 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT
 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS
+#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XDAMAGE
+#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES
 #undef SDL_VIDEO_DRIVER_X11_VIDMODE
 #undef SDL_VIDEO_DRIVER_X11_XINERAMA
 #undef SDL_VIDEO_DRIVER_X11_XRANDR
@@ -279,6 +281,8 @@
 #undef SDL_VIDEO_DRIVER_X11_SCRNSAVER
 #undef SDL_VIDEO_DRIVER_X11_XV
 #undef SDL_VIDEO_DRIVER_X11_XRENDER
+#undef SDL_VIDEO_DRIVER_X11_XDAMAGE
+#undef SDL_VIDEO_DRIVER_X11_XFIXES
 
 #undef SDL_VIDEO_RENDER_X11
 
--- a/src/video/x11/SDL_x11dyn.h	Mon Jul 19 18:57:02 2010 +0530
+++ b/src/video/x11/SDL_x11dyn.h	Mon Jul 19 20:05:53 2010 +0530
@@ -56,6 +56,14 @@
 #include <X11/extensions/Xrender.h>
 #endif
 
+#if SDL_VIDEO_DRIVER_X11_XDAMAGE
+#include <X11/extensions/Xdamage.h>
+#endif
+
+#if SDL_VIDEO_DRIVER_X11_XFIXES
+#include <X11/extensions/Xfixes.h>
+#endif
+
 /*
  * When using the "dynamic X11" functionality, we duplicate all the Xlib
  *  symbols that would be referenced by SDL inside of SDL itself.
--- a/src/video/x11/SDL_x11render.c	Mon Jul 19 18:57:02 2010 +0530
+++ b/src/video/x11/SDL_x11render.c	Mon Jul 19 20:05:53 2010 +0530
@@ -31,11 +31,6 @@
 #include "../SDL_pixels_c.h"
 #include "../SDL_yuv_sw_c.h"
 
-#include <X11/extensions/Xdamage.h>
-#include <X11/extensions/Xfixes.h>
-
-#define SDL_VIDEO_DRIVER_X11_XDAMAGE
-
 /* X11 renderer implementation */
 
 static SDL_Renderer *X11_CreateRenderer(SDL_Window * window, Uint32 flags);
@@ -271,21 +266,23 @@
     }
 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
     if (data->use_xrender) {
+        if(SDL_X11_HAVE_XDAMAGE && SDL_X11_HAVE_XFIXES) {
         /* Query XDamage and XFixes */
-        if(XDamageQueryExtension(data->display,
-                                 &event_basep,
-                                 &error_basep) == True && 
-           (XFixesQueryExtension(data->display,
-                                    &event_basep,
-                                    &error_basep) == True)) {
-                int major_version, minor_version;
-                XFixesQueryVersion(data->display,
-                                   &major_version,
-                                   &minor_version);
-                /* Only XFixes v 2 or greater
-                 * Required for XFixesSetPictureClipRegion() */
-                if(major_version >= 2)
-                    data->use_xdamage = SDL_TRUE;
+            if(XDamageQueryExtension(data->display,
+                                     &event_basep,
+                                     &error_basep) == True && 
+               (XFixesQueryExtension(data->display,
+                                        &event_basep,
+                                        &error_basep) == True)) {
+                    int major_version, minor_version;
+                    XFixesQueryVersion(data->display,
+                                       &major_version,
+                                       &minor_version);
+                    /* Only XFixes v 2 or greater
+                     * Required for XFixesSetPictureClipRegion() */
+                    if(major_version >= 2)
+                        data->use_xdamage = SDL_TRUE;
+            }
         }
 #endif
         /* Find the PictFormat from the visual.
--- a/src/video/x11/SDL_x11sym.h	Mon Jul 19 18:57:02 2010 +0530
+++ b/src/video/x11/SDL_x11sym.h	Mon Jul 19 20:05:53 2010 +0530
@@ -252,6 +252,22 @@
 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)
 SDL_X11_SYM(void,XRenderFillRectangles,(Display *dpy,int op,Picture dst,_Xconst XRenderColor *color,_Xconst XRectangle *rectangles,int n_rects),(dpy,op,dst,color,rectangles,n_rects),return)
 #endif
+
+#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
+SDL_X11_MODULE(XDAMAGE)
+SDL_X11_SYM(Bool,XDamageQueryExtension,(Display *dpy,int *event_base_return,int *error_base_return),(dpy,event_base_return,error_base_return),return)
+SDL_X11_SYM(Damage,XDamageCreate,(Display *dpy,Drawable d,int level),(dpy,d,level),return)
+SDL_X11_SYM(void,XDamageSubtract,(Display *dpy,Damage damage,XserverRegion repair,XserverRegion parts),(dpy,damage,repair,parts),return)
+SDL_X11_SYM(void,XDamageDestroy,(Display *dpy,Damage damage),(dpy,damage),return)
+#endif
+
+#ifdef SDL_VIDEO_DRIVER_X11_XFIXES
+SDL_X11_MODULE(XFIXES)
+SDL_X11_SYM(Bool,XFixesQueryExtension,(Display *dpy,int *event_base,int *error_base),(dpy,event_base,error_base),return)
+SDL_X11_SYM(Status,XFixesQueryVersion,(Display *dpy,int *major,int *minor),(dpy,major,minor),return)
+SDL_X11_SYM(void,XFixesSetGCClipRegion,(Display *dpy,GC gc,int clip_x,int clip_y,XserverRegion region),(dpy,gc,clip_x,clip_y,region),return)
+SDL_X11_SYM(void,XFixesSetPictureClipRegion,(Display *dpy,XID picture,int clip_x,int clip_y,XserverRegion region),(dpy,picture,clip_x,clip_y,region),return)
+#endif
 /* *INDENT-ON* */
 
 /* vi: set ts=4 sw=4 expandtab: */