aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2008-05-30 11:42:08 -0600
committerBrian Paul <[email protected]>2008-05-30 11:47:09 -0600
commit750782a327a1d295f4ed00a590c362f32912d597 (patch)
tree3ee035439e0d3e230d4d2c350f0b98c609e95507 /src
parent057ee55720faee0e1269937d70bbafe6df5c57e6 (diff)
egl: assorted fixes. The code works now.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/winsys/egl_xlib/egl_xlib.c67
1 files changed, 60 insertions, 7 deletions
diff --git a/src/gallium/winsys/egl_xlib/egl_xlib.c b/src/gallium/winsys/egl_xlib/egl_xlib.c
index 4741da87cd2..555bb8b7b49 100644
--- a/src/gallium/winsys/egl_xlib/egl_xlib.c
+++ b/src/gallium/winsys/egl_xlib/egl_xlib.c
@@ -176,6 +176,28 @@ xlib_eglTerminate(_EGLDriver *drv, EGLDisplay dpy)
}
+static void
+get_drawable_visual_info(Display *dpy, Drawable d, XVisualInfo *visInfo)
+{
+ XWindowAttributes attr;
+ XVisualInfo visTemp, *vis;
+ int num_visuals;
+
+ XGetWindowAttributes(dpy, d, &attr);
+
+ visTemp.screen = DefaultScreen(dpy);
+ visTemp.visualid = attr.visual->visualid;
+ vis = XGetVisualInfo(dpy,
+ (VisualScreenMask | VisualIDMask),
+ &visTemp, &num_visuals);
+ if (vis)
+ *visInfo = *vis;
+
+ XFree(vis);
+}
+
+
+
/** Get size of given window */
static Status
get_drawable_size(Display *dpy, Drawable d, uint *width, uint *height)
@@ -192,6 +214,16 @@ get_drawable_size(Display *dpy, Drawable d, uint *width, uint *height)
static void
+check_and_update_buffer_size(struct xlib_egl_surface *surface)
+{
+ uint width, height;
+ get_drawable_size(surface->Dpy, surface->Win, &width, &height);
+ st_resize_framebuffer(surface->Framebuffer, width, height);
+}
+
+
+
+static void
display_surface(struct pipe_winsys *pws,
struct pipe_surface *psurf,
struct xlib_egl_surface *xsurf)
@@ -223,6 +255,8 @@ display_surface(struct pipe_winsys *pws,
XPutImage(xsurf->Dpy, xsurf->Win, xsurf->Gc,
ximage, 0, 0, 0, 0, psurf->width, psurf->height);
+ XSync(xsurf->Dpy, 0);
+
ximage->data = NULL;
XDestroyImage(ximage);
@@ -303,13 +337,21 @@ xlib_eglDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx)
* Called via eglMakeCurrent(), drv->API.MakeCurrent().
*/
static EGLBoolean
-xlib_eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d,
- EGLSurface r, EGLContext context)
+xlib_eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy,
+ EGLSurface draw, EGLSurface read, EGLContext ctx)
{
- if (!_eglMakeCurrent(drv, dpy, d, r, context))
+ struct xlib_egl_context *context = lookup_context(ctx);
+ struct xlib_egl_surface *draw_surf = lookup_surface(draw);
+ struct xlib_egl_surface *read_surf = lookup_surface(read);
+
+ if (!_eglMakeCurrent(drv, dpy, draw, read, context))
return EGL_FALSE;
- /* XXX anything todo? */
+ st_make_current((context ? context->Context : NULL),
+ (draw_surf ? draw_surf->Framebuffer : NULL),
+ (read_surf ? read_surf->Framebuffer : NULL));
+
+ check_and_update_buffer_size(draw_surf);
return EGL_TRUE;
}
@@ -336,7 +378,7 @@ static enum pipe_format
choose_depth_format(const __GLcontextModes *visual)
{
if (visual->depthBits > 0)
- return PIPE_FORMAT_Z24S8_UNORM;
+ return PIPE_FORMAT_S8Z24_UNORM;
else
return PIPE_FORMAT_NONE;
}
@@ -346,7 +388,7 @@ static enum pipe_format
choose_stencil_format(const __GLcontextModes *visual)
{
if (visual->stencilBits > 0)
- return PIPE_FORMAT_Z24S8_UNORM;
+ return PIPE_FORMAT_S8Z24_UNORM;
else
return PIPE_FORMAT_NONE;
}
@@ -378,6 +420,8 @@ xlib_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
return EGL_NO_SURFACE;
}
+ _eglSaveSurface(&surf->Base);
+
/*
* Now init the Xlib and gallium stuff
*/
@@ -389,6 +433,10 @@ xlib_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
_eglConfigToContextModesRec(conf, &visual);
get_drawable_size(surf->Dpy, surf->Win, &width, &height);
+ get_drawable_visual_info(surf->Dpy, surf->Win, &surf->VisInfo);
+
+ surf->Base.Width = width;
+ surf->Base.Height = height;
/* Create GL statetracker framebuffer */
surf->Framebuffer = st_create_framebuffer(&visual,
@@ -397,7 +445,10 @@ xlib_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
choose_stencil_format(&visual),
width, height,
(void *) surf);
- return surf;
+
+ st_resize_framebuffer(surf->Framebuffer, width, height);
+
+ return _eglGetSurfaceHandle(&surf->Base);
}
@@ -414,6 +465,8 @@ xlib_eglSwapBuffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw)
struct pipe_surface *psurf =
st_get_framebuffer_surface(xsurf->Framebuffer, ST_SURFACE_BACK_LEFT);
+ st_notify_swapbuffers(xsurf->Framebuffer);
+
display_surface(pws, psurf, xsurf);
}