gallium: rename pipe_buffer_handle to pipe_buffer, rework pipebuffer/ code
[mesa.git] / src / mesa / pipe / draw / draw_unfilled.c
index 82e8775f59f1d6c3faaa5a1baa0429f1a1e60a3c..786826b33c1af7ffadb5430bd56affc20e72fad4 100644 (file)
@@ -33,7 +33,7 @@
 /* Authors:  Keith Whitwell <keith@tungstengraphics.com>
  */
 
-#include "main/imports.h"
+#include "pipe/p_util.h"
 #include "pipe/p_defines.h"
 #include "draw_private.h"
 
@@ -45,7 +45,7 @@ struct unfilled_stage {
     * legal values:  PIPE_POLYGON_MODE_FILL, PIPE_POLYGON_MODE_LINE,
     * and PIPE_POLYGON_MODE_POINT,
     */
-   GLuint mode[2];
+   unsigned mode[2];
 };
 
 
@@ -59,8 +59,8 @@ static void unfilled_begin( struct draw_stage *stage )
 {
    struct unfilled_stage *unfilled = unfilled_stage(stage);
 
-   unfilled->mode[0] = stage->draw->setup.fill_ccw; /* front */
-   unfilled->mode[1] = stage->draw->setup.fill_cw;  /* back */
+   unfilled->mode[0] = stage->draw->rasterizer->fill_ccw; /* front */
+   unfilled->mode[1] = stage->draw->rasterizer->fill_cw;  /* back */
 
    stage->next->begin( stage->next );
 }
@@ -91,9 +91,9 @@ static void points( struct draw_stage *stage,
    struct vertex_header *v1 = header->v[1];
    struct vertex_header *v2 = header->v[2];
 
-   if (v0->edgeflag) point( stage, v0 );
-   if (v1->edgeflag) point( stage, v1 );
-   if (v2->edgeflag) point( stage, v2 );
+   if (header->edgeflags & 0x1) point( stage, v0 );
+   if (header->edgeflags & 0x2) point( stage, v1 );
+   if (header->edgeflags & 0x4) point( stage, v2 );
 }
 
 
@@ -104,9 +104,15 @@ static void lines( struct draw_stage *stage,
    struct vertex_header *v1 = header->v[1];
    struct vertex_header *v2 = header->v[2];
 
-   if (v0->edgeflag) line( stage, v0, v1 );
-   if (v1->edgeflag) line( stage, v1, v2 );
-   if (v2->edgeflag) line( stage, v2, v0 );
+#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->edgeflags & 0x1) line( stage, v0, v1 );
+   if (header->edgeflags & 0x2) line( stage, v1, v2 );
+   if (header->edgeflags & 0x4) line( stage, v2, v0 );
 }
 
 
@@ -119,7 +125,7 @@ static void unfilled_tri( struct draw_stage *stage,
                          struct prim_header *header )
 {
    struct unfilled_stage *unfilled = unfilled_stage(stage);
-   GLuint mode = unfilled->mode[header->det > 0.0];
+   unsigned mode = unfilled->mode[header->det >= 0.0];
   
    switch (mode) {
    case PIPE_POLYGON_MODE_FILL:
@@ -162,6 +168,13 @@ static void unfilled_reset_stipple_counter( struct draw_stage *stage )
 }
 
 
+static void unfilled_destroy( struct draw_stage *stage )
+{
+   draw_free_tmps( stage );
+   FREE( stage );
+}
+
+
 /**
  * Create unfilled triangle stage.
  */
@@ -180,6 +193,7 @@ struct draw_stage *draw_unfilled_stage( struct draw_context *draw )
    unfilled->stage.tri = unfilled_tri;
    unfilled->stage.end = unfilled_end;
    unfilled->stage.reset_stipple_counter = unfilled_reset_stipple_counter;
+   unfilled->stage.destroy = unfilled_destroy;
 
    return &unfilled->stage;
 }