s_alpha.c revision bf80e1ed620836e2ca0dd3f7d2d4cb187d17563d
1bf80e1ed620836e2ca0dd3f7d2d4cb187d17563dBrian Paul/* $Id: s_alpha.c,v 1.10 2002/04/19 14:05:50 brianp Exp $ */
2e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
3e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell/*
4e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Mesa 3-D graphics library
52ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul * Version:  4.1
622144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
72ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
822144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
9e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a
10e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * copy of this software and associated documentation files (the "Software"),
11e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * to deal in the Software without restriction, including without limitation
12e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * and/or sell copies of the Software, and to permit persons to whom the
14e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * Software is furnished to do so, subject to the following conditions:
1522144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
16e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * The above copyright notice and this permission notice shall be included
17e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * in all copies or substantial portions of the Software.
1822144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
19e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell */
26e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
27bf80e1ed620836e2ca0dd3f7d2d4cb187d17563dBrian Paul/**
28bf80e1ed620836e2ca0dd3f7d2d4cb187d17563dBrian Paul * \file swrast/s_alpha.c
29bf80e1ed620836e2ca0dd3f7d2d4cb187d17563dBrian Paul * \brief Functions to apply alpha test.
30bf80e1ed620836e2ca0dd3f7d2d4cb187d17563dBrian Paul */
31e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
32e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#include "glheader.h"
33e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#include "context.h"
34e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#include "colormac.h"
35e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#include "macros.h"
36e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#include "mmath.h"
37e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
38e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell#include "s_alpha.h"
39ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul#include "s_context.h"
40e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
41e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
42bf80e1ed620836e2ca0dd3f7d2d4cb187d17563dBrian Paul/**
43bf80e1ed620836e2ca0dd3f7d2d4cb187d17563dBrian Paul * \fn GLint _mesa_alpha_test( const GLcontext *ctx, struct sw_span *span )
44bf80e1ed620836e2ca0dd3f7d2d4cb187d17563dBrian Paul * \brief Apply the alpha test to a span of pixels.
45bf80e1ed620836e2ca0dd3f7d2d4cb187d17563dBrian Paul * \return
46bf80e1ed620836e2ca0dd3f7d2d4cb187d17563dBrian Paul *      - "0" = all pixels in the span failed the alpha test.
47bf80e1ed620836e2ca0dd3f7d2d4cb187d17563dBrian Paul *      - "1" = one or more pixels passed the alpha test.
482ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul */
492ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian PaulGLint
50ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul_mesa_alpha_test( const GLcontext *ctx, struct sw_span *span )
512ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul{
52ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul   const GLchan (*rgba)[4] = (const GLchan (*)[4]) span->color.rgba;
532ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul   const GLchan ref = ctx->Color.AlphaRef;
54ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul   const GLuint n = span->end;
552ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul   GLubyte *mask = span->mask;
56ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul   GLuint i;
572ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul
58ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul   if (span->arrayMask & SPAN_RGBA) {
59ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul      /* Use the array values */
60ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul      switch (ctx->Color.AlphaFunc) {
61ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_LESS:
62ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            for (i = 0; i < n; i++)
63ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               mask[i] &= (rgba[i][ACOMP] < ref);
64ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            break;
65ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_LEQUAL:
66ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            for (i = 0; i < n; i++)
67ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               mask[i] &= (rgba[i][ACOMP] <= ref);
68ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            break;
69ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_GEQUAL:
70ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            for (i = 0; i < n; i++)
71ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               mask[i] &= (rgba[i][ACOMP] >= ref);
72ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            break;
73ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_GREATER:
74ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            for (i = 0; i < n; i++)
75ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               mask[i] &= (rgba[i][ACOMP] > ref);
76ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            break;
77ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_NOTEQUAL:
78ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            for (i = 0; i < n; i++)
79ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               mask[i] &= (rgba[i][ACOMP] != ref);
80ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            break;
81ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_EQUAL:
82ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            for (i = 0; i < n; i++)
83ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               mask[i] &= (rgba[i][ACOMP] == ref);
84ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            break;
85ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_ALWAYS:
86ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            /* do nothing */
87ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            return 1;
88ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_NEVER:
89ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            /* caller should check for zero! */
90ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            span->writeAll = GL_FALSE;
91ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            return 0;
92ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         default:
93ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            _mesa_problem( ctx, "Invalid alpha test in _mesa_alpha_test" );
94ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            return 0;
95ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul      }
96ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul   }
97ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul   else {
98ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul      /* Use the interpolation values */
99ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul#if CHAN_TYPE == GL_FLOAT
100ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul      const GLfloat alphaStep = span->alphaStep;
101ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul      GLfloat alpha = span->alpha;
102ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul      ASSERT(span->interpMask & SPAN_RGBA);
103ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul      switch (ctx->Color.AlphaFunc) {
104ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_LESS:
105ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            for (i = 0; i < n; i++) {
106ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               mask[i] &= (alpha < ref);
107ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               alpha += alphaStep;
108ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            }
109ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            break;
110ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_LEQUAL:
111ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            for (i = 0; i < n; i++) {
112ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               mask[i] &= (alpha <= ref);
113ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               alpha += alphaStep;
114ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            }
115ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            break;
116ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_GEQUAL:
117ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            for (i = 0; i < n; i++) {
118ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               mask[i] &= (alpha >= ref);
119ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               alpha += alphaStep;
120ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            }
121ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            break;
122ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_GREATER:
123ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            for (i = 0; i < n; i++) {
124ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               mask[i] &= (alpha > ref);
125ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               alpha += alphaStep;
126ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            }
127ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            break;
128ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_NOTEQUAL:
129ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            for (i = 0; i < n; i++) {
130ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               mask[i] &= (alpha != ref);
131ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               alpha += alphaStep;
132ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            }
133ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            break;
134ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_EQUAL:
135ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            for (i = 0; i < n; i++) {
136ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               mask[i] &= (alpha == ref);
137ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               alpha += alphaStep;
138ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            }
139ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            break;
140ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_ALWAYS:
141ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            /* do nothing */
142ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            return 1;
143ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_NEVER:
144ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            /* caller should check for zero! */
145ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            span->writeAll = GL_FALSE;
146ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            return 0;
147ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         default:
148ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            _mesa_problem( ctx, "Invalid alpha test in gl_alpha_test" );
149ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            return 0;
150ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul      }
151ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul#else
152ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul      /* 8 or 16-bit channel interpolation */
153ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul      const GLfixed alphaStep = span->alphaStep;
154ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul      GLfixed alpha = span->alpha;
155ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul      ASSERT(span->interpMask & SPAN_RGBA);
156ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul      switch (ctx->Color.AlphaFunc) {
157ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_LESS:
158ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            for (i = 0; i < n; i++) {
159ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               mask[i] &= (FixedToChan(alpha) < ref);
160ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               alpha += alphaStep;
161ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            }
162ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            break;
163ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_LEQUAL:
164ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            for (i = 0; i < n; i++) {
165ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               mask[i] &= (FixedToChan(alpha) <= ref);
166ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               alpha += alphaStep;
167ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            }
168ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            break;
169ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_GEQUAL:
170ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            for (i = 0; i < n; i++) {
171ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               mask[i] &= (FixedToChan(alpha) >= ref);
172ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               alpha += alphaStep;
173ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            }
174ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            break;
175ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_GREATER:
176ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            for (i = 0; i < n; i++) {
177ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               mask[i] &= (FixedToChan(alpha) > ref);
178ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               alpha += alphaStep;
179ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            }
180ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            break;
181ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_NOTEQUAL:
182ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            for (i = 0; i < n; i++) {
183ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               mask[i] &= (FixedToChan(alpha) != ref);
184ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               alpha += alphaStep;
185ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            }
186ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            break;
187ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_EQUAL:
188ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            for (i = 0; i < n; i++) {
189ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               mask[i] &= (FixedToChan(alpha) == ref);
190ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul               alpha += alphaStep;
191ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            }
192ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            break;
193ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_ALWAYS:
194ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            /* do nothing */
195ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            return 1;
196ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         case GL_NEVER:
197ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            /* caller should check for zero! */
198ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            span->writeAll = GL_FALSE;
199ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            return 0;
200ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul         default:
201ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            _mesa_problem( ctx, "Invalid alpha test in gl_alpha_test" );
202ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul            return 0;
203ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul      }
204ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul#endif /* CHAN_TYPE */
2052ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul   }
2062ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul
2072a182a98973edc9ecf2936b1288485bb2b3fa722Brian Paul#if 0
2082a182a98973edc9ecf2936b1288485bb2b3fa722Brian Paul   /* XXXX This causes conformance failures!!!! */
2092ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul   while ((span->start <= span->end)  &&
210ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul          (mask[span->start] == 0))
2112ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul     span->start ++;
2122ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul
2132ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul   while ((span->end >= span->start)  &&
214ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul          (mask[span->end] == 0))
2152ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul     span->end --;
2162a182a98973edc9ecf2936b1288485bb2b3fa722Brian Paul#endif
217ceb39f4f8dc4863fde17d668c752533a2184476eBrian Paul
2182ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul   span->writeAll = GL_FALSE;
219e3a051e0538a605551f4d58294c94f5eb00ed07fKeith Whitwell
2202ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul   if (span->start >= span->end)
2212ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul     return 0;
2222ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul   else
2232ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul     return 1;
2242ef866d1fc0a5cc5ef8543d65744dfd4da4dbbafBrian Paul}
225