aboutsummaryrefslogtreecommitdiff
path: root/src/r_drawspan.inl
diff options
context:
space:
mode:
Diffstat (limited to 'src/r_drawspan.inl')
-rw-r--r--src/r_drawspan.inl160
1 files changed, 160 insertions, 0 deletions
diff --git a/src/r_drawspan.inl b/src/r_drawspan.inl
new file mode 100644
index 0000000..84cc95d
--- /dev/null
+++ b/src/r_drawspan.inl
@@ -0,0 +1,160 @@
1/* Emacs style mode select -*- C++ -*-
2 *-----------------------------------------------------------------------------
3 *
4 *
5 * PrBoom: a Doom port merged with LxDoom and LSDLDoom
6 * based on BOOM, a modified and improved DOOM engine
7 * Copyright (C) 1999 by
8 * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
9 * Copyright (C) 1999-2000 by
10 * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
11 * Copyright 2005, 2006 by
12 * Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 * 02111-1307, USA.
28 *
29 *-----------------------------------------------------------------------------*/
30
31//
32// R_DrawSpan
33//
34
35#if (R_DRAWSPAN_PIPELINE_BITS == 8)
36#define SCREENTYPE byte
37#define TOPLEFT byte_topleft
38#define PITCH byte_pitch
39#elif (R_DRAWSPAN_PIPELINE_BITS == 15)
40#define SCREENTYPE unsigned short
41#define TOPLEFT short_topleft
42#define PITCH short_pitch
43#elif (R_DRAWSPAN_PIPELINE_BITS == 16)
44#define SCREENTYPE unsigned short
45#define TOPLEFT short_topleft
46#define PITCH short_pitch
47#elif (R_DRAWSPAN_PIPELINE_BITS == 32)
48#define SCREENTYPE unsigned int
49#define TOPLEFT int_topleft
50#define PITCH int_pitch
51#endif
52
53#if (R_DRAWSPAN_PIPELINE & RDC_DITHERZ)
54 #define GETDEPTHMAP(col) dither_colormaps[filter_getDitheredPixelLevel(x1, y, fracz)][(col)]
55#else
56 #define GETDEPTHMAP(col) colormap[(col)]
57#endif
58
59#if (R_DRAWSPAN_PIPELINE_BITS == 8)
60 #define GETCOL_POINT(col) GETDEPTHMAP(col)
61 #define GETCOL_LINEAR(col) GETDEPTHMAP(col)
62#elif (R_DRAWSPAN_PIPELINE_BITS == 15)
63 #define GETCOL_POINT(col) VID_PAL15(GETDEPTHMAP(col), VID_COLORWEIGHTMASK)
64 #define GETCOL_LINEAR(col) filter_getFilteredForSpan15(GETDEPTHMAP, xfrac, yfrac)
65#elif (R_DRAWSPAN_PIPELINE_BITS == 16)
66 #define GETCOL_POINT(col) VID_PAL16(GETDEPTHMAP(col), VID_COLORWEIGHTMASK)
67 #define GETCOL_LINEAR(col) filter_getFilteredForSpan16(GETDEPTHMAP, xfrac, yfrac)
68#elif (R_DRAWSPAN_PIPELINE_BITS == 32)
69 #define GETCOL_POINT(col) VID_PAL32(GETDEPTHMAP(col), VID_COLORWEIGHTMASK)
70 #define GETCOL_LINEAR(col) filter_getFilteredForSpan32(GETDEPTHMAP, xfrac, yfrac)
71#endif
72
73#if (R_DRAWSPAN_PIPELINE & RDC_BILINEAR)
74 #define GETCOL(col) GETCOL_LINEAR(col)
75#else
76 #define GETCOL(col) GETCOL_POINT(col)
77#endif
78
79static void R_DRAWSPAN_FUNCNAME(draw_span_vars_t *dsvars)
80{
81#if (R_DRAWSPAN_PIPELINE & (RDC_ROUNDED|RDC_BILINEAR))
82 // drop back to point filtering if we're minifying
83 // 49152 = FRACUNIT * 0.75
84 if ((D_abs(dsvars->xstep) > drawvars.mag_threshold)
85 || (D_abs(dsvars->ystep) > drawvars.mag_threshold))
86 {
87 R_GetDrawSpanFunc(RDRAW_FILTER_POINT,
88 drawvars.filterz)(dsvars);
89 return;
90 }
91#endif
92 {
93 unsigned count = dsvars->x2 - dsvars->x1 + 1;
94 fixed_t xfrac = dsvars->xfrac;
95 fixed_t yfrac = dsvars->yfrac;
96 const fixed_t xstep = dsvars->xstep;
97 const fixed_t ystep = dsvars->ystep;
98 const byte *source = dsvars->source;
99 const byte *colormap = dsvars->colormap;
100 SCREENTYPE *dest = drawvars.TOPLEFT + dsvars->y*drawvars.PITCH + dsvars->x1;
101#if (R_DRAWSPAN_PIPELINE & (RDC_DITHERZ|RDC_BILINEAR))
102 const int y = dsvars->y;
103 int x1 = dsvars->x1;
104#endif
105#if (R_DRAWSPAN_PIPELINE & RDC_DITHERZ)
106 const int fracz = (dsvars->z >> 12) & 255;
107 const byte *dither_colormaps[2] = { dsvars->colormap, dsvars->nextcolormap };
108#endif
109
110 while (count) {
111#if ((R_DRAWSPAN_PIPELINE_BITS != 8) && (R_DRAWSPAN_PIPELINE & RDC_BILINEAR))
112 // truecolor bilinear filtered
113 *dest++ = GETCOL(0);
114 xfrac += xstep;
115 yfrac += ystep;
116 count--;
117 #if (R_DRAWSPAN_PIPELINE & RDC_DITHERZ)
118 x1--;
119 #endif
120#elif (R_DRAWSPAN_PIPELINE & RDC_ROUNDED)
121 *dest++ = GETCOL(filter_getRoundedForSpan(xfrac, yfrac));
122 xfrac += xstep;
123 yfrac += ystep;
124 count--;
125 #if (R_DRAWSPAN_PIPELINE & RDC_DITHERZ)
126 x1--;
127 #endif
128#else
129 #if (R_DRAWSPAN_PIPELINE & RDC_BILINEAR)
130 // 8 bit bilinear
131 const fixed_t xtemp = ((xfrac >> 16) + (filter_getDitheredPixelLevel(x1, y, ((xfrac>>8)&0xff)))) & 63;
132 const fixed_t ytemp = ((yfrac >> 10) + 64*(filter_getDitheredPixelLevel(x1, y, ((yfrac>>8)&0xff)))) & 4032;
133 #else
134 const fixed_t xtemp = (xfrac >> 16) & 63;
135 const fixed_t ytemp = (yfrac >> 10) & 4032;
136 #endif
137 const fixed_t spot = xtemp | ytemp;
138 xfrac += xstep;
139 yfrac += ystep;
140 *dest++ = GETCOL(source[spot]);
141 count--;
142 #if (R_DRAWSPAN_PIPELINE & (RDC_DITHERZ|RDC_BILINEAR))
143 x1--;
144 #endif
145#endif
146 }
147 }
148}
149
150#undef GETDEPTHMAP
151#undef GETCOL_LINEAR
152#undef GETCOL_POINT
153#undef GETCOL
154#undef PITCH
155#undef TOPLEFT
156#undef SCREENTYPE
157
158#undef R_DRAWSPAN_PIPELINE_BITS
159#undef R_DRAWSPAN_PIPELINE
160#undef R_DRAWSPAN_FUNCNAME