summaryrefslogtreecommitdiff
path: root/src/mesa/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/x11/xm_buffer.c4
-rw-r--r--src/mesa/drivers/x11/xm_dd.c28
-rw-r--r--src/mesa/drivers/x11/xm_line.c8
-rw-r--r--src/mesa/drivers/x11/xm_tri.c37
-rw-r--r--src/mesa/drivers/x11/xmesaP.h12
5 files changed, 57 insertions, 32 deletions
diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c
index 2f20b162a7..2a44e126f7 100644
--- a/src/mesa/drivers/x11/xm_buffer.c
+++ b/src/mesa/drivers/x11/xm_buffer.c
@@ -48,7 +48,7 @@ static GLboolean
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;
@@ -74,7 +74,7 @@ static GLboolean
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);
diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c
index 2056366a91..d339ac6bc3 100644
--- a/src/mesa/drivers/x11/xm_dd.c
+++ b/src/mesa/drivers/x11/xm_dd.c
@@ -302,11 +302,12 @@ clear_HPCR_ximage( GLcontext *ctx, struct xmesa_renderbuffer *xrb,
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;
}
@@ -329,7 +330,7 @@ clear_HPCR_ximage( GLcontext *ctx, struct xmesa_renderbuffer *xrb,
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++;
}
@@ -530,14 +531,15 @@ clear_buffers( GLcontext *ctx, GLbitfield mask,
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);
@@ -549,8 +551,9 @@ clear_buffers( GLcontext *ctx, GLbitfield mask,
}
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);
@@ -600,7 +603,7 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx,
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 );
@@ -1151,10 +1154,15 @@ update_framebuffer_size(GLcontext *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);
}
diff --git a/src/mesa/drivers/x11/xm_line.c b/src/mesa/drivers/x11/xm_line.c
index f60ffa65eb..1799503114 100644
--- a/src/mesa/drivers/x11/xm_line.c
+++ b/src/mesa/drivers/x11/xm_line.c
@@ -118,7 +118,7 @@ void xmesa_choose_point( GLcontext *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)
/*
@@ -547,8 +547,7 @@ xor_line(GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1)
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],
@@ -589,8 +588,7 @@ get_line_func(GLcontext *ctx)
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
diff --git a/src/mesa/drivers/x11/xm_tri.c b/src/mesa/drivers/x11/xm_tri.c
index 61e8986a9b..d08fd8f816 100644
--- a/src/mesa/drivers/x11/xm_tri.c
+++ b/src/mesa/drivers/x11/xm_tri.c
@@ -45,7 +45,7 @@
#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)
/**********************************************************************/
@@ -53,6 +53,8 @@
/**********************************************************************/
+#if CHAN_BITS == 8
+
/*
* XImage, smooth, depth-buffered, PF_TRUECOLOR triangle.
*/
@@ -1307,8 +1309,10 @@
#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 )
{
@@ -1441,19 +1445,24 @@ get_triangle_func(GLcontext *ctx)
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
@@ -1607,13 +1616,11 @@ get_triangle_func(GLcontext *ctx)
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 */
}
diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h
index 9d4e694609..bcac0557b9 100644
--- a/src/mesa/drivers/x11/xmesaP.h
+++ b/src/mesa/drivers/x11/xmesaP.h
@@ -480,12 +480,14 @@ extern const int xmesa_kernel1[16];
/*
* 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))
@@ -520,6 +522,16 @@ xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer *xrb,
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.
*/