Debian Codegraph @

src/gui/render_templates.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2002-2010 The DOSBox Team
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 #if DBPP == 8
20 #define PSIZE 1
21 #define PTYPE Bit8u
22 #define WC scalerWriteCache.b8
23 //#define FC scalerFrameCache.b8
24 #define FC (*(scalerFrameCache_t*)(&scalerSourceCache.b32[400][0])).b8
25 #define redMask 0
26 #define greenMask 0
27 #define blueMask 0
28 #define redBits 0
29 #define greenBits 0
30 #define blueBits 0
31 #define redShift 0
32 #define greenShift 0
33 #define blueShift 0
34 #elif DBPP == 15 || DBPP == 16
35 #define PSIZE 2
36 #define PTYPE Bit16u
37 #define WC scalerWriteCache.b16
38 //#define FC scalerFrameCache.b16
39 #define FC (*(scalerFrameCache_t*)(&scalerSourceCache.b32[400][0])).b16
40 #if DBPP == 15
41 #define redMask 0x7C00
42 #define greenMask 0x03E0
43 #define blueMask 0x001F
44 #define redBits 5
45 #define greenBits 5
46 #define blueBits 5
47 #define redShift 10
48 #define greenShift 5
49 #define blueShift 0
50 #elif DBPP == 16
51 #define redMask 0xF800
52 #define greenMask 0x07E0
53 #define blueMask 0x001F
54 #define redBits 5
55 #define greenBits 6
56 #define blueBits 5
57 #define redShift 11
58 #define greenShift 5
59 #define blueShift 0
60 #endif
61 #elif DBPP == 32
62 #define PSIZE 4
63 #define PTYPE Bit32u
64 #define WC scalerWriteCache.b32
65 //#define FC scalerFrameCache.b32
66 #define FC (*(scalerFrameCache_t*)(&scalerSourceCache.b32[400][0])).b32
67 #define redMask 0xff0000
68 #define greenMask 0x00ff00
69 #define blueMask 0x0000ff
70 #define redBits 8
71 #define greenBits 8
72 #define blueBits 8
73 #define redShift 16
74 #define greenShift 8
75 #define blueShift 0
76 #endif
77
78 #define redblueMask (redMask | blueMask)
79
80
81 #if SBPP == 8 || SBPP == 9
82 #define SC scalerSourceCache.b8
83 #if DBPP == 8
84 #define PMAKE(_VAL) (_VAL)
85 #elif DBPP == 15
86 #define PMAKE(_VAL) render.pal.lut.b16[_VAL]
87 #elif DBPP == 16
88 #define PMAKE(_VAL) render.pal.lut.b16[_VAL]
89 #elif DBPP == 32
90 #define PMAKE(_VAL) render.pal.lut.b32[_VAL]
91 #endif
92 #define SRCTYPE Bit8u
93 #endif
94
95 #if SBPP == 15
96 #define SC scalerSourceCache.b16
97 #if DBPP == 15
98 #define PMAKE(_VAL) (_VAL)
99 #elif DBPP == 16
100 #define PMAKE(_VAL) (((_VAL) & 31) | ((_VAL) & ~31) << 1)
101 #elif DBPP == 32
102 #define PMAKE(_VAL) (((_VAL&(31<<10))<<9)|((_VAL&(31<<5))<<6)|((_VAL&31)<<3))
103 #endif
104 #define SRCTYPE Bit16u
105 #endif
106
107 #if SBPP == 16
108 #define SC scalerSourceCache.b16
109 #if DBPP == 15
110 #define PMAKE(_VAL) (((_VAL&~31)>>1)|(_VAL&31))
111 #elif DBPP == 16
112 #define PMAKE(_VAL) (_VAL)
113 #elif DBPP == 32
114 #define PMAKE(_VAL) (((_VAL&(31<<11))<<8)|((_VAL&(63<<5))<<5)|((_VAL&31)<<3))
115 #endif
116 #define SRCTYPE Bit16u
117 #endif
118
119 #if SBPP == 32
120 #define SC scalerSourceCache.b32
121 #if DBPP == 15
122 #define PMAKE(_VAL) (PTYPE)(((_VAL&(31<<19))>>9)|((_VAL&(31<<11))>>6)|((_VAL&(31<<3))>>3))
123 #elif DBPP == 16
124 #define PMAKE(_VAL) (PTYPE)(((_VAL&(31<<19))>>8)|((_VAL&(63<<10))>>4)|((_VAL&(31<<3))>>3))
125 #elif DBPP == 32
126 #define PMAKE(_VAL) (_VAL)
127 #endif
128 #define SRCTYPE Bit32u
129 #endif
130
131 // C0 C1 C2 D3
132 // C3 C4 C5 D4
133 // C6 C7 C8 D5
134 // D0 D1 D2 D6
135
136 #define C0 fc[-1 - SCALER_COMPLEXWIDTH]
137 #define C1 fc[+0 - SCALER_COMPLEXWIDTH]
138 #define C2 fc[+1 - SCALER_COMPLEXWIDTH]
139 #define C3 fc[-1 ]
140 #define C4 fc[+0 ]
141 #define C5 fc[+1 ]
142 #define C6 fc[-1 + SCALER_COMPLEXWIDTH]
143 #define C7 fc[+0 + SCALER_COMPLEXWIDTH]
144 #define C8 fc[+1 + SCALER_COMPLEXWIDTH]
145
146 #define D0 fc[-1 + 2*SCALER_COMPLEXWIDTH]
147 #define D1 fc[+0 + 2*SCALER_COMPLEXWIDTH]
148 #define D2 fc[+1 + 2*SCALER_COMPLEXWIDTH]
149 #define D3 fc[+2 - SCALER_COMPLEXWIDTH]
150 #define D4 fc[+2]
151 #define D5 fc[+2 + SCALER_COMPLEXWIDTH]
152 #define D6 fc[+2 + 2*SCALER_COMPLEXWIDTH]
153
154
155 #if RENDER_USE_ADVANCED_SCALERS>1
156 static void conc3d(Cache,SBPP,DBPP) (const void * s) {
157 #ifdef RENDER_NULL_INPUT
158 if (!s) {
159 render.scale.cacheRead += render.scale.cachePitch;
160 render.scale.inLine++;
161 render.scale.complexHandler();
162 return;
163 }
164 #endif
165 const SRCTYPE * src = (SRCTYPE*)s;
166 PTYPE *fc= &FC[render.scale.inLine+1][1];
167 SRCTYPE *sc = (SRCTYPE*)(render.scale.cacheRead);
168 render.scale.cacheRead += render.scale.cachePitch;
169 Bitu b;
170 bool hadChange = false;
171 /* This should also copy the surrounding pixels but it looks nice enough without */
172 for (b=0;b<render.scale.blocks;b++) {
173 #if (SBPP == 9)
174 for (Bitu x=0;x<SCALER_BLOCKSIZE;x++) {
175 PTYPE pixel = PMAKE(src[x]);
176 if (pixel != fc[x]) {
177 #else
178 for (Bitu x=0;x<SCALER_BLOCKSIZE;x+=sizeof(Bitu)/sizeof(SRCTYPE)) {
179 if (*(Bitu const*)&src[x] != *(Bitu*)&sc[x]) {
180 #endif
181 do {
182 fc[x] = PMAKE(src[x]);
183 sc[x] = src[x];
184 x++;
185 } while (x<SCALER_BLOCKSIZE);
186 hadChange = true;
187 /* Change the surrounding blocks */
188 CC[render.scale.inLine+0][1+b-1] |= SCALE_RIGHT;
189 CC[render.scale.inLine+0][1+b+0] |= SCALE_FULL;
190 CC[render.scale.inLine+0][1+b+1] |= SCALE_LEFT;
191 CC[render.scale.inLine+1][1+b-1] |= SCALE_RIGHT;
192 CC[render.scale.inLine+1][1+b+0] |= SCALE_FULL;
193 CC[render.scale.inLine+1][1+b+1] |= SCALE_LEFT;
194 CC[render.scale.inLine+2][1+b-1] |= SCALE_RIGHT;
195 CC[render.scale.inLine+2][1+b+0] |= SCALE_FULL;
196 CC[render.scale.inLine+2][1+b+1] |= SCALE_LEFT;
197 continue;
198 }
199 }
200 fc += SCALER_BLOCKSIZE;
201 sc += SCALER_BLOCKSIZE;
202 src += SCALER_BLOCKSIZE;
203 }
204 if (hadChange) {
205 CC[render.scale.inLine+0][0] = 1;
206 CC[render.scale.inLine+1][0] = 1;
207 CC[render.scale.inLine+2][0] = 1;
208 }
209 render.scale.inLine++;
210 render.scale.complexHandler();
211 }
212 #endif
213
214
215 /* Simple scalers */
216 #define SCALERNAME Normal1x
217 #define SCALERWIDTH 1
218 #define SCALERHEIGHT 1
219 #define SCALERFUNC \
220 line0[0] = P;
221 #include "render_simple.h"
222 #undef SCALERNAME
223 #undef SCALERWIDTH
224 #undef SCALERHEIGHT
225 #undef SCALERFUNC
226
227 #define SCALERNAME Normal2x
228 #define SCALERWIDTH 2
229 #define SCALERHEIGHT 2
230 #define SCALERFUNC \
231 line0[0] = P; \
232 line0[1] = P; \
233 line1[0] = P; \
234 line1[1] = P;
235 #include "render_simple.h"
236 #undef SCALERNAME
237 #undef SCALERWIDTH
238 #undef SCALERHEIGHT
239 #undef SCALERFUNC
240
241 #define SCALERNAME Normal3x
242 #define SCALERWIDTH 3
243 #define SCALERHEIGHT 3
244 #define SCALERFUNC \
245 line0[0] = P; \
246 line0[1] = P; \
247 line0[2] = P; \
248 line1[0] = P; \
249 line1[1] = P; \
250 line1[2] = P; \
251 line2[0] = P; \
252 line2[1] = P; \
253 line2[2] = P;
254 #include "render_simple.h"
255 #undef SCALERNAME
256 #undef SCALERWIDTH
257 #undef SCALERHEIGHT
258 #undef SCALERFUNC
259
260 #define SCALERNAME NormalDw
261 #define SCALERWIDTH 2
262 #define SCALERHEIGHT 1
263 #define SCALERFUNC \
264 line0[0] = P; \
265 line0[1] = P;
266 #include "render_simple.h"
267 #undef SCALERNAME
268 #undef SCALERWIDTH
269 #undef SCALERHEIGHT
270 #undef SCALERFUNC
271
272 #define SCALERNAME NormalDh
273 #define SCALERWIDTH 1
274 #define SCALERHEIGHT 2
275 #define SCALERFUNC \
276 line0[0] = P; \
277 line1[0] = P;
278 #include "render_simple.h"
279 #undef SCALERNAME
280 #undef SCALERWIDTH
281 #undef SCALERHEIGHT
282 #undef SCALERFUNC
283
284 #if (DBPP > 8)
285
286 #if RENDER_USE_ADVANCED_SCALERS>0
287
288 #define SCALERNAME TV2x
289 #define SCALERWIDTH 2
290 #define SCALERHEIGHT 2
291 #define SCALERFUNC \
292 { \
293 Bitu halfpixel=(((P & redblueMask) * 5) >> 3) & redblueMask; \
294 halfpixel|=(((P & greenMask) * 5) >> 3) & greenMask; \
295 line0[0]=P; \
296 line0[1]=P; \
297 line1[0]=halfpixel; \
298 line1[1]=halfpixel; \
299 }
300 #include "render_simple.h"
301 #undef SCALERNAME
302 #undef SCALERWIDTH
303 #undef SCALERHEIGHT
304 #undef SCALERFUNC
305
306 #define SCALERNAME TV3x
307 #define SCALERWIDTH 3
308 #define SCALERHEIGHT 3
309 #define SCALERFUNC \
310 { \
311 Bitu halfpixel=(((P & redblueMask) * 5) >> 3) & redblueMask; \
312 halfpixel|=(((P & greenMask) * 5) >> 3) & greenMask; \
313 line0[0]=P; \
314 line0[1]=P; \
315 line0[2]=P; \
316 line1[0]=halfpixel; \
317 line1[1]=halfpixel; \
318 line1[2]=halfpixel; \
319 halfpixel=(((P & redblueMask) * 5) >> 4) & redblueMask; \
320 halfpixel|=(((P & greenMask) * 5) >> 4) & greenMask; \
321 line2[0]=halfpixel; \
322 line2[1]=halfpixel; \
323 line2[2]=halfpixel; \
324 }
325 #include "render_simple.h"
326 #undef SCALERNAME
327 #undef SCALERWIDTH
328 #undef SCALERHEIGHT
329 #undef SCALERFUNC
330
331 #define SCALERNAME RGB2x
332 #define SCALERWIDTH 2
333 #define SCALERHEIGHT 2
334 #define SCALERFUNC \
335 line0[0]=P & redMask; \
336 line0[1]=P & greenMask; \
337 line1[0]=P & blueMask; \
338 line1[1]=P;
339 #include "render_simple.h"
340 #undef SCALERNAME
341 #undef SCALERWIDTH
342 #undef SCALERHEIGHT
343 #undef SCALERFUNC
344
345 #define SCALERNAME RGB3x
346 #define SCALERWIDTH 3
347 #define SCALERHEIGHT 3
348 #define SCALERFUNC \
349 line0[0]=P; \
350 line0[1]=P & greenMask; \
351 line0[2]=P & blueMask; \
352 line1[0]=P & greenMask; \
353 line1[1]=P & redMask; \
354 line1[2]=P; \
355 line2[0]=P; \
356 line2[1]=P & blueMask; \
357 line2[2]=P & redMask;
358 #include "render_simple.h"
359 #undef SCALERNAME
360 #undef SCALERWIDTH
361 #undef SCALERHEIGHT
362 #undef SCALERFUNC
363
364 #define SCALERNAME Scan2x
365 #define SCALERWIDTH 2
366 #define SCALERHEIGHT 2
367 #define SCALERFUNC \
368 line0[0]=P; \
369 line0[1]=P; \
370 line1[0]=0; \
371 line1[1]=0;
372 #include "render_simple.h"
373 #undef SCALERNAME
374 #undef SCALERWIDTH
375 #undef SCALERHEIGHT
376 #undef SCALERFUNC
377
378 #define SCALERNAME Scan3x
379 #define SCALERWIDTH 3
380 #define SCALERHEIGHT 3
381 #define SCALERFUNC \
382 line0[0]=P; \
383 line0[1]=P; \
384 line0[2]=P; \
385 line1[0]=P; \
386 line1[1]=P; \
387 line1[2]=P; \
388 line2[0]=0; \
389 line2[1]=0; \
390 line2[2]=0;
391 #include "render_simple.h"
392 #undef SCALERNAME
393 #undef SCALERWIDTH
394 #undef SCALERHEIGHT
395 #undef SCALERFUNC
396
397 #endif //#if RENDER_USE_ADVANCED_SCALERS>0
398
399 #endif //#if (DBPP > 8)
400
401 /* Complex scalers */
402
403 #if RENDER_USE_ADVANCED_SCALERS>2
404
405 #if (SBPP == DBPP)
406
407
408 #if (DBPP > 8)
409
410 #include "render_templates_hq.h"
411
412 #define SCALERNAME HQ2x
413 #define SCALERWIDTH 2
414 #define SCALERHEIGHT 2
415 #include "render_templates_hq2x.h"
416 #define SCALERFUNC conc2d(Hq2x,SBPP)(line0, line1, fc)
417 #include "render_loops.h"
418 #undef SCALERNAME
419 #undef SCALERWIDTH
420 #undef SCALERHEIGHT
421 #undef SCALERFUNC
422
423 #define SCALERNAME HQ3x
424 #define SCALERWIDTH 3
425 #define SCALERHEIGHT 3
426 #include "render_templates_hq3x.h"
427 #define SCALERFUNC conc2d(Hq3x,SBPP)(line0, line1, line2, fc)
428 #include "render_loops.h"
429 #undef SCALERNAME
430 #undef SCALERWIDTH
431 #undef SCALERHEIGHT
432 #undef SCALERFUNC
433
434 #include "render_templates_sai.h"
435
436 #define SCALERNAME Super2xSaI
437 #define SCALERWIDTH 2
438 #define SCALERHEIGHT 2
439 #define SCALERFUNC conc2d(Super2xSaI,SBPP)(line0, line1, fc)
440 #include "render_loops.h"
441 #undef SCALERNAME
442 #undef SCALERWIDTH
443 #undef SCALERHEIGHT
444 #undef SCALERFUNC
445
446 #define SCALERNAME SuperEagle
447 #define SCALERWIDTH 2
448 #define SCALERHEIGHT 2
449 #define SCALERFUNC conc2d(SuperEagle,SBPP)(line0, line1, fc)
450 #include "render_loops.h"
451 #undef SCALERNAME
452 #undef SCALERWIDTH
453 #undef SCALERHEIGHT
454 #undef SCALERFUNC
455
456 #define SCALERNAME _2xSaI
457 #define SCALERWIDTH 2
458 #define SCALERHEIGHT 2
459 #define SCALERFUNC conc2d(_2xSaI,SBPP)(line0, line1, fc)
460 #include "render_loops.h"
461 #undef SCALERNAME
462 #undef SCALERWIDTH
463 #undef SCALERHEIGHT
464 #undef SCALERFUNC
465
466 #define SCALERNAME AdvInterp2x
467 #define SCALERWIDTH 2
468 #define SCALERHEIGHT 2
469 #define SCALERFUNC \
470 if (C1 != C7 && C3 != C5) { \
471 line0[0] = C3 == C1 ? interp_w2(C3,C4,5U,3U) : C4; \
472 line0[1] = C1 == C5 ? interp_w2(C5,C4,5U,3U) : C4; \
473 line1[0] = C3 == C7 ? interp_w2(C3,C4,5U,3U) : C4; \
474 line1[1] = C7 == C5 ? interp_w2(C5,C4,5U,3U) : C4; \
475 } else { \
476 line0[0] = line0[1] = C4; \
477 line1[0] = line1[1] = C4; \
478 }
479 #include "render_loops.h"
480 #undef SCALERNAME
481 #undef SCALERWIDTH
482 #undef SCALERHEIGHT
483 #undef SCALERFUNC
484
485 //TODO, come up with something better for this one
486 #define SCALERNAME AdvInterp3x
487 #define SCALERWIDTH 3
488 #define SCALERHEIGHT 3
489 #define SCALERFUNC \
490 if ((C1 != C7) && (C3 != C5)) { \
491 line0[0] = C3 == C1 ? interp_w2(C3,C4,5U,3U) : C4; \
492 line0[1] = (C3 == C1 && C4 != C2) || (C5 == C1 && C4 != C0) ? C1 : C4; \
493 line0[2] = C5 == C1 ? interp_w2(C5,C4,5U,3U) : C4; \
494 line1[0] = (C3 == C1 && C4 != C6) || (C3 == C7 && C4 != C0) ? C3 : C4; \
495 line1[1] = C4; \
496 line1[2] = (C5 == C1 && C4 != C8) || (C5 == C7 && C4 != C2) ? C5 : C4; \
497 line2[0] = C3 == C7 ? interp_w2(C3,C4,5U,3U) : C4; \
498 line2[1] = (C3 == C7 && C4 != C8) || (C5 == C7 && C4 != C6) ? C7 : C4; \
499 line2[2] = C5 == C7 ? interp_w2(C5,C4,5U,3U) : C4; \
500 } else { \
501 line0[0] = line0[1] = line0[2] = C4; \
502 line1[0] = line1[1] = line1[2] = C4; \
503 line2[0] = line2[1] = line2[2] = C4; \
504 }
505 #include "render_loops.h"
506 #undef SCALERNAME
507 #undef SCALERWIDTH
508 #undef SCALERHEIGHT
509 #undef SCALERFUNC
510
511 #endif // #if (DBPP > 8)
512
513 #define SCALERNAME AdvMame2x
514 #define SCALERWIDTH 2
515 #define SCALERHEIGHT 2
516 #define SCALERFUNC \
517 if (C1 != C7 && C3 != C5) { \
518 line0[0] = C3 == C1 ? C3 : C4; \
519 line0[1] = C1 == C5 ? C5 : C4; \
520 line1[0] = C3 == C7 ? C3 : C4; \
521 line1[1] = C7 == C5 ? C5 : C4; \
522 } else { \
523 line0[0] = line0[1] = C4; \
524 line1[0] = line1[1] = C4; \
525 }
526 #include "render_loops.h"
527 #undef SCALERNAME
528 #undef SCALERWIDTH
529 #undef SCALERHEIGHT
530 #undef SCALERFUNC
531
532 #define SCALERNAME AdvMame3x
533 #define SCALERWIDTH 3
534 #define SCALERHEIGHT 3
535 #define SCALERFUNC \
536 if ((C1 != C7) && (C3 != C5)) { \
537 line0[0] = C3 == C1 ? C3 : C4; \
538 line0[1] = (C3 == C1 && C4 != C2) || (C5 == C1 && C4 != C0) ? C1 : C4; \
539 line0[2] = C5 == C1 ? C5 : C4; \
540 line1[0] = (C3 == C1 && C4 != C6) || (C3 == C7 && C4 != C0) ? C3 : C4; \
541 line1[1] = C4; \
542 line1[2] = (C5 == C1 && C4 != C8) || (C5 == C7 && C4 != C2) ? C5 : C4; \
543 line2[0] = C3 == C7 ? C3 : C4; \
544 line2[1] = (C3 == C7 && C4 != C8) || (C5 == C7 && C4 != C6) ? C7 : C4; \
545 line2[2] = C5 == C7 ? C5 : C4; \
546 } else { \
547 line0[0] = line0[1] = line0[2] = C4; \
548 line1[0] = line1[1] = line1[2] = C4; \
549 line2[0] = line2[1] = line2[2] = C4; \
550 }
551
552 #include "render_loops.h"
553 #undef SCALERNAME
554 #undef SCALERWIDTH
555 #undef SCALERHEIGHT
556 #undef SCALERFUNC
557
558
559 #endif // (SBPP == DBPP) && !defined (CACHEWITHPAL)
560
561 #endif // #if RENDER_USE_ADVANCED_SCALERS>2
562
563 #undef PSIZE
564 #undef PTYPE
565 #undef PMAKE
566 #undef WC
567 #undef LC
568 #undef FC
569 #undef SC
570 #undef redMask
571 #undef greenMask
572 #undef blueMask
573 #undef redblueMask
574 #undef redBits
575 #undef greenBits
576 #undef blueBits
577 #undef redShift
578 #undef greenShift
579 #undef blueShift
580 #undef SRCTYPE