Mesa (master): draw: Adjust wideline vertex coords for D3D.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Tue May 4 23:48:54 UTC 2010


Module: Mesa
Branch: master
Commit: dc1c33b448c830c5775e4f3fb6510830694a4177
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=dc1c33b448c830c5775e4f3fb6510830694a4177

Author: Brian Paul <brianp at vmware.com>
Date:   Tue May  4 23:56:42 2010 +0100

draw: Adjust wideline vertex coords for D3D.

---

 src/gallium/auxiliary/draw/draw_pipe_wide_line.c |   61 ++++++++++++----------
 1 files changed, 34 insertions(+), 27 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
index ab16706..d7ac95b 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
@@ -77,8 +77,11 @@ static void wideline_line( struct draw_stage *stage,
    const float dx = fabsf(pos0[0] - pos2[0]);
    const float dy = fabsf(pos0[1] - pos2[1]);
 
+   const boolean gl_rasterization_rules =
+      stage->draw->rasterizer->gl_rasterization_rules;
+
    /* small tweak to meet GL specification */
-   const float bias = 0.125f;
+   const float bias = gl_rasterization_rules ? 0.125f : 0.0f;
 
    /*
     * Draw wide line as a quad (two tris) by "stretching" the line along
@@ -92,19 +95,21 @@ static void wideline_line( struct draw_stage *stage,
       pos1[1] = pos1[1] + half_width - bias;
       pos2[1] = pos2[1] - half_width - bias;
       pos3[1] = pos3[1] + half_width - bias;
-      if (pos0[0] < pos2[0]) {
-         /* left to right line */
-         pos0[0] -= 0.5f;
-         pos1[0] -= 0.5f;
-         pos2[0] -= 0.5f;
-         pos3[0] -= 0.5f;
-      }
-      else {
-         /* right to left line */
-         pos0[0] += 0.5f;
-         pos1[0] += 0.5f;
-         pos2[0] += 0.5f;
-         pos3[0] += 0.5f;
+      if (gl_rasterization_rules) {
+         if (pos0[0] < pos2[0]) {
+            /* left to right line */
+            pos0[0] -= 0.5f;
+            pos1[0] -= 0.5f;
+            pos2[0] -= 0.5f;
+            pos3[0] -= 0.5f;
+         }
+         else {
+            /* right to left line */
+            pos0[0] += 0.5f;
+            pos1[0] += 0.5f;
+            pos2[0] += 0.5f;
+            pos3[0] += 0.5f;
+         }
       }
    }
    else {
@@ -113,19 +118,21 @@ static void wideline_line( struct draw_stage *stage,
       pos1[0] = pos1[0] + half_width + bias;
       pos2[0] = pos2[0] - half_width + bias;
       pos3[0] = pos3[0] + half_width + bias;
-      if (pos0[1] < pos2[1]) {
-         /* top to bottom line */
-         pos0[1] -= 0.5f;
-         pos1[1] -= 0.5f;
-         pos2[1] -= 0.5f;
-         pos3[1] -= 0.5f;
-      }
-      else {
-         /* bottom to top line */
-         pos0[1] += 0.5f;
-         pos1[1] += 0.5f;
-         pos2[1] += 0.5f;
-         pos3[1] += 0.5f;
+      if (gl_rasterization_rules) {
+         if (pos0[1] < pos2[1]) {
+            /* top to bottom line */
+            pos0[1] -= 0.5f;
+            pos1[1] -= 0.5f;
+            pos2[1] -= 0.5f;
+            pos3[1] -= 0.5f;
+         }
+         else {
+            /* bottom to top line */
+            pos0[1] += 0.5f;
+            pos1[1] += 0.5f;
+            pos2[1] += 0.5f;
+            pos3[1] += 0.5f;
+         }
       }
    }
 




More information about the mesa-commit mailing list