17798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul/* 27798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Mesa 3-D graphics library 3dd34fe8679fa200e55cfaf8e80bbecdecea084e3Brian * Version: 6.5.3 45e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen * 5dd34fe8679fa200e55cfaf8e80bbecdecea084e3Brian * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 65e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen * 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: 135e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen * 147798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * The above copyright notice and this permission notice shall be included 157798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * in all copies or substantial portions of the Software. 165e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen * 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 26bbd287103dad776d8a45c87c4e51fbc26d9b80d5Brian Paul#include "main/glheader.h" 27bbd287103dad776d8a45c87c4e51fbc26d9b80d5Brian Paul#include "main/imports.h" 28bbd287103dad776d8a45c87c4e51fbc26d9b80d5Brian Paul#include "main/macros.h" 29bbd287103dad776d8a45c87c4e51fbc26d9b80d5Brian Paul#include "main/mtypes.h" 307798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#include "swrast/s_aaline.h" 317798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#include "swrast/s_context.h" 32733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul#include "swrast/s_span.h" 337798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#include "swrast/swrast.h" 347798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 357798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 367798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#define SUB_PIXEL 4 377798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 387798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 397798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul/* 407798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Info about the AA line we're rendering 417798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul */ 427798374e472a8fa2f8699d38873e6b8490d853a4Brian Paulstruct LineInfo 437798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul{ 447798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat x0, y0; /* start */ 457798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat x1, y1; /* end */ 467798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat dx, dy; /* direction vector */ 477798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat len; /* length */ 487798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat halfWidth; /* half of line width */ 497798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat xAdj, yAdj; /* X and Y adjustment for quad corners around line */ 507798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* for coverage computation */ 517798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat qx0, qy0; /* quad vertices */ 527798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat qx1, qy1; 537798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat qx2, qy2; 547798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat qx3, qy3; 557798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat ex0, ey0; /* quad edge vectors */ 567798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat ex1, ey1; 577798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat ex2, ey2; 587798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat ex3, ey3; 597798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 607798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* DO_Z */ 617798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat zPlane[4]; 62e5ed4c45c675ebdd595ad0d31f2835f8b2b8dc57Ian Romanick /* DO_RGBA - always enabled */ 637798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat rPlane[4], gPlane[4], bPlane[4], aPlane[4]; 64eca456b63d41700617987ba45a09e8f2168b9577Brian /* DO_ATTRIBS */ 659e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian GLfloat wPlane[4]; 669e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian GLfloat attrPlane[FRAG_ATTRIB_MAX][4][4]; 67dd34fe8679fa200e55cfaf8e80bbecdecea084e3Brian GLfloat lambda[FRAG_ATTRIB_MAX]; 68dd34fe8679fa200e55cfaf8e80bbecdecea084e3Brian GLfloat texWidth[FRAG_ATTRIB_MAX]; 69dd34fe8679fa200e55cfaf8e80bbecdecea084e3Brian GLfloat texHeight[FRAG_ATTRIB_MAX]; 70733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul 71cdb27e8242215271364602995d85607cfc06d441Brian Paul SWspan span; 727798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul}; 737798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 747798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 757798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 767798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul/* 777798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Compute the equation of a plane used to interpolate line fragment data 787798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * such as color, Z, texture coords, etc. 797798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Input: (x0, y0) and (x1,y1) are the endpoints of the line. 807798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * z0, and z1 are the end point values to interpolate. 817798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Output: plane - the plane equation. 827798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * 837798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Note: we don't really have enough parameters to specify a plane. 847798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * We take the endpoints of the line and compute a plane such that 857798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * the cross product of the line vector and the plane normal is 867798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * parallel to the projection plane. 877798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul */ 887798374e472a8fa2f8699d38873e6b8490d853a4Brian Paulstatic void 897798374e472a8fa2f8699d38873e6b8490d853a4Brian Paulcompute_plane(GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, 907798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat z0, GLfloat z1, GLfloat plane[4]) 917798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul{ 927798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#if 0 937798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* original */ 947798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat px = x1 - x0; 957798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat py = y1 - y0; 967798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat pz = z1 - z0; 977798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat qx = -py; 987798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat qy = px; 997798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat qz = 0; 1007798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat a = py * qz - pz * qy; 1017798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat b = pz * qx - px * qz; 1027798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat c = px * qy - py * qx; 1037798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat d = -(a * x0 + b * y0 + c * z0); 1047798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul plane[0] = a; 1057798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul plane[1] = b; 1067798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul plane[2] = c; 1077798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul plane[3] = d; 1087798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#else 1097798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* simplified */ 1107798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat px = x1 - x0; 1117798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat py = y1 - y0; 1127798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat pz = z0 - z1; 1137798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat a = pz * px; 1147798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat b = pz * py; 1157798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat c = px * px + py * py; 1167798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat d = -(a * x0 + b * y0 + c * z0); 1176ac852d45b3a53dc51414773454e6bae7126fe33Brian Paul if (a == 0.0 && b == 0.0 && c == 0.0 && d == 0.0) { 1186ac852d45b3a53dc51414773454e6bae7126fe33Brian Paul plane[0] = 0.0; 1196ac852d45b3a53dc51414773454e6bae7126fe33Brian Paul plane[1] = 0.0; 1206ac852d45b3a53dc51414773454e6bae7126fe33Brian Paul plane[2] = 1.0; 1216ac852d45b3a53dc51414773454e6bae7126fe33Brian Paul plane[3] = 0.0; 1226ac852d45b3a53dc51414773454e6bae7126fe33Brian Paul } 1236ac852d45b3a53dc51414773454e6bae7126fe33Brian Paul else { 1246ac852d45b3a53dc51414773454e6bae7126fe33Brian Paul plane[0] = a; 1256ac852d45b3a53dc51414773454e6bae7126fe33Brian Paul plane[1] = b; 1266ac852d45b3a53dc51414773454e6bae7126fe33Brian Paul plane[2] = c; 1276ac852d45b3a53dc51414773454e6bae7126fe33Brian Paul plane[3] = d; 1286ac852d45b3a53dc51414773454e6bae7126fe33Brian Paul } 1297798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#endif 1307798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul} 1317798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 1327798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 1339520f483b8f1e45fa474674b415554988de5d8d3Brian Paulstatic inline void 1347798374e472a8fa2f8699d38873e6b8490d853a4Brian Paulconstant_plane(GLfloat value, GLfloat plane[4]) 1357798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul{ 1367798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul plane[0] = 0.0; 1377798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul plane[1] = 0.0; 1387798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul plane[2] = -1.0; 1397798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul plane[3] = value; 1407798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul} 1417798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 1427798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 1439520f483b8f1e45fa474674b415554988de5d8d3Brian Paulstatic inline GLfloat 1447798374e472a8fa2f8699d38873e6b8490d853a4Brian Paulsolve_plane(GLfloat x, GLfloat y, const GLfloat plane[4]) 1457798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul{ 1466ac852d45b3a53dc51414773454e6bae7126fe33Brian Paul const GLfloat z = (plane[3] + plane[0] * x + plane[1] * y) / -plane[2]; 1477798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul return z; 1487798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul} 1497798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 1507798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#define SOLVE_PLANE(X, Y, PLANE) \ 1517798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul ((PLANE[3] + PLANE[0] * (X) + PLANE[1] * (Y)) / -PLANE[2]) 1527798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 1537798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 1547798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul/* 1557798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Return 1 / solve_plane(). 1567798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul */ 1579520f483b8f1e45fa474674b415554988de5d8d3Brian Paulstatic inline GLfloat 1587798374e472a8fa2f8699d38873e6b8490d853a4Brian Paulsolve_plane_recip(GLfloat x, GLfloat y, const GLfloat plane[4]) 1597798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul{ 1606ac852d45b3a53dc51414773454e6bae7126fe33Brian Paul const GLfloat denom = plane[3] + plane[0] * x + plane[1] * y; 1616ac852d45b3a53dc51414773454e6bae7126fe33Brian Paul if (denom == 0.0) 1626ac852d45b3a53dc51414773454e6bae7126fe33Brian Paul return 0.0; 1636ac852d45b3a53dc51414773454e6bae7126fe33Brian Paul else 1646ac852d45b3a53dc51414773454e6bae7126fe33Brian Paul return -plane[2] / denom; 1657798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul} 1667798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 1677798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 1687798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul/* 1697798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Solve plane and return clamped GLchan value. 1707798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul */ 1719520f483b8f1e45fa474674b415554988de5d8d3Brian Paulstatic inline GLchan 1727798374e472a8fa2f8699d38873e6b8490d853a4Brian Paulsolve_plane_chan(GLfloat x, GLfloat y, const GLfloat plane[4]) 1737798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul{ 174a20ed720032d1a04a5206374020234140dd5ef08Brian Paul const GLfloat z = (plane[3] + plane[0] * x + plane[1] * y) / -plane[2]; 175a20ed720032d1a04a5206374020234140dd5ef08Brian Paul#if CHAN_TYPE == GL_FLOAT 176a20ed720032d1a04a5206374020234140dd5ef08Brian Paul return CLAMP(z, 0.0F, CHAN_MAXF); 177a20ed720032d1a04a5206374020234140dd5ef08Brian Paul#else 178a20ed720032d1a04a5206374020234140dd5ef08Brian Paul if (z < 0) 1797798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul return 0; 180a20ed720032d1a04a5206374020234140dd5ef08Brian Paul else if (z > CHAN_MAX) 181a20ed720032d1a04a5206374020234140dd5ef08Brian Paul return CHAN_MAX; 182a20ed720032d1a04a5206374020234140dd5ef08Brian Paul return (GLchan) IROUND_POS(z); 183a20ed720032d1a04a5206374020234140dd5ef08Brian Paul#endif 1847798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul} 1857798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 1867798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 1877798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul/* 1887798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Compute mipmap level of detail. 1897798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul */ 1909520f483b8f1e45fa474674b415554988de5d8d3Brian Paulstatic inline GLfloat 1917798374e472a8fa2f8699d38873e6b8490d853a4Brian Paulcompute_lambda(const GLfloat sPlane[4], const GLfloat tPlane[4], 1927798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat invQ, GLfloat width, GLfloat height) 1937798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul{ 1947798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat dudx = sPlane[0] / sPlane[2] * invQ * width; 1957798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat dudy = sPlane[1] / sPlane[2] * invQ * width; 1967798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat dvdx = tPlane[0] / tPlane[2] * invQ * height; 1977798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat dvdy = tPlane[1] / tPlane[2] * invQ * height; 1987798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat r1 = dudx * dudx + dudy * dudy; 1997798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat r2 = dvdx * dvdx + dvdy * dvdy; 2007798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat rho2 = r1 + r2; 2017798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* return log base 2 of rho */ 202dbed2027444338dc09fc102d6f4bd5c707c238d7Brian Paul if (rho2 == 0.0F) 203dbed2027444338dc09fc102d6f4bd5c707c238d7Brian Paul return 0.0; 204dbed2027444338dc09fc102d6f4bd5c707c238d7Brian Paul else 205b3aefd1cfb6aacd1695c52911dd39da50d893eceBrian Paul return (GLfloat) (LOGF(rho2) * 1.442695 * 0.5);/* 1.442695 = 1/log(2) */ 2067798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul} 2077798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 2087798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 2097798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 2107798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 2117798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul/* 2127798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Fill in the samples[] array with the (x,y) subpixel positions of 2137798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * xSamples * ySamples sample positions. 2147798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Note that the four corner samples are put into the first four 2157798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * positions of the array. This allows us to optimize for the common 2167798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * case of all samples being inside the polygon. 2177798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul */ 2187798374e472a8fa2f8699d38873e6b8490d853a4Brian Paulstatic void 2197798374e472a8fa2f8699d38873e6b8490d853a4Brian Paulmake_sample_table(GLint xSamples, GLint ySamples, GLfloat samples[][2]) 2207798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul{ 2217798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat dx = 1.0F / (GLfloat) xSamples; 2227798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat dy = 1.0F / (GLfloat) ySamples; 2237798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLint x, y; 2247798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLint i; 2257798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 2267798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul i = 4; 2277798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul for (x = 0; x < xSamples; x++) { 2287798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul for (y = 0; y < ySamples; y++) { 2297798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLint j; 2307798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (x == 0 && y == 0) { 2317798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* lower left */ 2327798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul j = 0; 2337798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2347798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else if (x == xSamples - 1 && y == 0) { 2357798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* lower right */ 2367798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul j = 1; 2377798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2387798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else if (x == 0 && y == ySamples - 1) { 2397798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* upper left */ 2407798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul j = 2; 2417798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2427798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else if (x == xSamples - 1 && y == ySamples - 1) { 2437798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* upper right */ 2447798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul j = 3; 2457798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2467798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else { 2477798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul j = i++; 2487798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2497b9fe820a3fba3849864682fbb1cb512362934abKarl Schultz samples[j][0] = x * dx + 0.5F * dx; 2507b9fe820a3fba3849864682fbb1cb512362934abKarl Schultz samples[j][1] = y * dy + 0.5F * dy; 2517798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2527798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2537798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul} 2547798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 2557798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 2567798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 2577798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul/* 2587798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Compute how much of the given pixel's area is inside the rectangle 2597798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * defined by vertices v0, v1, v2, v3. 2607798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Vertices MUST be specified in counter-clockwise order. 2617798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Return: coverage in [0, 1]. 2627798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul */ 2637798374e472a8fa2f8699d38873e6b8490d853a4Brian Paulstatic GLfloat 2647798374e472a8fa2f8699d38873e6b8490d853a4Brian Paulcompute_coveragef(const struct LineInfo *info, 2657798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLint winx, GLint winy) 2667798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul{ 2677798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul static GLfloat samples[SUB_PIXEL * SUB_PIXEL][2]; 2687798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul static GLboolean haveSamples = GL_FALSE; 2697798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat x = (GLfloat) winx; 2707798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat y = (GLfloat) winy; 2717798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLint stop = 4, i; 2727798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat insideCount = SUB_PIXEL * SUB_PIXEL; 2737798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 2747798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (!haveSamples) { 2757798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul make_sample_table(SUB_PIXEL, SUB_PIXEL, samples); 2767798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul haveSamples = GL_TRUE; 2777798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2787798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 2797798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#if 0 /*DEBUG*/ 2807798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul { 2817798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat area = dx0 * dy1 - dx1 * dy0; 2827798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul assert(area >= 0.0); 2837798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2847798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#endif 2857798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 2867798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul for (i = 0; i < stop; i++) { 2877798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat sx = x + samples[i][0]; 2887798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat sy = y + samples[i][1]; 2897798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat fx0 = sx - info->qx0; 2907798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat fy0 = sy - info->qy0; 2917798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat fx1 = sx - info->qx1; 2927798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat fy1 = sy - info->qy1; 2937798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat fx2 = sx - info->qx2; 2947798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat fy2 = sy - info->qy2; 2957798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat fx3 = sx - info->qx3; 2967798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat fy3 = sy - info->qy3; 2977798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* cross product determines if sample is inside or outside each edge */ 2987798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat cross0 = (info->ex0 * fy0 - info->ey0 * fx0); 2997798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat cross1 = (info->ex1 * fy1 - info->ey1 * fx1); 3007798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat cross2 = (info->ex2 * fy2 - info->ey2 * fx2); 3017798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat cross3 = (info->ex3 * fy3 - info->ey3 * fx3); 3027798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* Check if the sample is exactly on an edge. If so, let cross be a 3037798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * positive or negative value depending on the direction of the edge. 3047798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul */ 3057798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (cross0 == 0.0F) 3067798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul cross0 = info->ex0 + info->ey0; 3077798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (cross1 == 0.0F) 3087798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul cross1 = info->ex1 + info->ey1; 3097798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (cross2 == 0.0F) 3107798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul cross2 = info->ex2 + info->ey2; 3117798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (cross3 == 0.0F) 3127798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul cross3 = info->ex3 + info->ey3; 3137798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (cross0 < 0.0F || cross1 < 0.0F || cross2 < 0.0F || cross3 < 0.0F) { 3147798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* point is outside quadrilateral */ 3157798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul insideCount -= 1.0F; 3167798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul stop = SUB_PIXEL * SUB_PIXEL; 3177798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 3187798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 3197798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (stop == 4) 3207798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul return 1.0F; 3217798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else 3227798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul return insideCount * (1.0F / (SUB_PIXEL * SUB_PIXEL)); 3237798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul} 3247798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 3257798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 326f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergtypedef void (*plot_func)(struct gl_context *ctx, struct LineInfo *line, 327733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul int ix, int iy); 328733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul 3297798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 3307798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 3317798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul/* 3327798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Draw an AA line segment (called many times per line when stippling) 3337798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul */ 3347798374e472a8fa2f8699d38873e6b8490d853a4Brian Paulstatic void 335f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergsegment(struct gl_context *ctx, 3367798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul struct LineInfo *line, 3377798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul plot_func plot, 3387798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat t0, GLfloat t1) 3397798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul{ 3407798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat absDx = (line->dx < 0.0F) ? -line->dx : line->dx; 3417798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat absDy = (line->dy < 0.0F) ? -line->dy : line->dy; 3427798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* compute the actual segment's endpoints */ 3437798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat x0 = line->x0 + t0 * line->dx; 3447798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat y0 = line->y0 + t0 * line->dy; 3457798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat x1 = line->x0 + t1 * line->dx; 3467798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat y1 = line->y0 + t1 * line->dy; 3477798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 3487798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* compute vertices of the line-aligned quadrilateral */ 3497798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line->qx0 = x0 - line->yAdj; 3507798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line->qy0 = y0 + line->xAdj; 3517798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line->qx1 = x0 + line->yAdj; 3527798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line->qy1 = y0 - line->xAdj; 3537798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line->qx2 = x1 + line->yAdj; 3547798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line->qy2 = y1 - line->xAdj; 3557798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line->qx3 = x1 - line->yAdj; 3567798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line->qy3 = y1 + line->xAdj; 3577798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* compute the quad's edge vectors (for coverage calc) */ 3587798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line->ex0 = line->qx1 - line->qx0; 3597798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line->ey0 = line->qy1 - line->qy0; 3607798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line->ex1 = line->qx2 - line->qx1; 3617798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line->ey1 = line->qy2 - line->qy1; 3627798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line->ex2 = line->qx3 - line->qx2; 3637798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line->ey2 = line->qy3 - line->qy2; 3647798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line->ex3 = line->qx0 - line->qx3; 3657798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line->ey3 = line->qy0 - line->qy3; 3667798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 3677798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (absDx > absDy) { 3687798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* X-major line */ 3697798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat dydx = line->dy / line->dx; 3707798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat xLeft, xRight, yBot, yTop; 3717798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLint ix, ixRight; 3727798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (x0 < x1) { 3737798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul xLeft = x0 - line->halfWidth; 3747798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul xRight = x1 + line->halfWidth; 3757798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (line->dy >= 0.0) { 3767b9fe820a3fba3849864682fbb1cb512362934abKarl Schultz yBot = y0 - 3.0F * line->halfWidth; 3777798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul yTop = y0 + line->halfWidth; 3787798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 3797798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else { 3807798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul yBot = y0 - line->halfWidth; 3817b9fe820a3fba3849864682fbb1cb512362934abKarl Schultz yTop = y0 + 3.0F * line->halfWidth; 3827798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 3837798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 3847798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else { 3857798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul xLeft = x1 - line->halfWidth; 3867798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul xRight = x0 + line->halfWidth; 3877798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (line->dy <= 0.0) { 3887b9fe820a3fba3849864682fbb1cb512362934abKarl Schultz yBot = y1 - 3.0F * line->halfWidth; 3897798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul yTop = y1 + line->halfWidth; 3907798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 3917798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else { 3927798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul yBot = y1 - line->halfWidth; 3937b9fe820a3fba3849864682fbb1cb512362934abKarl Schultz yTop = y1 + 3.0F * line->halfWidth; 3947798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 3957798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 3967798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 3977798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* scan along the line, left-to-right */ 3987798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul ixRight = (GLint) (xRight + 1.0F); 3997798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 4007798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /*printf("avg span height: %g\n", yTop - yBot);*/ 4017798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul for (ix = (GLint) xLeft; ix < ixRight; ix++) { 4027798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLint iyBot = (GLint) yBot; 4037798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLint iyTop = (GLint) (yTop + 1.0F); 4047798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLint iy; 4057798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* scan across the line, bottom-to-top */ 4067798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul for (iy = iyBot; iy < iyTop; iy++) { 407733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul (*plot)(ctx, line, ix, iy); 4087798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 4097798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul yBot += dydx; 4107798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul yTop += dydx; 4117798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 4127798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 4137798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else { 4147798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* Y-major line */ 4157798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat dxdy = line->dx / line->dy; 4167798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat yBot, yTop, xLeft, xRight; 4177798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLint iy, iyTop; 4187798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (y0 < y1) { 4197798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul yBot = y0 - line->halfWidth; 4207798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul yTop = y1 + line->halfWidth; 4217798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (line->dx >= 0.0) { 4227b9fe820a3fba3849864682fbb1cb512362934abKarl Schultz xLeft = x0 - 3.0F * line->halfWidth; 4237798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul xRight = x0 + line->halfWidth; 4247798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 4257798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else { 4267798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul xLeft = x0 - line->halfWidth; 4277b9fe820a3fba3849864682fbb1cb512362934abKarl Schultz xRight = x0 + 3.0F * line->halfWidth; 4287798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 4297798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 4307798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else { 4317798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul yBot = y1 - line->halfWidth; 4327798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul yTop = y0 + line->halfWidth; 4337798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (line->dx <= 0.0) { 4347b9fe820a3fba3849864682fbb1cb512362934abKarl Schultz xLeft = x1 - 3.0F * line->halfWidth; 4357798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul xRight = x1 + line->halfWidth; 4367798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 4377798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else { 4387798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul xLeft = x1 - line->halfWidth; 4397b9fe820a3fba3849864682fbb1cb512362934abKarl Schultz xRight = x1 + 3.0F * line->halfWidth; 4407798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 4417798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 4427798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 4437798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* scan along the line, bottom-to-top */ 4447798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul iyTop = (GLint) (yTop + 1.0F); 4457798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 4467798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /*printf("avg span width: %g\n", xRight - xLeft);*/ 4477798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul for (iy = (GLint) yBot; iy < iyTop; iy++) { 4487798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLint ixLeft = (GLint) xLeft; 4497798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLint ixRight = (GLint) (xRight + 1.0F); 4507798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLint ix; 4517798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* scan across the line, left-to-right */ 4527798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul for (ix = ixLeft; ix < ixRight; ix++) { 453733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul (*plot)(ctx, line, ix, iy); 4547798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 4557798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul xLeft += dxdy; 4567798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul xRight += dxdy; 4577798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 4587798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 4597798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul} 4607798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 4617798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 4627798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#define NAME(x) aa_rgba_##x 4637798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#define DO_Z 4647798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#include "s_aalinetemp.h" 4657798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 4667798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 4679e8a961dd7d7b717a9fb4ecdea1c1b60ea355efeBrian#define NAME(x) aa_general_rgba_##x 4687798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#define DO_Z 469eca456b63d41700617987ba45a09e8f2168b9577Brian#define DO_ATTRIBS 4706b1e4ea5a54ea852a904440cd9fa50251f63f64cBrian Paul#include "s_aalinetemp.h" 4716b1e4ea5a54ea852a904440cd9fa50251f63f64cBrian Paul 4726b1e4ea5a54ea852a904440cd9fa50251f63f64cBrian Paul 4737798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 4747798374e472a8fa2f8699d38873e6b8490d853a4Brian Paulvoid 475f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg_swrast_choose_aa_line_function(struct gl_context *ctx) 4767798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul{ 4777798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul SWcontext *swrast = SWRAST_CONTEXT(ctx); 4787798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 4797798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul ASSERT(ctx->Line.SmoothFlag); 4807798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 481e5ed4c45c675ebdd595ad0d31f2835f8b2b8dc57Ian Romanick if (ctx->Texture._EnabledCoordUnits != 0 4821c0f1dd42a50464eeb81de4aad8eecf24b3d6c89Chad Versace || _swrast_use_fragment_program(ctx) 483e5ed4c45c675ebdd595ad0d31f2835f8b2b8dc57Ian Romanick || (ctx->Light.Enabled && 484e5ed4c45c675ebdd595ad0d31f2835f8b2b8dc57Ian Romanick ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) 485e5ed4c45c675ebdd595ad0d31f2835f8b2b8dc57Ian Romanick || ctx->Fog.ColorSumEnabled 486e5ed4c45c675ebdd595ad0d31f2835f8b2b8dc57Ian Romanick || swrast->_FogEnabled) { 487e5ed4c45c675ebdd595ad0d31f2835f8b2b8dc57Ian Romanick swrast->Line = aa_general_rgba_line; 4887798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 4897798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else { 490e5ed4c45c675ebdd595ad0d31f2835f8b2b8dc57Ian Romanick swrast->Line = aa_rgba_line; 4917798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 4927798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul} 493