diff options
author | Michal Krol <[email protected]> | 2010-03-10 15:49:30 +0100 |
---|---|---|
committer | Michal Krol <[email protected]> | 2010-03-10 15:49:30 +0100 |
commit | 3ce4375912c8ea488460e593e07c5bb15b92dca9 (patch) | |
tree | 1011fa439bd829fd46a44fd99478135848800e73 /src/mesa/drivers/x11/xm_api.c | |
parent | f59f28093ea827bd234d8e1a36bdd56a9fce5f09 (diff) | |
parent | 9b348d0ed125a22be3f318ac60cef6f201edfdab (diff) |
Merge branch 'master' into gallium-sampler-view
Conflicts:
src/gallium/auxiliary/Makefile
src/gallium/auxiliary/SConscript
src/gallium/auxiliary/tgsi/tgsi_exec.c
src/gallium/auxiliary/util/u_blitter.c
src/gallium/drivers/i915/i915_context.h
src/gallium/drivers/i965/brw_context.h
src/gallium/drivers/llvmpipe/lp_context.h
src/gallium/drivers/nv50/nv50_context.h
src/gallium/drivers/nv50/nv50_state_validate.c
src/gallium/drivers/nv50/nv50_tex.c
src/gallium/drivers/r300/r300_blit.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/softpipe/sp_context.h
src/gallium/drivers/svga/svga_context.h
src/gallium/drivers/svga/svga_pipe_sampler.c
Diffstat (limited to 'src/mesa/drivers/x11/xm_api.c')
-rw-r--r-- | src/mesa/drivers/x11/xm_api.c | 163 |
1 files changed, 73 insertions, 90 deletions
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index 1a5456e1be2..a1723fa37b1 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -253,7 +253,7 @@ bits_per_pixel( XMesaVisual xmv ) /* grab the bits/pixel value */ bitsPerPixel = img->bits_per_pixel; /* free the XImage */ - _mesa_free( img->data ); + free( img->data ); img->data = NULL; XMesaDestroyImage( img ); return bitsPerPixel; @@ -383,7 +383,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, */ b->frontxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual, GL_FALSE); if (!b->frontxrb) { - _mesa_free(b); + free(b); return NULL; } b->frontxrb->Parent = b; @@ -399,7 +399,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, b->backxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual, GL_TRUE); if (!b->backxrb) { /* XXX free front xrb too */ - _mesa_free(b); + free(b); return NULL; } b->backxrb->Parent = b; @@ -511,12 +511,12 @@ xmesa_free_buffer(XMesaBuffer buffer) static void copy_colortable_info(XMesaBuffer dst, const XMesaBuffer src) { - MEMCPY(dst->color_table, src->color_table, sizeof(src->color_table)); - MEMCPY(dst->pixel_to_r, src->pixel_to_r, sizeof(src->pixel_to_r)); - MEMCPY(dst->pixel_to_g, src->pixel_to_g, sizeof(src->pixel_to_g)); - MEMCPY(dst->pixel_to_b, src->pixel_to_b, sizeof(src->pixel_to_b)); + memcpy(dst->color_table, src->color_table, sizeof(src->color_table)); + memcpy(dst->pixel_to_r, src->pixel_to_r, sizeof(src->pixel_to_r)); + memcpy(dst->pixel_to_g, src->pixel_to_g, sizeof(src->pixel_to_g)); + memcpy(dst->pixel_to_b, src->pixel_to_b, sizeof(src->pixel_to_b)); dst->num_alloced = src->num_alloced; - MEMCPY(dst->alloced_colors, src->alloced_colors, + memcpy(dst->alloced_colors, src->alloced_colors, sizeof(src->alloced_colors)); } @@ -596,7 +596,7 @@ noFaultXAllocColor( int client, || prevCmapSize != cmapSize || !ctable) { /* free previously cached color table */ if (ctable) - _mesa_free(ctable); + free(ctable); /* Get the color table from X */ ctable = (XMesaColor *) MALLOC(cmapSize * sizeof(XMesaColor)); assert(ctable); @@ -652,8 +652,8 @@ noFaultXAllocColor( int client, *alloced = 0; } #ifdef XFree86Server - _mesa_free(ppixIn); - _mesa_free(ctable); + free(ppixIn); + free(ctable); #else /* don't free table, save it for next time */ #endif @@ -684,9 +684,7 @@ setup_grayscale(int client, XMesaVisual v, } prevBuffer = xmesa_find_buffer(v->display, cmap, buffer); - if (prevBuffer && - (buffer->xm_visual->mesa_visual.rgbMode == - prevBuffer->xm_visual->mesa_visual.rgbMode)) { + if (prevBuffer) { /* Copy colormap stuff from previous XMesaBuffer which uses same * X colormap. Do this to avoid time spent in noFaultXAllocColor. */ @@ -773,9 +771,7 @@ setup_dithered_color(int client, XMesaVisual v, } prevBuffer = xmesa_find_buffer(v->display, cmap, buffer); - if (prevBuffer && - (buffer->xm_visual->mesa_visual.rgbMode == - prevBuffer->xm_visual->mesa_visual.rgbMode)) { + if (prevBuffer) { /* Copy colormap stuff from previous, matching XMesaBuffer. * Do this to avoid time spent in noFaultXAllocColor. */ @@ -1047,10 +1043,11 @@ setup_monochrome( XMesaVisual v, XMesaBuffer b ) */ static GLboolean initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b, - GLboolean rgb_flag, XMesaDrawable window, + XMesaDrawable window, XMesaColormap cmap) { int client = 0; + const int xclass = v->mesa_visual.visualType; #ifdef XFree86Server client = (window) ? CLIENT_ID(window->id) : 0; @@ -1062,45 +1059,34 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b, v->BitsPerPixel = bits_per_pixel(v); assert(v->BitsPerPixel > 0); - if (rgb_flag == GL_FALSE) { - /* COLOR-INDEXED WINDOW: - * Even if the visual is TrueColor or DirectColor we treat it as - * being color indexed. This is weird but might be useful to someone. - */ - v->dithered_pf = v->undithered_pf = PF_Index; - v->mesa_visual.indexBits = GET_VISUAL_DEPTH(v); + /* RGB WINDOW: + * We support RGB rendering into almost any kind of visual. + */ + if (xclass == GLX_TRUE_COLOR || xclass == GLX_DIRECT_COLOR) { + setup_truecolor( v, b, cmap ); } - else { - /* RGB WINDOW: - * We support RGB rendering into almost any kind of visual. - */ - const int xclass = v->mesa_visual.visualType; - if (xclass == GLX_TRUE_COLOR || xclass == GLX_DIRECT_COLOR) { - setup_truecolor( v, b, cmap ); - } - else if (xclass == GLX_STATIC_GRAY && GET_VISUAL_DEPTH(v) == 1) { - setup_monochrome( v, b ); - } - else if (xclass == GLX_GRAY_SCALE || xclass == GLX_STATIC_GRAY) { - if (!setup_grayscale( client, v, b, cmap )) { - return GL_FALSE; - } - } - else if ((xclass == GLX_PSEUDO_COLOR || xclass == GLX_STATIC_COLOR) - && GET_VISUAL_DEPTH(v)>=4 && GET_VISUAL_DEPTH(v)<=16) { - if (!setup_dithered_color( client, v, b, cmap )) { - return GL_FALSE; - } + else if (xclass == GLX_STATIC_GRAY && GET_VISUAL_DEPTH(v) == 1) { + setup_monochrome( v, b ); + } + else if (xclass == GLX_GRAY_SCALE || xclass == GLX_STATIC_GRAY) { + if (!setup_grayscale( client, v, b, cmap )) { + return GL_FALSE; } - else { - _mesa_warning(NULL, "XMesa: RGB mode rendering not supported in given visual.\n"); + } + else if ((xclass == GLX_PSEUDO_COLOR || xclass == GLX_STATIC_COLOR) + && GET_VISUAL_DEPTH(v)>=4 && GET_VISUAL_DEPTH(v)<=16) { + if (!setup_dithered_color( client, v, b, cmap )) { return GL_FALSE; } - v->mesa_visual.indexBits = 0; + } + else { + _mesa_warning(NULL, "XMesa: RGB mode rendering not supported in given visual.\n"); + return GL_FALSE; + } + v->mesa_visual.indexBits = 0; - if (_mesa_getenv("MESA_NO_DITHER")) { - v->dithered_pf = v->undithered_pf; - } + if (_mesa_getenv("MESA_NO_DITHER")) { + v->dithered_pf = v->undithered_pf; } @@ -1110,12 +1096,12 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b, * reports bugs. */ if (_mesa_getenv("MESA_INFO")) { - _mesa_printf("X/Mesa visual = %p\n", (void *) v); - _mesa_printf("X/Mesa dithered pf = %u\n", v->dithered_pf); - _mesa_printf("X/Mesa undithered pf = %u\n", v->undithered_pf); - _mesa_printf("X/Mesa level = %d\n", v->mesa_visual.level); - _mesa_printf("X/Mesa depth = %d\n", GET_VISUAL_DEPTH(v)); - _mesa_printf("X/Mesa bits per pixel = %d\n", v->BitsPerPixel); + printf("X/Mesa visual = %p\n", (void *) v); + printf("X/Mesa dithered pf = %u\n", v->dithered_pf); + printf("X/Mesa undithered pf = %u\n", v->undithered_pf); + printf("X/Mesa level = %d\n", v->mesa_visual.level); + printf("X/Mesa depth = %d\n", GET_VISUAL_DEPTH(v)); + printf("X/Mesa bits per pixel = %d\n", v->BitsPerPixel); } if (b && window) { @@ -1359,6 +1345,10 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display, } #endif + /* Color-index rendering not supported. */ + if (!rgb_flag) + return NULL; + v = (XMesaVisual) CALLOC_STRUCT(xmesa_visual); if (!v) { return NULL; @@ -1366,17 +1356,17 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display, v->display = display; - /* Save a copy of the XVisualInfo struct because the user may X_mesa_free() + /* Save a copy of the XVisualInfo struct because the user may Xfree() * the struct but we may need some of the information contained in it * at a later time. */ #ifndef XFree86Server v->visinfo = (XVisualInfo *) MALLOC(sizeof(*visinfo)); if(!v->visinfo) { - _mesa_free(v); + free(v); return NULL; } - MEMCPY(v->visinfo, visinfo, sizeof(*visinfo)); + memcpy(v->visinfo, visinfo, sizeof(*visinfo)); #endif /* check for MESA_GAMMA environment variable */ @@ -1428,7 +1418,7 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display, if (alpha_flag) v->mesa_visual.alphaBits = 8; - (void) initialize_visual_and_buffer( v, NULL, rgb_flag, 0, 0 ); + (void) initialize_visual_and_buffer( v, NULL, 0, 0 ); { const int xclass = v->mesa_visual.visualType; @@ -1453,10 +1443,9 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display, } _mesa_initialize_visual( &v->mesa_visual, - rgb_flag, db_flag, stereo_flag, + db_flag, stereo_flag, red_bits, green_bits, blue_bits, alpha_bits, - v->mesa_visual.indexBits, depth_size, stencil_size, accum_red_size, accum_green_size, @@ -1473,9 +1462,9 @@ PUBLIC void XMesaDestroyVisual( XMesaVisual v ) { #ifndef XFree86Server - _mesa_free(v->visinfo); + free(v->visinfo); #endif - _mesa_free(v); + free(v); } @@ -1514,7 +1503,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) if (!_mesa_initialize_context(mesaCtx, &v->mesa_visual, share_list ? &(share_list->mesa) : (GLcontext *) NULL, &functions, (void *) c)) { - _mesa_free(c); + free(c); return NULL; } @@ -1564,7 +1553,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) !_tnl_CreateContext( mesaCtx ) || !_swsetup_CreateContext( mesaCtx )) { _mesa_free_context_data(&c->mesa); - _mesa_free(c); + free(c); return NULL; } @@ -1598,7 +1587,7 @@ void XMesaDestroyContext( XMesaContext c ) _tnl_DestroyContext( mesaCtx ); _vbo_DestroyContext( mesaCtx ); _mesa_free_context_data( mesaCtx ); - _mesa_free( c ); + free( c ); } @@ -1655,8 +1644,7 @@ XMesaCreateWindowBuffer(XMesaVisual v, XMesaWindow w) if (!b) return NULL; - if (!initialize_visual_and_buffer( v, b, v->mesa_visual.rgbMode, - (XMesaDrawable) w, cmap )) { + if (!initialize_visual_and_buffer( v, b, (XMesaDrawable) w, cmap )) { xmesa_free_buffer(b); return NULL; } @@ -1686,8 +1674,7 @@ XMesaCreatePixmapBuffer(XMesaVisual v, XMesaPixmap p, XMesaColormap cmap) if (!b) return NULL; - if (!initialize_visual_and_buffer(v, b, v->mesa_visual.rgbMode, - (XMesaDrawable) p, cmap)) { + if (!initialize_visual_and_buffer(v, b, (XMesaDrawable) p, cmap)) { xmesa_free_buffer(b); return NULL; } @@ -1747,8 +1734,7 @@ XMesaCreatePixmapTextureBuffer(XMesaVisual v, XMesaPixmap p, b->TextureFormat = format; b->TextureMipmap = mipmap; - if (!initialize_visual_and_buffer(v, b, v->mesa_visual.rgbMode, - (XMesaDrawable) p, cmap)) { + if (!initialize_visual_and_buffer(v, b, (XMesaDrawable) p, cmap)) { xmesa_free_buffer(b); return NULL; } @@ -1778,8 +1764,7 @@ XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap, if (!b) return NULL; - if (!initialize_visual_and_buffer(v, b, v->mesa_visual.rgbMode, - drawable, cmap)) { + if (!initialize_visual_and_buffer(v, b, drawable, cmap)) { xmesa_free_buffer(b); return NULL; } @@ -1874,19 +1859,17 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, &drawBuffer->mesa_buffer, &readBuffer->mesa_buffer); - if (c->xm_visual->mesa_visual.rgbMode) { - /* - * Must recompute and set these pixel values because colormap - * can be different for different windows. - */ - c->clearpixel = xmesa_color_to_pixel( &c->mesa, - c->clearcolor[0], - c->clearcolor[1], - c->clearcolor[2], - c->clearcolor[3], - c->xm_visual->undithered_pf); - XMesaSetForeground(c->display, drawBuffer->cleargc, c->clearpixel); - } + /* + * Must recompute and set these pixel values because colormap + * can be different for different windows. + */ + c->clearpixel = xmesa_color_to_pixel( &c->mesa, + c->clearcolor[0], + c->clearcolor[1], + c->clearcolor[2], + c->clearcolor[3], + c->xm_visual->undithered_pf); + XMesaSetForeground(c->display, drawBuffer->cleargc, c->clearpixel); /* Solution to Stephane Rehel's problem with glXReleaseBuffersMESA(): */ drawBuffer->wasCurrent = GL_TRUE; |