[PATCHv10 5/5] glx/dri2: Notify the driver when its buffers become invalid.
Francisco Jerez
currojerez at riseup.net
Mon Mar 1 11:21:09 PST 2010
Signed-off-by: Francisco Jerez <currojerez at riseup.net>
---
glx/glxdri2.c | 53 +++++++++++++++++++++++++++++++++--------------------
1 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index edd29b0..f162f38 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -107,8 +107,10 @@ __glXDRIdrawableDestroy(__GLXdrawable *drawable)
/* If the X window was destroyed, the dri DestroyWindow hook will
* aready have taken care of this, so only call if pDraw isn't NULL. */
- if (drawable->pDraw != NULL)
+ if (drawable->pDraw != NULL) {
+ DRI2UntrackClient(drawable->pDraw, 0);
DRI2DestroyDrawable(drawable->pDraw);
+ }
__glXDrawableRelease(drawable);
@@ -217,15 +219,8 @@ __glXDRIdrawableSwapBuffers(ClientPtr client, __GLXdrawable *drawable)
__GLXDRIscreen *screen = priv->screen;
CARD64 unused;
-#if __DRI2_FLUSH_VERSION >= 3
- if (screen->flush) {
- (*screen->flush->flush)(priv->driDrawable);
- (*screen->flush->invalidate)(priv->driDrawable);
- }
-#else
if (screen->flush)
- (*screen->flush->flushInvalidate)(priv->driDrawable);
-#endif
+ (*screen->flush->flush)(priv->driDrawable);
if (DRI2SwapBuffers(client, drawable->pDraw, 0, 0, 0, &unused,
__glXdriSwapEvent, drawable->pDraw) != Success)
@@ -474,6 +469,16 @@ __glXDRIscreenCreateDrawable(__GLXscreen *screen,
return &private->base;
}
+static void
+__glXDRIinvalidateEvent(DrawablePtr pDraw, void *priv)
+{
+ __GLXDRIdrawable *draw = priv;
+ __GLXDRIscreen *screen = draw->screen;
+
+ if (screen->flush)
+ screen->flush->invalidate(draw->driDrawable);
+}
+
static __DRIbuffer *
dri2GetBuffers(__DRIdrawable *driDrawable,
int *width, int *height,
@@ -481,17 +486,21 @@ dri2GetBuffers(__DRIdrawable *driDrawable,
int *out_count, void *loaderPrivate)
{
__GLXDRIdrawable *private = loaderPrivate;
+ DrawablePtr pDraw = private->base.pDraw;
DRI2BufferPtr *buffers;
- int i;
- int j;
+ int i, j, ret;
- buffers = DRI2GetBuffers(private->base.pDraw,
- width, height, attachments, count, out_count);
+ buffers = DRI2GetBuffers(pDraw, width, height, attachments,
+ count, out_count);
if (*out_count > MAX_DRAWABLE_BUFFERS) {
*out_count = 0;
return NULL;
}
-
+
+ ret = DRI2TrackClient(pDraw, 0, __glXDRIinvalidateEvent, NULL, private);
+ if (ret)
+ return NULL;
+
private->width = *width;
private->height = *height;
@@ -501,7 +510,7 @@ dri2GetBuffers(__DRIdrawable *driDrawable,
for (i = 0; i < *out_count; i++) {
/* Do not send the real front buffer of a window to the client.
*/
- if ((private->base.pDraw->type == DRAWABLE_WINDOW)
+ if ((pDraw->type == DRAWABLE_WINDOW)
&& (buffers[i]->attachment == DRI2BufferFrontLeft)) {
continue;
}
@@ -525,18 +534,22 @@ dri2GetBuffersWithFormat(__DRIdrawable *driDrawable,
int *out_count, void *loaderPrivate)
{
__GLXDRIdrawable *private = loaderPrivate;
+ DrawablePtr pDraw = private->base.pDraw;
DRI2BufferPtr *buffers;
- int i;
+ int i, ret;
int j = 0;
- buffers = DRI2GetBuffersWithFormat(private->base.pDraw,
- width, height, attachments, count,
- out_count);
+ buffers = DRI2GetBuffersWithFormat(pDraw, width, height, attachments,
+ count, out_count);
if (*out_count > MAX_DRAWABLE_BUFFERS) {
*out_count = 0;
return NULL;
}
+ ret = DRI2TrackClient(pDraw, 0, __glXDRIinvalidateEvent, NULL, private);
+ if (ret)
+ return NULL;
+
private->width = *width;
private->height = *height;
@@ -545,7 +558,7 @@ dri2GetBuffersWithFormat(__DRIdrawable *driDrawable,
for (i = 0; i < *out_count; i++) {
/* Do not send the real front buffer of a window to the client.
*/
- if ((private->base.pDraw->type == DRAWABLE_WINDOW)
+ if ((pDraw->type == DRAWABLE_WINDOW)
&& (buffers[i]->attachment == DRI2BufferFrontLeft)) {
continue;
}
--
1.6.4.4
More information about the xorg-devel
mailing list