summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/egl_g3d/x11/x11_screen.c')
-rw-r--r--src/gallium/state_trackers/egl_g3d/x11/x11_screen.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c
index 1e98943242..4d68a88d2e 100644
--- a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c
+++ b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c
@@ -30,6 +30,7 @@
#include <X11/extensions/XShm.h>
#include "util/u_memory.h"
#include "util/u_math.h"
+#include "util/u_format.h"
#include "xf86drm.h"
#include "egllog.h"
@@ -50,6 +51,10 @@ struct x11_screen {
XVisualInfo *visuals;
int num_visuals;
+
+ /* cached values for x11_drawable_get_depth */
+ Drawable last_drawable;
+ unsigned int last_depth;
};
@@ -351,6 +356,37 @@ x11_drawable_get_buffers(struct x11_screen *xscr, Drawable drawable,
}
/**
+ * Return the depth of a drawable.
+ *
+ * Unlike other drawable functions, the drawable needs not be a DRI2 drawable.
+ */
+uint
+x11_drawable_get_depth(struct x11_screen *xscr, Drawable drawable)
+{
+ unsigned int depth;
+
+ if (drawable != xscr->last_drawable) {
+ Window root;
+ int x, y;
+ unsigned int w, h, border;
+ Status ok;
+
+ ok = XGetGeometry(xscr->dpy, drawable, &root,
+ &x, &y, &w, &h, &border, &depth);
+ if (!ok)
+ depth = 0;
+
+ xscr->last_drawable = drawable;
+ xscr->last_depth = depth;
+ }
+ else {
+ depth = xscr->last_depth;
+ }
+
+ return depth;
+}
+
+/**
* Create a mode list of the given size.
*/
__GLcontextModes *