xmesa_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
GLenum internalFormat, GLuint width, GLuint height)
{
- struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb);
/* just clear these to be sure we don't accidentally use them */
xrb->origin1 = NULL;
xmesa_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
GLenum internalFormat, GLuint width, GLuint height)
{
- struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb);
/* same as front buffer */
(void) xmesa_alloc_front_storage(ctx, rb, internalFormat, width, height);
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
if (all) {
- GLint i, c16 = (xrb->ximage->bytes_per_line>>4)<<4;
+ const GLuint c16 = xrb->ximage->bytes_per_line & ~0xf;
+ GLuint i;
GLubyte *ptr = (GLubyte *) xrb->ximage->data;
for (i = 0; i < xrb->Base.Height; i++) {
- GLint j;
- GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0];
+ GLuint j;
+ const GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0];
if (i&1) {
sptr += 16;
}
ptr[15] = sptr[15];
ptr += 16;
}
- for (; j < xrb->ximage->bytes_per_line; j++) {
+ for (; j < (GLuint) xrb->ximage->bytes_per_line; j++) {
*ptr = sptr[j&15];
ptr++;
}
if (ctx->DrawBuffer->Name == 0) {
/* this is a window system framebuffer */
const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
- XMesaBuffer b = (XMesaBuffer) ctx->DrawBuffer;
+ XMesaBuffer b = XMESA_BUFFER(ctx->DrawBuffer);
/* we can't handle color or index masking */
if (*colorMask == 0xffffffff && ctx->Color.IndexMask == 0xffffffff) {
if (mask & BUFFER_BIT_FRONT_LEFT) {
/* clear front color buffer */
- if (b->frontxrb == (struct xmesa_renderbuffer *)
- ctx->DrawBuffer->Attachment[BUFFER_FRONT_LEFT].Renderbuffer) {
+ struct gl_renderbuffer *frontRb
+ = ctx->DrawBuffer->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
+ if (b->frontxrb == xmesa_renderbuffer(frontRb)) {
/* renderbuffer is not wrapped - great! */
b->frontxrb->clearFunc(ctx, b->frontxrb, all, x, y,
width, height);
}
if (mask & BUFFER_BIT_BACK_LEFT) {
/* clear back color buffer */
- if (b->backxrb == (struct xmesa_renderbuffer *)
- ctx->DrawBuffer->Attachment[BUFFER_BACK_LEFT].Renderbuffer) {
+ struct gl_renderbuffer *backRb
+ = ctx->DrawBuffer->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
+ if (b->backxrb == xmesa_renderbuffer(backRb)) {
/* renderbuffer is not wrapped - great! */
b->backxrb->clearFunc(ctx, b->backxrb, all, x, y,
width, height);
const GLvoid *pixels )
{
struct xmesa_renderbuffer *xrb
- = (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+ = (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const SWcontext *swrast = SWRAST_CONTEXT( ctx );
* 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 void
xmesa_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
{
+ (void) x;
+ (void) y;
+ (void) w;
+ (void) h;
update_framebuffer_size(ctx);
}
#define GET_XRB(XRB) struct xmesa_renderbuffer *XRB = \
- (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped
+ xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped)
/*
XMesaContext xmesa = XMESA_CONTEXT(ctx);
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaGC gc = xmesa->xm_buffer->gc;
- struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *)
- ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+ GET_XRB(xrb);
unsigned long pixel = xmesa_color_to_pixel(ctx,
vert1->color[0], vert1->color[1],
vert1->color[2], vert1->color[3],
if (ctx->Line.StippleFlag) return (swrast_line_func) NULL;
if (swrast->_RasterMask & MULTI_DRAW_BIT) return (swrast_line_func) NULL;
- xrb = (struct xmesa_renderbuffer *)
- ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped;
+ xrb = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped);
if (xrb->ximage
&& swrast->_RasterMask==DEPTH_BIT
#define GET_XRB(XRB) struct xmesa_renderbuffer *XRB = \
- (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped
+ xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped)
/**********************************************************************/
/**********************************************************************/
+#if CHAN_BITS == 8
+
/*
* XImage, smooth, depth-buffered, PF_TRUECOLOR triangle.
*/
#include "swrast/s_tritemp.h"
+#endif /* CHAN_BITS == 8 */
-#ifdef DEBUG
+
+#if defined(DEBUG) && CHAN_BITS == 8
extern void _xmesa_print_triangle_func( swrast_tri_func triFunc );
void _xmesa_print_triangle_func( swrast_tri_func triFunc )
{
triFuncName = NULL;
#endif
+#if CHAN_BITS == 8
+ /* trivial fallback tests */
if ((ctx->DrawBuffer->_ColorDrawBufferMask[0]
& (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) == 0)
return (swrast_tri_func) NULL;
- if (ctx->RenderMode != GL_RENDER) return (swrast_tri_func) NULL;
- if (ctx->Polygon.SmoothFlag) return (swrast_tri_func) NULL;
- if (ctx->Texture._EnabledUnits) return (swrast_tri_func) NULL;
- if (swrast->_RasterMask & MULTI_DRAW_BIT) return (swrast_tri_func) NULL;
+ if (ctx->RenderMode != GL_RENDER)
+ return (swrast_tri_func) NULL;
+ if (ctx->Polygon.SmoothFlag)
+ return (swrast_tri_func) NULL;
+ if (ctx->Texture._EnabledUnits)
+ return (swrast_tri_func) NULL;
+ if (swrast->_RasterMask & MULTI_DRAW_BIT)
+ return (swrast_tri_func) NULL;
if (ctx->Polygon.CullFlag &&
ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
- return (swrast_tri_func) NULL;
+ return (swrast_tri_func) NULL;
- xrb = (struct xmesa_renderbuffer *)
- ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped;
+ xrb = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped);
if (xrb->ximage) {
if ( ctx->Light.ShadeModel==GL_SMOOTH
return (swrast_tri_func) NULL;
}
}
-
- return (swrast_tri_func) NULL;
- }
- else {
- /* draw to pixmap */
- return (swrast_tri_func) NULL;
}
+
+#else
+ return (swrast_tri_func) NULL;
+#endif /* CHAN_BITS == 8 */
}
/*
* Return pointer to XMesaContext corresponding to a Mesa GLcontext.
* Since we're using structure containment, it's just a cast!.
+ * XXX should use inlined function for better type safety.
*/
#define XMESA_CONTEXT(MESACTX) ((XMesaContext) (MESACTX))
/*
* Return pointer to XMesaBuffer corresponding to a Mesa GLframebuffer.
* Since we're using structure containment, it's just a cast!.
+ * XXX should use inlined function for better type safety.
*/
#define XMESA_BUFFER(MESABUFF) ((XMesaBuffer) (MESABUFF))
enum pixel_format pixelformat, GLint depth);
+/**
+ * Using a function instead of an ordinary cast is safer.
+ */
+static INLINE struct xmesa_renderbuffer *
+xmesa_renderbuffer(struct gl_renderbuffer *rb)
+{
+ return (struct xmesa_renderbuffer *) rb;
+}
+
+
/* Plugged into the software rasterizer. Try to use internal
* swrast-style point, line and triangle functions.
*/