From 3425257e14e3f4b1f663649856f73b520726db9b Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 12 Jan 2009 11:52:13 +0000 Subject: dri: rename dri1 directory --- src/gallium/state_trackers/glx/dri/dri_drawable.c | 63 +++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/gallium/state_trackers/glx/dri/dri_drawable.c (limited to 'src/gallium/state_trackers/glx/dri/dri_drawable.c') diff --git a/src/gallium/state_trackers/glx/dri/dri_drawable.c b/src/gallium/state_trackers/glx/dri/dri_drawable.c new file mode 100644 index 0000000000..7503c40194 --- /dev/null +++ b/src/gallium/state_trackers/glx/dri/dri_drawable.c @@ -0,0 +1,63 @@ + +/** + * This is called when we need to set up GL rendering to a new X window. + */ +static boolean +dri_create_buffer(__DRIscreenPrivate *sPriv, + __DRIdrawablePrivate *dPriv, + const __GLcontextModes *visual, + boolean isPixmap) +{ + enum pipe_format colorFormat, depthFormat, stencilFormat; + struct dri_drawable *drawable; + + if (isPixmap) + goto fail; /* not implemented */ + + drawable = CALLOC_STRUCT(dri_drawable); + if (drawable == NULL) + goto fail; + + /* XXX: todo: use the pipe_screen queries to figure out which + * render targets are supportable. + */ + if (visual->redBits == 5) + colorFormat = PIPE_FORMAT_R5G6B5_UNORM; + else + colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM; + + if (visual->depthBits == 16) + depthFormat = PIPE_FORMAT_Z16_UNORM; + else if (visual->depthBits == 24) { + if (visual->stencilBits == 8) + depthFormat = PIPE_FORMAT_S8Z24_UNORM; + else + depthFormat = PIPE_FORMAT_X8Z24_UNORM; + } + + drawable->stfb = st_create_framebuffer(visual, + colorFormat, + depthFormat, + dPriv->w, + dPriv->h, + (void*) drawable); + if (drawable->stfb == NULL) + goto fail; + + dPriv->driverPrivate = (void *) drawable; + return GL_TRUE; + +fail: + FREE(drawable); + return GL_FALSE; +} + +static void +dri_destroy_buffer(__DRIdrawablePrivate *dPriv) +{ + struct dri_drawable *drawable = dri_drawable(dPriv); + assert(drawable->stfb); + st_unreference_framebuffer(drawable->stfb); + FREE(drawable); +} + -- cgit v1.2.3