diff options
author | Eric Anholt <[email protected]> | 2007-01-05 18:19:58 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2007-01-05 18:23:57 -0800 |
commit | c2b185cff82a6cdb723cda4e05ffe1a213a9de3e (patch) | |
tree | bdaa0ae2352ed0c1b53fdacfc449e1c392e45744 /src | |
parent | b530d96216f8a01e2dd4100941f6b1aa4d9dfbcd (diff) |
Add reporting of damage by DRI drivers when the extension support is available.
With this, tools like ximagesrc in gstreamer correctly see updates from GL
rendering. Support requires that the Xdamage library be current (but will be
disabled if not present) plus a new X Server with support for the new
XDamagePost request. libGL now has a new interface version, and also links
against libXdamage and libXfixes to support it, but backwards compatibility
is retained.
Currently, all drivers report damage at SwapBuffers time through common code --
front buffer rendering doesn't result in damage being reported. Also, the
damage is against the root window, as our drivers don't yet render to backing
store when they should (composited environments).
Diffstat (limited to 'src')
-rw-r--r-- | src/glx/x11/glxcmds.c | 3 | ||||
-rw-r--r-- | src/glx/x11/glxext.c | 66 | ||||
-rw-r--r-- | src/mesa/drivers/dri/common/dri_util.c | 21 |
3 files changed, 88 insertions, 2 deletions
diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c index 9d1bb2a0b55..f52b71ffcd2 100644 --- a/src/glx/x11/glxcmds.c +++ b/src/glx/x11/glxcmds.c @@ -2883,8 +2883,9 @@ int __glXGetInternalVersion(void) * 20050727 - Gut all the old interfaces. This breaks compatability with * any DRI driver built to any previous version. * 20060314 - Added support for GLX_MESA_copy_sub_buffer. + * 20070105 - Added support for damage reporting. */ - return 20060314; + return 20070105; } diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c index 8bec2c34c60..29b3a1c01c5 100644 --- a/src/glx/x11/glxext.c +++ b/src/glx/x11/glxext.c @@ -48,6 +48,8 @@ #include <stdio.h> #include <X11/extensions/Xext.h> #include <X11/extensions/extutil.h> +#include <X11/extensions/Xfixes.h> +#include <X11/extensions/Xdamage.h> #include <assert.h> #include "indirect_init.h" #include "glapi.h" @@ -698,6 +700,68 @@ static __DRIfuncPtr get_proc_address( const char * proc_name ) return NULL; } +#ifdef XDAMAGE_1_1_INTERFACE +static GLboolean has_damage_post(__DRInativeDisplay *dpy) +{ + static GLboolean inited = GL_FALSE; + static GLboolean has_damage; + + if (!inited) { + int major, minor; + + if (XDamageQueryVersion(dpy, &major, &minor) && + major == 1 && minor >= 1) + { + has_damage = GL_TRUE; + } else { + has_damage = GL_FALSE; + } + inited = GL_TRUE; + } + + return has_damage; +} +#endif /* XDAMAGE_1_1_INTERFACE */ + +static void __glXReportDamage(__DRInativeDisplay *dpy, int screen, + __DRIid drawable, + int x, int y, + drm_clip_rect_t *rects, int num_rects, + GLboolean front_buffer) +{ +#ifdef XDAMAGE_1_1_INTERFACE + XRectangle *xrects; + XserverRegion region; + int i; + int x_off, y_off; + + if (!has_damage_post(dpy)) + return; + + if (front_buffer) { + x_off = x; + y_off = y; + drawable = RootWindow(dpy, screen); + } else{ + x_off = 0; + y_off = 0; + } + + xrects = malloc(sizeof(XRectangle) * num_rects); + if (xrects == NULL) + return; + + for (i = 0; i < num_rects; i++) { + xrects[i].x = rects[i].x1 + x_off; + xrects[i].y = rects[i].y1 + y_off; + xrects[i].width = rects[i].x2 - rects[i].x1; + xrects[i].height = rects[i].y2 - rects[i].y1; + } + region = XFixesCreateRegion(dpy, xrects, num_rects); + XDamagePost(dpy, drawable, region); + XFixesDestroyRegion(dpy, region); +#endif +} /** * Table of functions exported by the loader to the driver. @@ -720,6 +784,8 @@ static const __DRIinterfaceMethods interface_methods = { __glXGetUST, __glXGetMscRateOML, + + __glXReportDamage, }; diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index ba251a81430..cc3dcf9d8db 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -482,8 +482,27 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp) static void driSwapBuffers( __DRInativeDisplay *dpy, void *drawablePrivate ) { __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate; + drm_clip_rect_t rect; + dPriv->swapBuffers(dPriv); - (void) dpy; + + /* Check that we actually have the new damage report method */ + if (api_ver < 20070105 || dri_interface->reportDamage == NULL) + return; + + /* Assume it's affecting the whole drawable for now */ + rect.x1 = 0; + rect.y1 = 0; + rect.x2 = rect.x1 + dPriv->w; + rect.y2 = rect.y1 + dPriv->h; + + /* Report the damage. Currently, all our drivers draw directly to the + * front buffer, so we report the damage there rather than to the backing + * store (if any). + */ + (*dri_interface->reportDamage)(dpy, dPriv->screen, dPriv->draw, + dPriv->x, dPriv->y, + &rect, 1, GL_TRUE); } /** |