17798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul/*
27798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Mesa 3-D graphics library
35237f863edf4f61447b9b436e2fc4efb4ee819f1Brian * Version:  7.1
422144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
5dd34fe8679fa200e55cfaf8e80bbecdecea084e3Brian * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
622144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
77798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Permission is hereby granted, free of charge, to any person obtaining a
87798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * copy of this software and associated documentation files (the "Software"),
97798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * to deal in the Software without restriction, including without limitation
107798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * the rights to use, copy, modify, merge, publish, distribute, sublicense,
117798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * and/or sell copies of the Software, and to permit persons to whom the
127798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Software is furnished to do so, subject to the following conditions:
1322144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
147798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * The above copyright notice and this permission notice shall be included
157798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * in all copies or substantial portions of the Software.
1622144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
177798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
187798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
197798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
207798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
217798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
227798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
237798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul */
247798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul
257798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul
267798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul/*
277798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Antialiased line template.
287798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul */
297798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul
307798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul
317798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul/*
327798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Function to render each fragment in the AA line.
33a803b0c891404dcd7c376e91f6a033cd4e42abc3Brian Paul * \param ix  - integer fragment window X coordiante
34a803b0c891404dcd7c376e91f6a033cd4e42abc3Brian Paul * \param iy  - integer fragment window Y coordiante
357798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul */
367798374e472a8fa2f8699d38873e6b8490d853a4Brian Paulstatic void
37f9995b30756140724f41daf963fa06167912be7fKristian HøgsbergNAME(plot)(struct gl_context *ctx, struct LineInfo *line, int ix, int iy)
387798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul{
39dd34fe8679fa200e55cfaf8e80bbecdecea084e3Brian   const SWcontext *swrast = SWRAST_CONTEXT(ctx);
407798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   const GLfloat fx = (GLfloat) ix;
417798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   const GLfloat fy = (GLfloat) iy;
427798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   const GLfloat coverage = compute_coveragef(line, ix, iy);
4377df88727cb0a423dd5cb41498c2302d9df4fce7Brian Paul   const GLuint i = line->span.end;
447798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul
45dd34fe8679fa200e55cfaf8e80bbecdecea084e3Brian   (void) swrast;
46dd34fe8679fa200e55cfaf8e80bbecdecea084e3Brian
477798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   if (coverage == 0.0)
487798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul      return;
497798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul
5077df88727cb0a423dd5cb41498c2302d9df4fce7Brian Paul   line->span.end++;
5177df88727cb0a423dd5cb41498c2302d9df4fce7Brian Paul   line->span.array->coverage[i] = coverage;
5277df88727cb0a423dd5cb41498c2302d9df4fce7Brian Paul   line->span.array->x[i] = ix;
5377df88727cb0a423dd5cb41498c2302d9df4fce7Brian Paul   line->span.array->y[i] = iy;
54733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul
557798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   /*
567798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul    * Compute Z, color, texture coords, fog for the fragment by
577798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul    * solving the plane equations at (ix,iy).
587798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul    */
597798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#ifdef DO_Z
603e37bafab0a339021354b9c78f983d05d433d735Brian Paul   line->span.array->z[i] = (GLuint) solve_plane(fx, fy, line->zPlane);
617798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#endif
6277df88727cb0a423dd5cb41498c2302d9df4fce7Brian Paul   line->span.array->rgba[i][RCOMP] = solve_plane_chan(fx, fy, line->rPlane);
6377df88727cb0a423dd5cb41498c2302d9df4fce7Brian Paul   line->span.array->rgba[i][GCOMP] = solve_plane_chan(fx, fy, line->gPlane);
6477df88727cb0a423dd5cb41498c2302d9df4fce7Brian Paul   line->span.array->rgba[i][BCOMP] = solve_plane_chan(fx, fy, line->bPlane);
6577df88727cb0a423dd5cb41498c2302d9df4fce7Brian Paul   line->span.array->rgba[i][ACOMP] = solve_plane_chan(fx, fy, line->aPlane);
66eca456b63d41700617987ba45a09e8f2168b9577Brian#if defined(DO_ATTRIBS)
670bdf216dd06d5136b8529297297aa962bab548c2Brian   ATTRIB_LOOP_BEGIN
680bdf216dd06d5136b8529297297aa962bab548c2Brian      GLfloat (*attribArray)[4] = line->span.array->attribs[attr];
699e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian      if (attr >= FRAG_ATTRIB_TEX0 && attr < FRAG_ATTRIB_VAR0
701c0f1dd42a50464eeb81de4aad8eecf24b3d6c89Chad Versace          && !_swrast_use_fragment_program(ctx)) {
719e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian         /* texcoord w/ divide by Q */
720bdf216dd06d5136b8529297297aa962bab548c2Brian         const GLuint unit = attr - FRAG_ATTRIB_TEX0;
739e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian         const GLfloat invQ = solve_plane_recip(fx, fy, line->attrPlane[attr][3]);
749e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian         GLuint c;
759e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian         for (c = 0; c < 3; c++) {
769e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian            attribArray[i][c] = solve_plane(fx, fy, line->attrPlane[attr][c]) * invQ;
779e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian         }
780bdf216dd06d5136b8529297297aa962bab548c2Brian         line->span.array->lambda[unit][i]
799e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian            = compute_lambda(line->attrPlane[attr][0],
809e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian                             line->attrPlane[attr][1], invQ,
810bdf216dd06d5136b8529297297aa962bab548c2Brian                             line->texWidth[attr], line->texHeight[attr]);
820bdf216dd06d5136b8529297297aa962bab548c2Brian      }
839e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian      else {
849e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian         /* non-texture attrib */
859e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian         const GLfloat invW = solve_plane_recip(fx, fy, line->wPlane);
869e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian         GLuint c;
879e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian         for (c = 0; c < 4; c++) {
889e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian            attribArray[i][c] = solve_plane(fx, fy, line->attrPlane[attr][c]) * invW;
899e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian         }
909e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian      }
910bdf216dd06d5136b8529297297aa962bab548c2Brian   ATTRIB_LOOP_END
927798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#endif
937798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul
9447d88ef204b42a9220c6be3e98c92df9c9aa0860Brian Paul   if (line->span.end == SWRAST_MAX_WIDTH) {
9545bc887da226403f2c41077e40ca38b6f60f1359Brian Paul      _swrast_write_rgba_span(ctx, &(line->span));
9677df88727cb0a423dd5cb41498c2302d9df4fce7Brian Paul      line->span.end = 0; /* reset counter */
97733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul   }
987798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul}
997798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul
1007798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul
1017798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul
1027798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul/*
1037798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Line setup
1047798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul */
1057798374e472a8fa2f8699d38873e6b8490d853a4Brian Paulstatic void
106f9995b30756140724f41daf963fa06167912be7fKristian HøgsbergNAME(line)(struct gl_context *ctx, const SWvertex *v0, const SWvertex *v1)
1077798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul{
1087798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   SWcontext *swrast = SWRAST_CONTEXT(ctx);
1097798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   GLfloat tStart, tEnd;   /* segment start, end along line length */
1107798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   GLboolean inSegment;
1117798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   GLint iLen, i;
1127798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul
1137798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   /* Init the LineInfo struct */
1147798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   struct LineInfo line;
1159e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian   line.x0 = v0->attrib[FRAG_ATTRIB_WPOS][0];
1169e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian   line.y0 = v0->attrib[FRAG_ATTRIB_WPOS][1];
1179e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian   line.x1 = v1->attrib[FRAG_ATTRIB_WPOS][0];
1189e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian   line.y1 = v1->attrib[FRAG_ATTRIB_WPOS][1];
1197798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   line.dx = line.x1 - line.x0;
1207798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   line.dy = line.y1 - line.y0;
121f9b1e5241facc8cf255c258082d5cb5b04783e93Brian Paul   line.len = SQRTF(line.dx * line.dx + line.dy * line.dy);
122af2aa8e9cf88a9ee3ec338eddc9a47bf2f142cb7Brian   line.halfWidth = 0.5F * CLAMP(ctx->Line.Width,
123af2aa8e9cf88a9ee3ec338eddc9a47bf2f142cb7Brian                                 ctx->Const.MinLineWidthAA,
124af2aa8e9cf88a9ee3ec338eddc9a47bf2f142cb7Brian                                 ctx->Const.MaxLineWidthAA);
125dbed2027444338dc09fc102d6f4bd5c707c238d7Brian Paul
126ef4f5b391e560e535b25b372f797e41edeef09f1Keith Whitwell   if (line.len == 0.0 || IS_INF_OR_NAN(line.len))
127dbed2027444338dc09fc102d6f4bd5c707c238d7Brian Paul      return;
128dbed2027444338dc09fc102d6f4bd5c707c238d7Brian Paul
129f4b103dc993491355ec3e3640d9cb060138175c2Brian   INIT_SPAN(line.span, GL_LINE);
130f4b103dc993491355ec3e3640d9cb060138175c2Brian   line.span.arrayMask = SPAN_XY | SPAN_COVERAGE;
131fcd7c37fd3d0f61cf6ac81170bc0b3fca64ad9bbBrian   line.span.facing = swrast->PointLineFacing;
132dbed2027444338dc09fc102d6f4bd5c707c238d7Brian Paul   line.xAdj = line.dx / line.len * line.halfWidth;
133dbed2027444338dc09fc102d6f4bd5c707c238d7Brian Paul   line.yAdj = line.dy / line.len * line.halfWidth;
1347798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul
1357798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#ifdef DO_Z
13677df88727cb0a423dd5cb41498c2302d9df4fce7Brian Paul   line.span.arrayMask |= SPAN_Z;
1377798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   compute_plane(line.x0, line.y0, line.x1, line.y1,
1389e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian                 v0->attrib[FRAG_ATTRIB_WPOS][2], v1->attrib[FRAG_ATTRIB_WPOS][2], line.zPlane);
1397798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#endif
14077df88727cb0a423dd5cb41498c2302d9df4fce7Brian Paul   line.span.arrayMask |= SPAN_RGBA;
1417798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   if (ctx->Light.ShadeModel == GL_SMOOTH) {
1427798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul      compute_plane(line.x0, line.y0, line.x1, line.y1,
1437798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul                    v0->color[RCOMP], v1->color[RCOMP], line.rPlane);
1447798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul      compute_plane(line.x0, line.y0, line.x1, line.y1,
1457798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul                    v0->color[GCOMP], v1->color[GCOMP], line.gPlane);
1467798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul      compute_plane(line.x0, line.y0, line.x1, line.y1,
1477798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul                    v0->color[BCOMP], v1->color[BCOMP], line.bPlane);
1487798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul      compute_plane(line.x0, line.y0, line.x1, line.y1,
1497798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul                    v0->color[ACOMP], v1->color[ACOMP], line.aPlane);
1507798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   }
1517798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   else {
15258e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell      constant_plane(v1->color[RCOMP], line.rPlane);
15358e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell      constant_plane(v1->color[GCOMP], line.gPlane);
15458e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell      constant_plane(v1->color[BCOMP], line.bPlane);
15558e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell      constant_plane(v1->color[ACOMP], line.aPlane);
1567798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   }
157eca456b63d41700617987ba45a09e8f2168b9577Brian#if defined(DO_ATTRIBS)
1587798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   {
1599e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian      const GLfloat invW0 = v0->attrib[FRAG_ATTRIB_WPOS][3];
1609e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian      const GLfloat invW1 = v1->attrib[FRAG_ATTRIB_WPOS][3];
1619e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian      line.span.arrayMask |= SPAN_LAMBDA;
1629e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian      compute_plane(line.x0, line.y0, line.x1, line.y1, invW0, invW1, line.wPlane);
1630bdf216dd06d5136b8529297297aa962bab548c2Brian      ATTRIB_LOOP_BEGIN
1649e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian         GLuint c;
1655237f863edf4f61447b9b436e2fc4efb4ee819f1Brian         if (swrast->_InterpMode[attr] == GL_FLAT) {
1665237f863edf4f61447b9b436e2fc4efb4ee819f1Brian            for (c = 0; c < 4; c++) {
1675237f863edf4f61447b9b436e2fc4efb4ee819f1Brian               constant_plane(v1->attrib[attr][c], line.attrPlane[attr][c]);
1685237f863edf4f61447b9b436e2fc4efb4ee819f1Brian            }
1695237f863edf4f61447b9b436e2fc4efb4ee819f1Brian         }
1705237f863edf4f61447b9b436e2fc4efb4ee819f1Brian         else {
1715237f863edf4f61447b9b436e2fc4efb4ee819f1Brian            for (c = 0; c < 4; c++) {
1725237f863edf4f61447b9b436e2fc4efb4ee819f1Brian               const GLfloat a0 = v0->attrib[attr][c] * invW0;
1735237f863edf4f61447b9b436e2fc4efb4ee819f1Brian               const GLfloat a1 = v1->attrib[attr][c] * invW1;
1745237f863edf4f61447b9b436e2fc4efb4ee819f1Brian               compute_plane(line.x0, line.y0, line.x1, line.y1, a0, a1,
1755237f863edf4f61447b9b436e2fc4efb4ee819f1Brian                             line.attrPlane[attr][c]);
1765237f863edf4f61447b9b436e2fc4efb4ee819f1Brian            }
1779e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian         }
178706400f0a7a59bba89eca8e97a1ada45445ee6dfBrian Paul         line.span.arrayAttribs |= BITFIELD64_BIT(attr);
1799e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian         if (attr >= FRAG_ATTRIB_TEX0 && attr < FRAG_ATTRIB_VAR0) {
1800bdf216dd06d5136b8529297297aa962bab548c2Brian            const GLuint u = attr - FRAG_ATTRIB_TEX0;
1810bdf216dd06d5136b8529297297aa962bab548c2Brian            const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current;
1820bdf216dd06d5136b8529297297aa962bab548c2Brian            const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel];
1830bdf216dd06d5136b8529297297aa962bab548c2Brian            line.texWidth[attr]  = (GLfloat) texImage->Width;
184eca456b63d41700617987ba45a09e8f2168b9577Brian            line.texHeight[attr] = (GLfloat) texImage->Height;
1857798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul         }
1860bdf216dd06d5136b8529297297aa962bab548c2Brian      ATTRIB_LOOP_END
1877798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   }
1887798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#endif
1897798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul
1907798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   tStart = tEnd = 0.0;
1917798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   inSegment = GL_FALSE;
1927798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   iLen = (GLint) line.len;
1937798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul
1947798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   if (ctx->Line.StippleFlag) {
1957798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul      for (i = 0; i < iLen; i++) {
1967798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul         const GLuint bit = (swrast->StippleCounter / ctx->Line.StippleFactor) & 0xf;
1977798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul         if ((1 << bit) & ctx->Line.StipplePattern) {
1987798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul            /* stipple bit is on */
1997798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul            const GLfloat t = (GLfloat) i / (GLfloat) line.len;
2007798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul            if (!inSegment) {
2017798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul               /* start new segment */
2027798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul               inSegment = GL_TRUE;
2037798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul               tStart = t;
2047798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul            }
2057798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul            else {
2067798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul               /* still in the segment, extend it */
2077798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul               tEnd = t;
2087798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul            }
2097798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul         }
2107798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul         else {
2117798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul            /* stipple bit is off */
2127798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul            if (inSegment && (tEnd > tStart)) {
2137798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul               /* draw the segment */
214733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul               segment(ctx, &line, NAME(plot), tStart, tEnd);
2157798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul               inSegment = GL_FALSE;
2167798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul            }
2177798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul            else {
2187798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul               /* still between segments, do nothing */
2197798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul            }
2207798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul         }
2217798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul         swrast->StippleCounter++;
2227798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul      }
223426628c374d043c5ae2bb73079aff577fc31c138Brian Paul
224426628c374d043c5ae2bb73079aff577fc31c138Brian Paul      if (inSegment) {
225426628c374d043c5ae2bb73079aff577fc31c138Brian Paul         /* draw the final segment of the line */
226733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul         segment(ctx, &line, NAME(plot), tStart, 1.0F);
227426628c374d043c5ae2bb73079aff577fc31c138Brian Paul      }
2287798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   }
2297798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   else {
2307798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul      /* non-stippled */
231733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul      segment(ctx, &line, NAME(plot), 0.0, 1.0);
2327798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul   }
233733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul
23445bc887da226403f2c41077e40ca38b6f60f1359Brian Paul   _swrast_write_rgba_span(ctx, &(line.span));
2357798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul}
2367798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul
2377798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul
2387798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul
2397798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul
2407798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#undef DO_Z
241eca456b63d41700617987ba45a09e8f2168b9577Brian#undef DO_ATTRIBS
2427798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#undef NAME
243