util: Update caps after helpfull input
[mesa.git] / src / gallium / auxiliary / draw / draw_pipe_unfilled.c
index d4ddfec1b3aaef284e5ff006dc2f863254e41c51..03bb842e20a30c5978fe5fe899e9139e88829825 100644 (file)
@@ -33,7 +33,7 @@
 /* Authors:  Keith Whitwell <keith@tungstengraphics.com>
  */
 
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
 #include "pipe/p_defines.h"
 #include "draw_private.h"
 #include "draw_pipe.h"
@@ -83,9 +83,9 @@ static void points( struct draw_stage *stage,
    struct vertex_header *v1 = header->v[1];
    struct vertex_header *v2 = header->v[2];
 
-   if (header->edgeflags & 0x1) point( stage, v0 );
-   if (header->edgeflags & 0x2) point( stage, v1 );
-   if (header->edgeflags & 0x4) point( stage, v2 );
+   if ((header->flags & DRAW_PIPE_EDGE_FLAG_0) && v0->edgeflag) point( stage, v0 );
+   if ((header->flags & DRAW_PIPE_EDGE_FLAG_1) && v1->edgeflag) point( stage, v1 );
+   if ((header->flags & DRAW_PIPE_EDGE_FLAG_2) && v2->edgeflag) point( stage, v2 );
 }
 
 
@@ -96,22 +96,22 @@ static void lines( struct draw_stage *stage,
    struct vertex_header *v1 = header->v[1];
    struct vertex_header *v2 = header->v[2];
 
-#if 0
-   assert(((header->edgeflags & 0x1) >> 0) == header->v[0]->edgeflag);
-   assert(((header->edgeflags & 0x2) >> 1) == header->v[1]->edgeflag);
-   assert(((header->edgeflags & 0x4) >> 2) == header->v[2]->edgeflag);
-#endif
+   if (header->flags & DRAW_PIPE_RESET_STIPPLE)
+      stage->next->reset_stipple_counter( stage->next );
 
-   if (header->edgeflags & 0x4) line( stage, v2, v0 );
-   if (header->edgeflags & 0x1) line( stage, v0, v1 );
-   if (header->edgeflags & 0x2) line( stage, v1, v2 );
+   if ((header->flags & DRAW_PIPE_EDGE_FLAG_2) && v2->edgeflag) line( stage, v2, v0 );
+   if ((header->flags & DRAW_PIPE_EDGE_FLAG_0) && v0->edgeflag) line( stage, v0, v1 );
+   if ((header->flags & DRAW_PIPE_EDGE_FLAG_1) && v1->edgeflag) line( stage, v1, v2 );
 }
 
 
 /* Unfilled tri:  
  *
  * Note edgeflags in the vertex struct is not sufficient as we will
- * need to manipulate them when decomposing primitives???
+ * need to manipulate them when decomposing primitives.  
+ * 
+ * We currently keep the vertex edgeflag and primitive edgeflag mask
+ * separate until the last possible moment.
  */
 static void unfilled_tri( struct draw_stage *stage,
                          struct prim_header *header )
@@ -177,10 +177,14 @@ static void unfilled_destroy( struct draw_stage *stage )
 struct draw_stage *draw_unfilled_stage( struct draw_context *draw )
 {
    struct unfilled_stage *unfilled = CALLOC_STRUCT(unfilled_stage);
+   if (unfilled == NULL)
+      goto fail;
 
-   draw_alloc_temp_verts( &unfilled->stage, 0 );
+   if (!draw_alloc_temp_verts( &unfilled->stage, 0 ))
+      goto fail;
 
    unfilled->stage.draw = draw;
+   unfilled->stage.name = "unfilled";
    unfilled->stage.next = NULL;
    unfilled->stage.tmp = NULL;
    unfilled->stage.point = draw_pipe_passthrough_point;
@@ -191,4 +195,10 @@ struct draw_stage *draw_unfilled_stage( struct draw_context *draw )
    unfilled->stage.destroy = unfilled_destroy;
 
    return &unfilled->stage;
+
+ fail:
+   if (unfilled)
+      unfilled->stage.destroy( &unfilled->stage );
+
+   return NULL;
 }