summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/egl_g3d/x11/native_ximage.c')
-rw-r--r--src/gallium/state_trackers/egl_g3d/x11/native_ximage.c100
1 files changed, 55 insertions, 45 deletions
diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c b/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c
index e02faa9b7b..d76107c47f 100644
--- a/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c
+++ b/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c
@@ -83,6 +83,7 @@ struct ximage_surface {
GC gc;
struct ximage_buffer buffers[NUM_NATIVE_ATTACHMENTS];
+ unsigned int sequence_number;
};
struct ximage_config {
@@ -260,6 +261,9 @@ ximage_surface_swap_buffers(struct native_surface *nsurf)
*xfront = *xback;
*xback = xtmp;
+ /* the front/back textures are swapped */
+ xsurf->sequence_number++;
+
return ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_FRONT_LEFT);
}
@@ -285,33 +289,29 @@ ximage_surface_update_geometry(struct native_surface *nsurf)
}
static boolean
-ximage_surface_validate(struct native_surface *nsurf,
- const enum native_attachment *natts,
- unsigned num_natts,
- struct pipe_texture **textures,
- int *width, int *height)
+ximage_surface_validate(struct native_surface *nsurf, uint attachment_mask,
+ unsigned int *seq_num, struct pipe_texture **textures,
+ int *width, int *height)
{
struct ximage_surface *xsurf = ximage_surface(nsurf);
- boolean error = FALSE;
- unsigned i;
+ boolean new_buffers = FALSE;
+ int att;
ximage_surface_update_geometry(&xsurf->base);
- if (textures)
- memset(textures, 0, sizeof(*textures) * num_natts);
-
- for (i = 0; i < num_natts; i++) {
- enum native_attachment natt = natts[i];
- struct ximage_buffer *xbuf = &xsurf->buffers[natt];
+ for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) {
+ struct ximage_buffer *xbuf = &xsurf->buffers[att];
- if (!xbuf)
+ /* delay the allocation */
+ if (!native_attachment_mask_test(attachment_mask, att))
continue;
/* reallocate the texture */
if (!xbuf->texture ||
xsurf->width != xbuf->texture->width0 ||
xsurf->height != xbuf->texture->height0) {
- if (ximage_surface_alloc_buffer(&xsurf->base, natt)) {
+ new_buffers = TRUE;
+ if (ximage_surface_alloc_buffer(&xsurf->base, att)) {
/* update ximage */
if (xbuf->ximage) {
xbuf->ximage->width = xbuf->transfer->width;
@@ -321,27 +321,24 @@ ximage_surface_validate(struct native_surface *nsurf,
}
}
- /* allocation failed */
- if (!xbuf->texture) {
- unsigned j;
- for (j = 0; j < i; j++)
- pipe_texture_reference(&textures[j], NULL);
- for (j = i; j < num_natts; j++)
- textures[j] = NULL;
- error = TRUE;
- break;
+ if (textures) {
+ textures[att] = NULL;
+ pipe_texture_reference(&textures[att], xbuf->texture);
}
-
- if (textures)
- pipe_texture_reference(&textures[i], xbuf->texture);
}
+ /* increase the sequence number so that caller knows */
+ if (new_buffers)
+ xsurf->sequence_number++;
+
+ if (seq_num)
+ *seq_num = xsurf->sequence_number;
if (width)
*width = xsurf->width;
if (height)
*height = xsurf->height;
- return !error;
+ return TRUE;
}
static void
@@ -603,6 +600,34 @@ ximage_display_get_configs(struct native_display *ndpy, int *num_configs)
return configs;
}
+static boolean
+ximage_display_is_pixmap_supported(struct native_display *ndpy,
+ EGLNativePixmapType pix,
+ const struct native_config *nconf)
+{
+ struct ximage_display *xdpy = ximage_display(ndpy);
+ enum pipe_format fmt;
+ uint depth;
+
+ depth = x11_drawable_get_depth(xdpy->xscr, (Drawable) pix);
+ switch (depth) {
+ case 32:
+ fmt = PIPE_FORMAT_A8R8G8B8_UNORM;
+ break;
+ case 24:
+ fmt = PIPE_FORMAT_X8R8G8B8_UNORM;
+ break;
+ case 16:
+ fmt = PIPE_FORMAT_R5G6B5_UNORM;
+ break;
+ default:
+ fmt = PIPE_FORMAT_NONE;
+ break;
+ }
+
+ return (fmt == nconf->color_format);
+}
+
static void
ximage_display_destroy(struct native_display *ndpy)
{
@@ -620,18 +645,8 @@ ximage_display_destroy(struct native_display *ndpy)
free(xdpy);
}
-static void
-ximage_display_flush_frontbuffer(void *dummy, struct pipe_surface *surf,
- void *context_private)
-{
- /* TODO get native surface from context private, and remove the callback */
- _eglLog(_EGL_WARNING, "flush_frontbuffer is not supplied");
-}
-
struct native_display *
-x11_create_ximage_display(EGLNativeDisplayType dpy,
- boolean use_xshm,
- native_flush_frontbuffer flush_frontbuffer)
+x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm)
{
struct ximage_display *xdpy;
@@ -660,17 +675,12 @@ x11_create_ximage_display(EGLNativeDisplayType dpy,
(use_xshm && x11_screen_support(xdpy->xscr, X11_SCREEN_EXTENSION_XSHM));
xdpy->winsys = create_sw_winsys();
- if (!flush_frontbuffer)
- flush_frontbuffer = ximage_display_flush_frontbuffer;
- xdpy->winsys->flush_frontbuffer =
- (void (*)(struct pipe_winsys *, struct pipe_surface *, void *))
- flush_frontbuffer;
-
xdpy->base.screen = softpipe_create_screen(xdpy->winsys);
xdpy->base.destroy = ximage_display_destroy;
xdpy->base.get_configs = ximage_display_get_configs;
+ xdpy->base.is_pixmap_supported = ximage_display_is_pixmap_supported;
xdpy->base.create_context = ximage_display_create_context;
xdpy->base.create_window_surface = ximage_display_create_window_surface;
xdpy->base.create_pixmap_surface = ximage_display_create_pixmap_surface;