📄 xm_dd.c
字号:
break; default: ; /* silence compiler warning */ }}static voidclear_color_HPCR_ximage( GLcontext *ctx, const GLfloat color[4] ){ int i; const XMesaContext xmesa = XMESA_CONTEXT(ctx); CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]); CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]); CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]); CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]); if (color[0] == 0.0 && color[1] == 0.0 && color[2] == 0.0) { /* black is black */ MEMSET( xmesa->xm_visual->hpcr_clear_ximage_pattern, 0x0 , sizeof(xmesa->xm_visual->hpcr_clear_ximage_pattern)); } else { /* build clear pattern */ for (i=0; i<16; i++) { xmesa->xm_visual->hpcr_clear_ximage_pattern[0][i] = DITHER_HPCR(i, 0, xmesa->clearcolor[0], xmesa->clearcolor[1], xmesa->clearcolor[2]); xmesa->xm_visual->hpcr_clear_ximage_pattern[1][i] = DITHER_HPCR(i, 1, xmesa->clearcolor[0], xmesa->clearcolor[1], xmesa->clearcolor[2]); } }}static voidclear_color_HPCR_pixmap( GLcontext *ctx, const GLfloat color[4] ){ int i; const XMesaContext xmesa = XMESA_CONTEXT(ctx); CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]); CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]); CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]); CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]); if (color[0] == 0.0 && color[1] == 0.0 && color[2] == 0.0) { /* black is black */ for (i=0; i<16; i++) { XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 0, 0); XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 1, 0); } } else { for (i=0; i<16; i++) { XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 0, DITHER_HPCR(i, 0, xmesa->clearcolor[0], xmesa->clearcolor[1], xmesa->clearcolor[2])); XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 1, DITHER_HPCR(i, 1, xmesa->clearcolor[0], xmesa->clearcolor[1], xmesa->clearcolor[2])); } } /* change tile pixmap content */ XMesaPutImage(xmesa->display, (XMesaDrawable)xmesa->xm_visual->hpcr_clear_pixmap, XMESA_BUFFER(ctx->DrawBuffer)->cleargc, xmesa->xm_visual->hpcr_clear_ximage, 0, 0, 0, 0, 16, 2);}/** * Called when the driver should update its state, based on the new_state * flags. */voidxmesa_update_state( GLcontext *ctx, GLbitfield new_state ){ const XMesaContext xmesa = XMESA_CONTEXT(ctx); /* Propagate statechange information to swrast and swrast_setup * modules. The X11 driver has no internal GL-dependent state. */ _swrast_InvalidateState( ctx, new_state ); _tnl_InvalidateState( ctx, new_state ); _vbo_InvalidateState( ctx, new_state ); _swsetup_InvalidateState( ctx, new_state ); if (ctx->DrawBuffer->Name != 0) return; /* * GL_DITHER, GL_READ/DRAW_BUFFER, buffer binding state, etc. effect * renderbuffer span/clear funcs. */ if (new_state & (_NEW_COLOR | _NEW_PIXEL | _NEW_BUFFERS)) { XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer); struct xmesa_renderbuffer *front_xrb, *back_xrb; front_xrb = xmbuf->frontxrb; if (front_xrb) { xmesa_set_renderbuffer_funcs(front_xrb, xmesa->pixelformat, xmesa->xm_visual->BitsPerPixel); front_xrb->clearFunc = clear_pixmap; } back_xrb = xmbuf->backxrb; if (back_xrb) { xmesa_set_renderbuffer_funcs(back_xrb, xmesa->pixelformat, xmesa->xm_visual->BitsPerPixel); if (xmbuf->backxrb->pixmap) { back_xrb->clearFunc = clear_pixmap; } else { switch (xmesa->xm_visual->BitsPerPixel) { case 8: if (xmesa->xm_visual->hpcr_clear_flag) { back_xrb->clearFunc = clear_HPCR_ximage; } else { back_xrb->clearFunc = clear_8bit_ximage; } break; case 16: back_xrb->clearFunc = clear_16bit_ximage; break; case 24: back_xrb->clearFunc = clear_24bit_ximage; break; case 32: back_xrb->clearFunc = clear_32bit_ximage; break; default: back_xrb->clearFunc = clear_nbit_ximage; break; } } } } if (xmesa->xm_visual->hpcr_clear_flag) { /* this depends on whether we're drawing to the front or back buffer */ /* XXX FIX THIS! */#if 0 if (pixmap) { ctx->Driver.ClearColor = clear_color_HPCR_pixmap; } else { ctx->Driver.ClearColor = clear_color_HPCR_ximage; }#else (void) clear_color_HPCR_pixmap; (void) clear_color_HPCR_ximage;#endif }}/** * Called via ctx->Driver.TestProxyTeximage(). Normally, we'd just use * the _mesa_test_proxy_teximage() fallback function, but we're going to * special-case the 3D texture case to allow textures up to 512x512x32 * texels. */static GLbooleantest_proxy_teximage(GLcontext *ctx, GLenum target, GLint level, GLint internalFormat, GLenum format, GLenum type, GLint width, GLint height, GLint depth, GLint border){ if (target == GL_PROXY_TEXTURE_3D) { /* special case for 3D textures */ if (width * height * depth > 512 * 512 * 64 || width < 2 * border || (!ctx->Extensions.ARB_texture_non_power_of_two && _mesa_bitcount(width - 2 * border) != 1) || height < 2 * border || (!ctx->Extensions.ARB_texture_non_power_of_two && _mesa_bitcount(height - 2 * border) != 1) || depth < 2 * border || (!ctx->Extensions.ARB_texture_non_power_of_two && _mesa_bitcount(depth - 2 * border) != 1)) { /* Bad size, or too many texels */ return GL_FALSE; } return GL_TRUE; } else { /* use the fallback routine for 1D, 2D, cube and rect targets */ return _mesa_test_proxy_teximage(ctx, target, level, internalFormat, format, type, width, height, depth, border); }}/** * In SW, we don't really compress GL_COMPRESSED_RGB[A] textures! */static const struct gl_texture_format *choose_tex_format( GLcontext *ctx, GLint internalFormat, GLenum format, GLenum type ){ switch (internalFormat) { case GL_COMPRESSED_RGB_ARB: return &_mesa_texformat_rgb; case GL_COMPRESSED_RGBA_ARB: return &_mesa_texformat_rgba; default: return _mesa_choose_tex_format(ctx, internalFormat, format, type); }}/** * Called by glViewport. * This is a good time for us to poll the current X window size and adjust * our renderbuffers to match the current window size. * Remember, we have no opportunity to respond to conventional * X Resize/StructureNotify events since the X driver has no event loop. * Thus, we poll. * Note that this trick isn't fool-proof. If the application never calls * glViewport, our notion of the current window size may be incorrect. * That problem led to the GLX_MESA_resize_buffers extension. */static voidxmesa_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h){ XMesaContext xmctx = XMESA_CONTEXT(ctx); XMesaBuffer xmdrawbuf = XMESA_BUFFER(ctx->WinSysDrawBuffer); XMesaBuffer xmreadbuf = XMESA_BUFFER(ctx->WinSysReadBuffer); xmesa_check_and_update_buffer_size(xmctx, xmdrawbuf); xmesa_check_and_update_buffer_size(xmctx, xmreadbuf); (void) x; (void) y; (void) w; (void) h;}#if ENABLE_EXT_timer_query/* * The GL_EXT_timer_query extension is not enabled for the XServer * indirect renderer. Not sure about how/if wrapping of gettimeofday() * is done, etc. */struct xmesa_query_object{ struct gl_query_object Base; struct timeval StartTime;};static struct gl_query_object *xmesa_new_query_object(GLcontext *ctx, GLuint id){ struct xmesa_query_object *q = CALLOC_STRUCT(xmesa_query_object); if (q) { q->Base.Id = id; q->Base.Ready = GL_TRUE; } return &q->Base;}static voidxmesa_begin_query(GLcontext *ctx, GLenum target, struct gl_query_object *q){ if (target == GL_TIME_ELAPSED_EXT) { struct xmesa_query_object *xq = (struct xmesa_query_object *) q; (void) gettimeofday(&xq->StartTime, NULL); }}/** * Return the difference between the two given times in microseconds. */#ifdef __VMS#define suseconds_t unsigned int#endifstatic GLuint64EXTtime_diff(const struct timeval *t0, const struct timeval *t1){ GLuint64EXT seconds0 = t0->tv_sec & 0xff; /* 0 .. 255 seconds */ GLuint64EXT seconds1 = t1->tv_sec & 0xff; /* 0 .. 255 seconds */ GLuint64EXT nanosec0 = (seconds0 * 1000000 + t0->tv_usec) * 1000; GLuint64EXT nanosec1 = (seconds1 * 1000000 + t1->tv_usec) * 1000; return nanosec1 - nanosec0;}static voidxmesa_end_query(GLcontext *ctx, GLenum target, struct gl_query_object *q){ if (target == GL_TIME_ELAPSED_EXT) { struct xmesa_query_object *xq = (struct xmesa_query_object *) q; struct timeval endTime; (void) gettimeofday(&endTime, NULL); /* result is in nanoseconds! */ q->Result = time_diff(&xq->StartTime, &endTime); } q->Ready = GL_TRUE;}#endif /* ENABLE_timer_query *//** * Initialize the device driver function table with the functions * we implement in this driver. */voidxmesa_init_driver_functions( XMesaVisual xmvisual, struct dd_function_table *driver ){ driver->GetString = get_string; driver->UpdateState = xmesa_update_state; driver->GetBufferSize = NULL; /* OBSOLETE */ driver->Flush = finish_or_flush; driver->Finish = finish_or_flush; driver->ClearIndex = clear_index; driver->ClearColor = clear_color; driver->IndexMask = index_mask; driver->ColorMask = color_mask; driver->Enable = enable; driver->Clear = clear_buffers; driver->Viewport = xmesa_viewport;#ifndef XFree86Server driver->CopyPixels = xmesa_CopyPixels; if (xmvisual->undithered_pf == PF_8R8G8B && xmvisual->dithered_pf == PF_8R8G8B && xmvisual->BitsPerPixel == 32) { driver->DrawPixels = xmesa_DrawPixels_8R8G8B; } else if (xmvisual->undithered_pf == PF_5R6G5B) { driver->DrawPixels = xmesa_DrawPixels_5R6G5B; }#endif driver->TestProxyTexImage = test_proxy_teximage;#if ENABLE_EXT_texure_compression_s3tc driver->ChooseTextureFormat = choose_tex_format;#else (void) choose_tex_format;#endif#if ENABLE_EXT_timer_query driver->NewQueryObject = xmesa_new_query_object; driver->BeginQuery = xmesa_begin_query; driver->EndQuery = xmesa_end_query;#endif}#define XMESA_NEW_POINT (_NEW_POINT | \ _NEW_RENDERMODE | \ _SWRAST_NEW_RASTERMASK)#define XMESA_NEW_LINE (_NEW_LINE | \ _NEW_TEXTURE | \ _NEW_LIGHT | \ _NEW_DEPTH | \ _NEW_RENDERMODE | \ _SWRAST_NEW_RASTERMASK)#define XMESA_NEW_TRIANGLE (_NEW_POLYGON | \ _NEW_TEXTURE | \ _NEW_LIGHT | \ _NEW_DEPTH | \ _NEW_RENDERMODE | \ _SWRAST_NEW_RASTERMASK)/** * Extend the software rasterizer with our line/point/triangle * functions. * Called during context creation only. */void xmesa_register_swrast_functions( GLcontext *ctx ){ SWcontext *swrast = SWRAST_CONTEXT( ctx ); swrast->choose_point = xmesa_choose_point; swrast->choose_line = xmesa_choose_line; swrast->choose_triangle = xmesa_choose_triangle; /* XXX these lines have no net effect. Remove??? */ swrast->InvalidatePointMask |= XMESA_NEW_POINT; swrast->InvalidateLineMask |= XMESA_NEW_LINE; swrast->InvalidateTriangleMask |= XMESA_NEW_TRIANGLE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -