-
Notifications
You must be signed in to change notification settings - Fork 0
/
r_drawspan.inl
63 lines (50 loc) · 1.85 KB
/
r_drawspan.inl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
static void R_DRAWSPAN_FUNCNAME(draw_span_vars_t *dsvars)
{
#if (R_DRAWSPAN_PIPELINE & (RDC_ROUNDED | RDC_BILINEAR))
if ((D_abs(dsvars->xstep) > drawvars.mag_threshold) || (D_abs(dsvars->ystep) > drawvars.mag_threshold))
{
R_GetDrawSpanFunc(RDRAW_FILTER_POINT, drawvars.filterz)(dsvars);
return;
}
#endif
{
unsigned count = dsvars->x2 - dsvars->x1 + 1;
int xfrac = dsvars->xfrac;
int yfrac = dsvars->yfrac;
const int xstep = dsvars->xstep;
const int ystep = dsvars->ystep;
const byte *source = dsvars->source;
const byte *colormap = dsvars->colormap;
byte *dest = drawvars.byte_topleft + dsvars->y*drawvars.byte_pitch + dsvars->x1;
#if (R_DRAWSPAN_PIPELINE & (RDC_DITHERZ | RDC_BILINEAR))
const int y = dsvars->y;
int x1 = dsvars->x1;
#endif
#if (R_DRAWSPAN_PIPELINE & RDC_DITHERZ)
const int fracz = (dsvars->z >> 12) & 255;
const byte *dither_colormaps[2] = { dsvars->colormap, dsvars->nextcolormap };
#endif
while (count)
{
#if (R_DRAWSPAN_PIPELINE & RDC_BILINEAR)
const int xtemp = ((xfrac >> 16) + (filter_getDitheredPixelLevel(x1, y, ((xfrac >> 8) & 0xff)))) & 63;
const int ytemp = ((yfrac >> 10) + 64 * (filter_getDitheredPixelLevel(x1, y, ((yfrac >> 8) & 0xff)))) & 4032;
#else
const int xtemp = (xfrac >> 16) & 63;
const int ytemp = (yfrac >> 10) & 4032;
#endif
const int spot = xtemp | ytemp;
xfrac += xstep;
yfrac += ystep;
#if (R_DRAWSPAN_PIPELINE & RDC_DITHERZ)
*dest++ = dither_colormaps[filter_getDitheredPixelLevel(x1, y, fracz)][source[spot]];
#else
*dest++ = colormap[source[spot]];
#endif
count--;
#if (R_DRAWSPAN_PIPELINE & (RDC_DITHERZ | RDC_BILINEAR))
x1--;
#endif
}
}
}