merge from master
[mesa.git] / src / mesa / drivers / x11 / xm_tri.c
index 87989f46f8994705044ad27abe9690574c8a4ed1..289ce11be62b335a50b2241b56039b3c8843965a 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.3
+ * Version:  6.5
  *
- * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -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.
  */
 #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 )
 {
@@ -1425,27 +1429,40 @@ do {                                   \
 #endif
 
 
-static swrast_tri_func get_triangle_func( GLcontext *ctx )
+/**
+ * Return pointer to line drawing function, or NULL if we should use a
+ * swrast fallback.
+ */
+static swrast_tri_func
+get_triangle_func(GLcontext *ctx)
 {
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
    XMesaContext xmesa = XMESA_CONTEXT(ctx);
    int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
-   GET_XRB(xrb);
+   struct xmesa_renderbuffer *xrb;
 
 #ifdef DEBUG
    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 = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped);
 
    if (xrb->ximage) {
       if (   ctx->Light.ShadeModel==GL_SMOOTH
@@ -1599,13 +1616,10 @@ static swrast_tri_func get_triangle_func( GLcontext *ctx )
                return (swrast_tri_func) NULL;
          }
       }
-
-      return (swrast_tri_func) NULL;
-   }
-   else {
-      /* draw to pixmap */
-      return (swrast_tri_func) NULL;
    }
+#endif /* CHAN_BITS == 8 */
+
+   return (swrast_tri_func) NULL;
 }