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

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

Removed RGB555->565 conversion in Fill16on16 & SurfReleaseDC (problem located in GDI32)

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