diff options
Diffstat (limited to 'x11-dri2.c')
-rw-r--r-- | x11-dri2.c | 39 |
1 files changed, 27 insertions, 12 deletions
@@ -1,5 +1,5 @@ /* - * Copyright © 2008 Kristian Høgsberg + * Copyright © 2008, 2009 Kristian Høgsberg * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -49,22 +49,35 @@ x11GetBuffers(EGLSurface surface, uint32_t *attachments, int count) EGLDisplayX11 x11Display = (EGLDisplayX11) surface->display; EGLSurfaceX11 x11Surface = (EGLSurfaceX11) surface; DRI2Buffer *buffers; - int i, outCount; + uint32_t x11Attachments[10]; + int i, j, outCount; + + /* Make sure we ask for a back buffer regardless of the config + * in use and remap the buffers so the dri driver renders to + * the back buffer in all cases. We should only do this for + * Windows */ + + for (i = 0, j = 0; i < count; i++, j++) { + if (i == 1 && attachments[i] != __DRI_BUFFER_BACK_LEFT) + x11Attachments[j++] = __DRI_BUFFER_BACK_LEFT; + x11Attachments[j] = attachments[i]; + } buffers = DRI2GetBuffers(x11Display->display, x11Surface->drawable, &surface->width, &surface->height, - attachments, count, &outCount); + x11Attachments, j, &outCount); - for (i = 0; i < outCount; i++) { - surface->buffers[i].attachment = buffers[i].attachment; - surface->buffers[i].name = buffers[i].name; - surface->buffers[i].pitch = buffers[i].pitch; - surface->buffers[i].cpp = buffers[i].cpp; + for (j = j - i, i = 0; i < count; i++, j++) { + surface->buffers[i].attachment = buffers[j].attachment; + surface->buffers[i].name = buffers[j].name; + surface->buffers[i].pitch = buffers[j].pitch; + surface->buffers[i].cpp = buffers[j].cpp; } + surface->buffers[0].attachment = __DRI_BUFFER_FRONT_LEFT; - surface->count = outCount; + surface->count = count; XFree(buffers); } @@ -83,7 +96,7 @@ x11SwapBuffers(EGLDisplay display, EGLSurface surface) rect.height = surface->height; region = XFixesCreateRegion(x11Display->display, &rect, 1); DRI2CopyRegion(x11Display->display, x11Surface->drawable, - region, DRI2BufferBackLeft, DRI2BufferFrontLeft); + region, DRI2BufferFrontLeft, DRI2BufferBackLeft); XFixesDestroyRegion(x11Display->display, region); return EGL_TRUE; @@ -132,8 +145,7 @@ eglCreateDisplayX11(Display *display, Window root) x11Display->errorBase = errorBase; x11Display->display = display; - /* Get ude*/ - if (eglInitDisplay(&x11Display->base, NULL, driverName) < 0) { + if (eglInitDisplay(&x11Display->base, deviceName, driverName) < 0) { free(x11Display); return NULL; } @@ -155,6 +167,7 @@ eglCreateSurfaceX11(EGLDisplay display, EGLConfig config, Window window, int width, int height) { EGLSurfaceX11 x11Surface; + EGLDisplayX11 x11Display = (EGLDisplayX11) display; x11Surface = malloc(sizeof *x11Surface); if (x11Surface == NULL) @@ -164,5 +177,7 @@ eglCreateSurfaceX11(EGLDisplay display, EGLConfig config, eglInitSurface(&x11Surface->base, display, config, width, height); + DRI2CreateDrawable(x11Display->display, x11Surface->drawable); + return &x11Surface->base; } |