summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-10-07 09:40:04 -0600
committerBrian Paul <[email protected]>2009-10-07 09:41:38 -0600
commit0526100a5cbd928fa28d38abdafd6beb024b0828 (patch)
tree455ba927c1c9a29fe3c2190562d89a04a9dcce68 /src
parentf36425b569953de862ecd8f42ecd54831ad9c4a6 (diff)
gallium/xlib: fix glXQueryDrawable() bugs, see bug 24320
Diffstat (limited to 'src')
-rw-r--r--src/gallium/state_trackers/glx/xlib/glx_api.c38
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_api.c2
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_api.h7
3 files changed, 34 insertions, 13 deletions
diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c
index 3277ff58a6c..556eefb1b17 100644
--- a/src/gallium/state_trackers/glx/xlib/glx_api.c
+++ b/src/gallium/state_trackers/glx/xlib/glx_api.c
@@ -1992,32 +1992,42 @@ glXCreatePbuffer( Display *dpy, GLXFBConfig config,
break;
case GLX_PRESERVED_CONTENTS:
attrib++;
- preserveContents = *attrib; /* ignored */
+ preserveContents = *attrib;
break;
case GLX_LARGEST_PBUFFER:
attrib++;
- useLargest = *attrib; /* ignored */
+ useLargest = *attrib;
break;
default:
return 0;
}
}
- /* not used at this time */
- (void) useLargest;
- (void) preserveContents;
-
if (width == 0 || height == 0)
return 0;
+ if (width > MAX_WIDTH || height > MAX_HEIGHT) {
+ /* If allocation would have failed and GLX_LARGEST_PBUFFER is set,
+ * allocate the largest possible buffer.
+ */
+ if (useLargest) {
+ width = MAX_WIDTH;
+ height = MAX_HEIGHT;
+ }
+ }
+
xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height);
/* A GLXPbuffer handle must be an X Drawable because that's what
* glXMakeCurrent takes.
*/
- if (xmbuf)
+ if (xmbuf) {
+ xmbuf->largestPbuffer = useLargest;
+ xmbuf->preservedContents = preserveContents;
return (GLXPbuffer) xmbuf->drawable;
- else
+ }
+ else {
return 0;
+ }
}
@@ -2035,22 +2045,26 @@ void
glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
unsigned int *value )
{
+ GLuint width, height;
XMesaBuffer xmbuf = XMesaFindBuffer(dpy, draw);
if (!xmbuf)
return;
+ /* make sure buffer's dimensions are up to date */
+ xmesa_get_window_size(dpy, xmbuf, &width, &height);
+
switch (attribute) {
case GLX_WIDTH:
- *value = xmesa_buffer_width(xmbuf);
+ *value = width;
break;
case GLX_HEIGHT:
- *value = xmesa_buffer_width(xmbuf);
+ *value = height;
break;
case GLX_PRESERVED_CONTENTS:
- *value = True;
+ *value = xmbuf->preservedContents;
break;
case GLX_LARGEST_PBUFFER:
- *value = xmesa_buffer_width(xmbuf) * xmesa_buffer_height(xmbuf);
+ *value = xmbuf->largestPbuffer;
break;
case GLX_FBCONFIG_ID:
*value = xmbuf->xm_visual->visinfo->visualid;
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c
index 957002ddd55..c76dfb31d2b 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -228,7 +228,7 @@ get_drawable_size( Display *dpy, Drawable d, uint *width, uint *height )
* \param width returns width in pixels
* \param height returns height in pixels
*/
-static void
+void
xmesa_get_window_size(Display *dpy, XMesaBuffer b,
GLuint *width, GLuint *height)
{
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.h b/src/gallium/state_trackers/glx/xlib/xm_api.h
index ce97a3ec768..d24971ca1c7 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.h
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.h
@@ -323,6 +323,9 @@ struct xmesa_buffer {
Colormap cmap; /* the X colormap */
BufferType type; /* window, pixmap, pbuffer or glxwindow */
+ GLboolean largestPbuffer; /**< for pbuffers */
+ GLboolean preservedContents; /**< for pbuffers */
+
XImage *tempImage;
unsigned long selectedEvents;/* for pbuffers only */
@@ -370,6 +373,10 @@ extern XMesaBuffer
xmesa_find_buffer(Display *dpy, Colormap cmap, XMesaBuffer notThis);
extern void
+xmesa_get_window_size(Display *dpy, XMesaBuffer b,
+ GLuint *width, GLuint *height);
+
+extern void
xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer);
extern void