source: trunk/src/ddraw/fillfunc.cpp@ 10367

Last change on this file since 10367 was 8830, checked in by sandervl, 23 years ago

MoveRect fixes (src & dest surfaces the same + overlap); fill fixes + optimizations

File size: 17.4 KB
Line 
1/* $Id: fillfunc.cpp,v 1.8 2002-07-03 15:44:39 sandervl Exp $ */
2
3/*
4 * ColorFill functions
5 *
6 * Copyright 1999 Markus Montkowski
7 *
8 * Project Odin Software License can be found in LICENSE.TXT
9 *
10 */
11
12#define INCL_BASE
13#include <os2wrap.h>
14#include <win32type.h>
15#include <memory.h>
16#include <misc.h>
17#include "fillfunc.h"
18#include "asmutil.h"
19
20//
21// Blt Functions
22//
23
24//*****************************************************************************
25//*****************************************************************************
26void CDECL Fill8(char* pDst, DWORD dwWidth, DWORD dwHeight, DWORD dwPitch, DWORD dwColor)
27{
28 DWORD *pColor;
29 char *pFillPos;
30
31 dprintf(("DDRAW:Fill8 %x (%d,%d) %d with %x \n", pDst, dwWidth, dwHeight, dwPitch, dwColor));
32
33 if(dwWidth == dwPitch)
34 {
35 // Width = Pitch => fill buffer so no need to take care of lines
36 memset(pDst, dwColor, dwWidth*dwHeight);
37 }
38 else
39 {
40 pFillPos = pDst;
41
42 while(dwHeight)
43 {
44 memset(pFillPos, dwColor, dwWidth);
45 pFillPos += dwPitch;
46 dwHeight--;
47 }
48 }
49}
50//*****************************************************************************
51//*****************************************************************************
52void CDECL Fill16(char* pDst, DWORD dwWidth, DWORD dwHeight, DWORD dwPitch, DWORD dwColor)
53{
54 DWORD *pColor;
55 char *pFillPos;
56
57 dprintf(("DDRAW:Fill16 %x (%d,%d) %d with %x \n", pDst, dwWidth, dwHeight, dwPitch, dwColor));
58
59 dwWidth *=2;
60
61 if(dwWidth == dwPitch)
62 {
63 // Width = Pitch => fill buffer so no need to take care of lines
64 ddmemfill16(pDst, dwColor, dwWidth*dwHeight);
65 }
66 else
67 {
68 pFillPos = pDst;
69
70 while(dwHeight)
71 {
72 ddmemfill16(pFillPos, dwColor, dwWidth);
73 pFillPos += dwPitch;
74 dwHeight--;
75 }
76 }
77}
78//*****************************************************************************
79//*****************************************************************************
80void CDECL Fill24(char* pDst, DWORD dwWidth, DWORD dwHeight, DWORD dwPitch, DWORD dwColor)
81{
82 DWORD *pColor;
83 char *pFillPos;
84 int i;
85
86 dprintf(("DDRAW:Fill24 %x (%d,%d) %d with %x \n", pDst, dwWidth, dwHeight, dwPitch, dwColor));
87
88 // First Fill First row with the color
89
90 for(i=0 ; i<dwWidth ; i++)
91 {
92 pColor = (DWORD*)(pDst+(i*3));
93 *pColor = dwColor;
94 }
95 dwWidth *=3;
96 dwHeight--;
97
98 if(dwWidth == dwPitch)
99 {
100 // Width = Pitch => fill buffer so no need to take care of lines
101 memcpy(pDst+dwPitch, pDst, dwWidth*dwHeight);
102 }
103 else
104 {
105 pFillPos = pDst+dwPitch;
106 while(dwHeight)
107 {
108 memcpy(pFillPos,pDst,dwWidth);
109 pFillPos += dwPitch;
110 dwHeight--;
111 }
112 }
113}
114//*****************************************************************************
115//*****************************************************************************
116void CDECL Fill32(char* pDst, DWORD dwWidth, DWORD dwHeight, DWORD dwPitch, DWORD dwColor)
117{
118 DWORD *pColor;
119 char *pFillPos;
120
121 dprintf(("DDRAW:Fill32 %x (%d,%d) %d with %x \n", pDst, dwWidth, dwHeight, dwPitch, dwColor));
122
123 dwWidth *= 4;
124
125 if(dwWidth == dwPitch)
126 {
127 // Width = Pitch => fill buffer so no need to take care of lines
128 ddmemfill32(pDst, dwColor, dwWidth*dwHeight);
129 }
130 else
131 {
132 pFillPos = pDst;
133
134 while(dwHeight)
135 {
136 ddmemfill32(pFillPos, dwColor, dwWidth);
137 pFillPos += dwPitch;
138 dwHeight--;
139 }
140 }
141}
142//*****************************************************************************
143//*****************************************************************************
144void CDECL Fill8on8( char *pDB,
145 char *pFB,
146 DWORD dwTop,
147 DWORD dwLeft,
148 DWORD dwWidth,
149 DWORD dwHeight,
150 DWORD dwPitchDB,
151 DWORD dwPitchFB,
152 DWORD dwColor,
153 VOID *pPalette
154 )
155{
156 dprintf(("Fill8on8\n"));
157 dwColor = (dwColor&0xFF)+(dwColor&0xFF<<8);
158 dwColor += (dwColor<<16);
159
160 Fill8( pDB+(dwTop*dwPitchDB)+dwLeft,
161 dwWidth,
162 dwHeight,
163 dwPitchDB,
164 dwColor);
165}
166//*****************************************************************************
167//*****************************************************************************
168void CDECL Fill16on16( char *pDB,
169 char *pFB,
170 DWORD dwTop,
171 DWORD dwLeft,
172 DWORD dwWidth,
173 DWORD dwHeight,
174 DWORD dwPitchDB,
175 DWORD dwPitchFB,
176 DWORD dwColor,
177 VOID *pPalette
178 )
179{
180 dprintf(("Fill16on16 %x (%d,%d)(%d,%d) %d %x", pDB+(dwTop*dwPitchDB)+(dwLeft*2), dwLeft, dwTop, dwWidth, dwHeight, dwPitchDB, dwColor));
181
182 dwColor = (dwColor&0xFFFF)+((dwColor&0xFFFF)<<16);
183
184 Fill16( pDB+(dwTop*dwPitchDB)+(dwLeft*2),
185 dwWidth,
186 dwHeight,
187 dwPitchDB,
188 dwColor);
189}
190//*****************************************************************************
191//*****************************************************************************
192void CDECL Fill24on24( char *pDB,
193 char *pFB,
194 DWORD dwTop,
195 DWORD dwLeft,
196 DWORD dwWidth,
197 DWORD dwHeight,
198 DWORD dwPitchDB,
199 DWORD dwPitchFB,
200 DWORD dwColor,
201 VOID *pPalette
202 )
203{
204 dprintf(("Fill24on24\n"));
205 dwColor <<= 8;
206
207 Fill24( pDB+(dwTop*dwPitchDB)+(dwLeft*3),
208 dwWidth,
209 dwHeight,
210 dwPitchDB,
211 dwColor);
212
213}
214//*****************************************************************************
215//*****************************************************************************
216void CDECL Fill32on32( char *pDB,
217 char *pFB,
218 DWORD dwTop,
219 DWORD dwLeft,
220 DWORD dwWidth,
221 DWORD dwHeight,
222 DWORD dwPitchDB,
223 DWORD dwPitchFB,
224 DWORD dwColor,
225 VOID *pPalette
226 )
227{
228 dprintf(("Fill32on32\n"));
229 Fill32( pDB+(dwTop*dwPitchDB)+(dwLeft*4),
230 dwWidth,
231 dwHeight,
232 dwPitchDB,
233 dwColor);
234}
235//*****************************************************************************
236//*****************************************************************************
237void CDECL Fill8on16( char *pDB,
238 char *pFB,
239 DWORD dwTop,
240 DWORD dwLeft,
241 DWORD dwWidth,
242 DWORD dwHeight,
243 DWORD dwPitchDB,
244 DWORD dwPitchFB,
245 DWORD dwColor,
246 VOID *pPalette
247 )
248{
249 DWORD dwCol;
250 dprintf(("Fill8on16\n"));
251 dwCol = (dwColor&0xFF)+(dwColor&0xFF<<8);
252 dwCol += (dwCol<<16);
253
254 Fill8( pFB+(dwTop*dwPitchFB)+dwLeft,
255 dwWidth,
256 dwHeight,
257 dwPitchFB,
258 dwCol);
259
260 dwCol = ((WORD*)pPalette)[dwColor];
261 dwCol += (dwCol<<16);
262 Fill16( pDB+(dwTop*dwPitchDB)+(dwLeft*2),
263 dwWidth,
264 dwHeight,
265 dwPitchDB,
266 dwCol);
267}
268//*****************************************************************************
269//*****************************************************************************
270void CDECL Fill8on24( char *pDB,
271 char *pFB,
272 DWORD dwTop,
273 DWORD dwLeft,
274 DWORD dwWidth,
275 DWORD dwHeight,
276 DWORD dwPitchDB,
277 DWORD dwPitchFB,
278 DWORD dwColor,
279 VOID *pPalette
280 )
281{
282 DWORD dwCol;
283 dprintf(("Fill8on24\n"));
284 dwCol = (dwColor&0xFF)+(dwColor&0xFF<<8);
285 dwCol += (dwCol<<16);
286
287 Fill8( pFB+(dwTop*dwPitchFB)+dwLeft,
288 dwWidth,
289 dwHeight,
290 dwPitchFB,
291 dwCol);
292
293 dwCol = ((DWORD*)pPalette)[dwColor];
294 //dwCol <<= 8;
295 Fill24( pDB+(dwTop*dwPitchDB)+(dwLeft*3),
296 dwWidth,
297 dwHeight,
298 dwPitchDB,
299 dwCol);
300}
301//*****************************************************************************
302//*****************************************************************************
303void CDECL Fill8on32( char *pDB,
304 char *pFB,
305 DWORD dwTop,
306 DWORD dwLeft,
307 DWORD dwWidth,
308 DWORD dwHeight,
309 DWORD dwPitchDB,
310 DWORD dwPitchFB,
311 DWORD dwColor,
312 VOID *pPalette
313 )
314{
315 DWORD dwCol;
316 dprintf(("Fill8on32\n"));
317 dwCol = (dwColor&0xFF)+(dwColor&0xFF<<8);
318 dwCol += (dwCol<<16);
319
320 Fill8( pFB+(dwTop*dwPitchFB)+dwLeft,
321 dwWidth,
322 dwHeight,
323 dwPitchFB,
324 dwCol);
325
326 dwCol = ((DWORD*)pPalette)[dwColor];
327 Fill32( pDB+(dwTop*dwPitchDB)+(dwLeft*4),
328 dwWidth,
329 dwHeight,
330 dwPitchDB,
331 dwCol);
332}
333//*****************************************************************************
334//*****************************************************************************
335void CDECL Fill16on8( char *pDB,
336 char *pFB,
337 DWORD dwTop,
338 DWORD dwLeft,
339 DWORD dwWidth,
340 DWORD dwHeight,
341 DWORD dwPitchDB,
342 DWORD dwPitchFB,
343 DWORD dwColor,
344 VOID *pPalette
345 )
346{
347 dprintf(("Fill16on8 NOT Implemented \n"));
348 DebugInt3();
349}
350//*****************************************************************************
351//*****************************************************************************
352void CDECL Fill16on24( char *pDB,
353 char *pFB,
354 DWORD dwTop,
355 DWORD dwLeft,
356 DWORD dwWidth,
357 DWORD dwHeight,
358 DWORD dwPitchDB,
359 DWORD dwPitchFB,
360 DWORD dwColor,
361 VOID *pPalette
362 )
363{
364 DWORD dwCol;
365 dprintf(("Fill16on24\n"));
366 dwCol = dwColor + (dwColor<<16);
367
368 Fill16( pFB+(dwTop*dwPitchFB)+(dwLeft*2),
369 dwWidth,
370 dwHeight,
371 dwPitchFB,
372 dwCol);
373
374 dwCol = ((dwColor & 0xF800)<< 16) +
375 ((dwColor & 0x07E0)<< 13) +
376 ((dwColor & 0x001F)<< 11);
377 Fill24( pDB+(dwTop*dwPitchDB)+(dwLeft*2),
378 dwWidth,
379 dwHeight,
380 dwPitchDB,
381 dwCol);
382}
383//*****************************************************************************
384//*****************************************************************************
385void CDECL Fill16on32( char *pDB,
386 char *pFB,
387 DWORD dwTop,
388 DWORD dwLeft,
389 DWORD dwWidth,
390 DWORD dwHeight,
391 DWORD dwPitchDB,
392 DWORD dwPitchFB,
393 DWORD dwColor,
394 VOID *pPalette
395 )
396{
397 DWORD dwCol;
398 dprintf(("Fill16on32\n"));
399 dwCol = dwColor + (dwColor<<16);
400
401 Fill16( pFB+(dwTop*dwPitchFB)+(dwLeft*2),
402 dwWidth,
403 dwHeight,
404 dwPitchFB,
405 dwCol);
406
407 dwCol = ((dwColor & 0xF800)<< 16) +
408 ((dwColor & 0x07E0)<< 13) +
409 ((dwColor & 0x001F)<< 11);
410 Fill32( pDB+(dwTop*dwPitchDB)+(dwLeft*4),
411 dwWidth,
412 dwHeight,
413 dwPitchDB,
414 dwCol);
415}
416//*****************************************************************************
417//*****************************************************************************
418void CDECL Fill24on8( char *pDB,
419 char *pFB,
420 DWORD dwTop,
421 DWORD dwLeft,
422 DWORD dwWidth,
423 DWORD dwHeight,
424 DWORD dwPitchDB,
425 DWORD dwPitchFB,
426 DWORD dwColor,
427 VOID *pPalette
428 )
429{
430 dprintf(("Fill24on8 NOT implemented\n"));
431 DebugInt3();
432}
433//*****************************************************************************
434//*****************************************************************************
435void CDECL Fill24on16( char *pDB,
436 char *pFB,
437 DWORD dwTop,
438 DWORD dwLeft,
439 DWORD dwWidth,
440 DWORD dwHeight,
441 DWORD dwPitchDB,
442 DWORD dwPitchFB,
443 DWORD dwColor,
444 VOID *pPalette
445 )
446{
447 DWORD dwCol;
448 dprintf(("Fill24on16\n"));
449 //dwColor <<=8;
450
451 Fill24( pFB+(dwTop*dwPitchFB)+(dwLeft*3),
452 dwWidth,
453 dwHeight,
454 dwPitchFB,
455 dwColor);
456
457 dwCol = ((dwColor & 0xF8000000) >>16) +
458 ((dwColor & 0x00FE0000)>> 13) +
459 ((dwColor & 0x0000F800)>> 11);
460
461 dwCol = dwCol + (dwCol<<16);
462 Fill16( pDB+(dwTop*dwPitchDB)+(dwLeft*2),
463 dwWidth,
464 dwHeight,
465 dwPitchDB,
466 dwCol);
467}
468//*****************************************************************************
469//*****************************************************************************
470void CDECL Fill24on32( char *pDB,
471 char *pFB,
472 DWORD dwTop,
473 DWORD dwLeft,
474 DWORD dwWidth,
475 DWORD dwHeight,
476 DWORD dwPitchDB,
477 DWORD dwPitchFB,
478 DWORD dwColor,
479 VOID *pPalette
480 )
481{
482 dprintf(("Fill24on32\n"));
483 //dwColor <<=8;
484
485 Fill24( pFB+(dwTop*dwPitchFB)+(dwLeft*3),
486 dwWidth,
487 dwHeight,
488 dwPitchFB,
489 dwColor);
490 Fill32( pDB+(dwTop*dwPitchDB)+(dwLeft*4),
491 dwWidth,
492 dwHeight,
493 dwPitchDB,
494 dwColor);
495}
496//*****************************************************************************
497//*****************************************************************************
498void CDECL Fill32on8( char *pDB,
499 char *pFB,
500 DWORD dwTop,
501 DWORD dwLeft,
502 DWORD dwWidth,
503 DWORD dwHeight,
504 DWORD dwPitchDB,
505 DWORD dwPitchFB,
506 DWORD dwColor,
507 VOID *pPalette
508 )
509{
510 dprintf(("Fill32on8 NOT implemented\n"));
511 DebugInt3();
512}
513//*****************************************************************************
514//*****************************************************************************
515void CDECL Fill32on16( char *pDB,
516 char *pFB,
517 DWORD dwTop,
518 DWORD dwLeft,
519 DWORD dwWidth,
520 DWORD dwHeight,
521 DWORD dwPitchDB,
522 DWORD dwPitchFB,
523 DWORD dwColor,
524 VOID *pPalette
525 )
526{
527 DWORD dwCol;
528 dprintf(("Fill32on16\n"));
529
530 Fill32( pFB+(dwTop*dwPitchFB)+(dwLeft*4),
531 dwWidth,
532 dwHeight,
533 dwPitchFB,
534 dwColor);
535
536 dwCol = ((dwColor & 0xF8000000) >>16) +
537 ((dwColor & 0x00FE0000)>> 13) +
538 ((dwColor & 0x0000F800)>> 11);
539
540 dwCol = dwCol + (dwCol<<16);
541 Fill16( pDB+(dwTop*dwPitchDB)+(dwLeft*2),
542 dwWidth,
543 dwHeight,
544 dwPitchDB,
545 dwCol);
546}
547//*****************************************************************************
548//*****************************************************************************
549void CDECL Fill32on24( char *pDB,
550 char *pFB,
551 DWORD dwTop,
552 DWORD dwLeft,
553 DWORD dwWidth,
554 DWORD dwHeight,
555 DWORD dwPitchDB,
556 DWORD dwPitchFB,
557 DWORD dwColor,
558 VOID *pPalette
559 )
560{
561 dprintf(("Fill32on24\n"));
562 Fill32( pFB+(dwTop*dwPitchFB)+(dwLeft*4),
563 dwWidth,
564 dwHeight,
565 dwPitchFB,
566 dwColor);
567
568 Fill24( pDB+(dwTop*dwPitchDB)+(dwLeft*3),
569 dwWidth,
570 dwHeight,
571 dwPitchDB,
572 dwColor);
573}
574//*****************************************************************************
575//*****************************************************************************
576
Note: See TracBrowser for help on using the repository browser.