36cf853215a730d66cbaa727077da3f77c263931
2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 DIB_32BPP_PutPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
, ULONG c
)
28 PBYTE byteaddr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
;
29 PDWORD addr
= (PDWORD
)byteaddr
+ x
;
35 DIB_32BPP_GetPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
)
37 PBYTE byteaddr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
;
38 PDWORD addr
= (PDWORD
)byteaddr
+ x
;
40 return (ULONG
)(*addr
);
46 DIB_32BPP_HLine(SURFOBJ
*SurfObj
, LONG x1
, LONG x2
, LONG y
, ULONG c
)
49 PBYTE byteaddr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
;
50 PDWORD addr
= (PDWORD
)byteaddr
+ x1
;
52 __asm__
__volatile__ (
55 " test $0x03, %%edi\n" /* Align to fullword boundary */
57 " mov %1,%%ecx\n" /* Setup count of fullwords to fill */
58 " rep stosl\n" /* The actual fill */
63 " mov %1,%%ecx\n" /* Setup count of fullwords to fill */
65 " rep stosl\n" /* The actual fill */
70 : "r"(c
), "r"(cx
), "D"(addr
)
77 DIB_32BPP_HLine(SURFOBJ
*SurfObj
, LONG x1
, LONG x2
, LONG y
, ULONG c
)
79 PBYTE byteaddr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
;
80 PDWORD addr
= (PDWORD
)byteaddr
+ x1
;
92 DIB_32BPP_VLine(SURFOBJ
*SurfObj
, LONG x
, LONG y1
, LONG y2
, ULONG c
)
96 PBYTE byteaddr
= SurfObj
->pvScan0
+ y1
* SurfObj
->lDelta
;
97 PDWORD addr
= (PDWORD
)byteaddr
+ x
;
98 LONG lDelta
= SurfObj
->lDelta
>> 2; // >> 2 == / sizeof(DWORD)
100 byteaddr
= (PBYTE
)addr
;
110 DIB_32BPP_BitBltSrcCopy(PBLTINFO BltInfo
)
112 LONG i
, j
, sx
, sy
, xColor
, f1
;
113 PBYTE SourceBits
, DestBits
, SourceLine
, DestLine
;
114 PBYTE SourceBits_4BPP
, SourceLine_4BPP
;
115 PDWORD Source32
, Dest32
;
117 DestBits
= BltInfo
->DestSurface
->pvScan0
+ (BltInfo
->DestRect
.top
* BltInfo
->DestSurface
->lDelta
) + 4 * BltInfo
->DestRect
.left
;
119 switch(BltInfo
->SourceSurface
->iBitmapFormat
)
123 sx
= BltInfo
->SourcePoint
.x
;
124 sy
= BltInfo
->SourcePoint
.y
;
126 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
128 sx
= BltInfo
->SourcePoint
.x
;
129 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
131 if(DIB_1BPP_GetPixel(BltInfo
->SourceSurface
, sx
, sy
) == 0)
133 DIB_32BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, 0));
135 DIB_32BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, 1));
144 SourceBits_4BPP
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + (BltInfo
->SourcePoint
.x
>> 1);
146 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
148 SourceLine_4BPP
= SourceBits_4BPP
;
149 sx
= BltInfo
->SourcePoint
.x
;
152 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
154 xColor
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
,
155 (*SourceLine_4BPP
& altnotmask
[f1
]) >> (4 * (1 - f1
)));
156 DIB_32BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, xColor
);
157 if(f1
== 1) { SourceLine_4BPP
++; f1
= 0; } else { f1
= 1; }
161 SourceBits_4BPP
+= BltInfo
->SourceSurface
->lDelta
;
166 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + BltInfo
->SourcePoint
.x
;
169 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
171 SourceBits
= SourceLine
;
174 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
176 xColor
= *SourceBits
;
177 *((PDWORD
) DestBits
) = (DWORD
)XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, xColor
);
182 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
183 DestLine
+= BltInfo
->DestSurface
->lDelta
;
188 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 2 * BltInfo
->SourcePoint
.x
;
191 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
193 SourceBits
= SourceLine
;
196 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
198 xColor
= *((PWORD
) SourceBits
);
199 *((PDWORD
) DestBits
) = (DWORD
)XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, xColor
);
204 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
205 DestLine
+= BltInfo
->DestSurface
->lDelta
;
210 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 3 * BltInfo
->SourcePoint
.x
;
213 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
215 SourceBits
= SourceLine
;
218 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
220 xColor
= (*(SourceBits
+ 2) << 0x10) +
221 (*(SourceBits
+ 1) << 0x08) +
223 *((PDWORD
)DestBits
) = (DWORD
)XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, xColor
);
228 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
229 DestLine
+= BltInfo
->DestSurface
->lDelta
;
234 if (NULL
== BltInfo
->XlateSourceToDest
|| 0 != (BltInfo
->XlateSourceToDest
->flXlate
& XO_TRIVIAL
))
236 if (BltInfo
->DestRect
.top
< BltInfo
->SourcePoint
.y
)
238 SourceBits
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 4 * BltInfo
->SourcePoint
.x
;
239 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
241 RtlMoveMemory(DestBits
, SourceBits
, 4 * (BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
));
242 SourceBits
+= BltInfo
->SourceSurface
->lDelta
;
243 DestBits
+= BltInfo
->DestSurface
->lDelta
;
248 SourceBits
= BltInfo
->SourceSurface
->pvScan0
+ ((BltInfo
->SourcePoint
.y
+ BltInfo
->DestRect
.bottom
- BltInfo
->DestRect
.top
- 1) * BltInfo
->SourceSurface
->lDelta
) + 4 * BltInfo
->SourcePoint
.x
;
249 DestBits
= BltInfo
->DestSurface
->pvScan0
+ ((BltInfo
->DestRect
.bottom
- 1) * BltInfo
->DestSurface
->lDelta
) + 4 * BltInfo
->DestRect
.left
;
250 for (j
= BltInfo
->DestRect
.bottom
- 1; BltInfo
->DestRect
.top
<= j
; j
--)
252 RtlMoveMemory(DestBits
, SourceBits
, 4 * (BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
));
253 SourceBits
-= BltInfo
->SourceSurface
->lDelta
;
254 DestBits
-= BltInfo
->DestSurface
->lDelta
;
260 if (BltInfo
->DestRect
.top
< BltInfo
->SourcePoint
.y
)
262 SourceBits
= (BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 4 * BltInfo
->SourcePoint
.x
);
263 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
265 if (BltInfo
->DestRect
.left
< BltInfo
->SourcePoint
.x
)
267 Dest32
= (DWORD
*) DestBits
;
268 Source32
= (DWORD
*) SourceBits
;
269 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
271 *Dest32
++ = XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *Source32
++);
276 Dest32
= (DWORD
*) DestBits
+ (BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
- 1);
277 Source32
= (DWORD
*) SourceBits
+ (BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
- 1);
278 for (i
= BltInfo
->DestRect
.right
- 1; BltInfo
->DestRect
.left
<= i
; i
--)
280 *Dest32
-- = XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *Source32
--);
283 SourceBits
+= BltInfo
->SourceSurface
->lDelta
;
284 DestBits
+= BltInfo
->DestSurface
->lDelta
;
289 SourceBits
= BltInfo
->SourceSurface
->pvScan0
+ ((BltInfo
->SourcePoint
.y
+ BltInfo
->DestRect
.bottom
- BltInfo
->DestRect
.top
- 1) * BltInfo
->SourceSurface
->lDelta
) + 4 * BltInfo
->SourcePoint
.x
;
290 DestBits
= BltInfo
->DestSurface
->pvScan0
+ ((BltInfo
->DestRect
.bottom
- 1) * BltInfo
->DestSurface
->lDelta
) + 4 * BltInfo
->DestRect
.left
;
291 for (j
= BltInfo
->DestRect
.bottom
- 1; BltInfo
->DestRect
.top
<= j
; j
--)
293 if (BltInfo
->DestRect
.left
< BltInfo
->SourcePoint
.x
)
295 Dest32
= (DWORD
*) DestBits
;
296 Source32
= (DWORD
*) SourceBits
;
297 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
299 *Dest32
++ = XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *Source32
++);
304 Dest32
= (DWORD
*) DestBits
+ (BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
- 1);
305 Source32
= (DWORD
*) SourceBits
+ (BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
- 1);
306 for (i
= BltInfo
->DestRect
.right
; BltInfo
->DestRect
.left
< i
; i
--)
308 *Dest32
-- = XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *Source32
--);
311 SourceBits
-= BltInfo
->SourceSurface
->lDelta
;
312 DestBits
-= BltInfo
->DestSurface
->lDelta
;
319 DPRINT1("DIB_32BPP_Bitblt: Unhandled Source BPP: %u\n", BitsPerFormat(BltInfo
->SourceSurface
->iBitmapFormat
));
327 DIB_32BPP_BitBlt(PBLTINFO BltInfo
)
330 ULONG SourceX
, SourceY
;
331 ULONG PatternY
= 0, PatternX
= 0, orgPatternX
= 0;
332 ULONG Source
= 0, Pattern
= 0;
338 switch (BltInfo
->Rop4
)
341 return DIB_32DstInvert(BltInfo
);
345 return DIB32_SrcPaint(BltInfo
);
348 case ROP4_NOTSRCERASE
:
349 return DIB32_NotSrcErase(BltInfo
);
353 return DIB32_SrcErase(BltInfo
);
360 UsesSource
= ROP4_USES_SOURCE(BltInfo
->Rop4
);
361 UsesPattern
= ROP4_USES_PATTERN(BltInfo
->Rop4
);
363 SourceY
= BltInfo
->SourcePoint
.y
;
364 DestBits
= (PULONG
)(BltInfo
->DestSurface
->pvScan0
+ (BltInfo
->DestRect
.left
<< 2) +
365 BltInfo
->DestRect
.top
* BltInfo
->DestSurface
->lDelta
);
367 Delta
= BltInfo
->DestSurface
->lDelta
- ((BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
) << 2);
369 if ((UsesSource
) && (BltInfo
->PatternSurface
))
373 PatternY
= (BltInfo
->DestRect
.top
+ BltInfo
->BrushOrigin
.y
) %
374 BltInfo
->PatternSurface
->sizlBitmap
.cy
;
377 orgPatternX
= (BltInfo
->DestRect
.left
+ BltInfo
->BrushOrigin
.x
) % BltInfo
->PatternSurface
->sizlBitmap
.cx
;
380 for (DestY
= BltInfo
->DestRect
.top
; DestY
< BltInfo
->DestRect
.bottom
; DestY
++)
382 SourceX
= BltInfo
->SourcePoint
.x
;
384 PatternX
= orgPatternX
;
386 for (DestX
= BltInfo
->DestRect
.left
; DestX
< BltInfo
->DestRect
.right
; DestX
++, DestBits
++, SourceX
++)
389 Source
= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
, SourceY
, BltInfo
->XlateSourceToDest
);
391 Pattern
= DIB_GetSource(BltInfo
->PatternSurface
, PatternX
, PatternY
, BltInfo
->XlatePatternToDest
);
393 *DestBits
= DIB_DoRop(BltInfo
->Rop4
, *DestBits
, Source
, Pattern
);
396 PatternX
%= BltInfo
->PatternSurface
->sizlBitmap
.cx
;
403 PatternY
%= BltInfo
->PatternSurface
->sizlBitmap
.cy
;
405 DestBits
= (PULONG
)((ULONG_PTR
)DestBits
+ Delta
);
409 else if ((UsesSource
) && (!BltInfo
->PatternSurface
))
413 Pattern
= BltInfo
->Brush
->iSolidColor
;
416 for (DestY
= BltInfo
->DestRect
.top
; DestY
< BltInfo
->DestRect
.bottom
; DestY
++)
418 SourceX
= BltInfo
->SourcePoint
.x
;
420 for (DestX
= BltInfo
->DestRect
.left
; DestX
< BltInfo
->DestRect
.right
; DestX
++, DestBits
++, SourceX
++)
422 Source
= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
, SourceY
, BltInfo
->XlateSourceToDest
);
424 *DestBits
= DIB_DoRop(BltInfo
->Rop4
, *DestBits
, Source
, Pattern
);
428 DestBits
= (PULONG
)((ULONG_PTR
)DestBits
+ Delta
);
432 else if ((!UsesSource
) && (BltInfo
->PatternSurface
))
436 PatternY
= (BltInfo
->DestRect
.top
+ BltInfo
->BrushOrigin
.y
) %
437 BltInfo
->PatternSurface
->sizlBitmap
.cy
;
440 orgPatternX
= (BltInfo
->DestRect
.left
+ BltInfo
->BrushOrigin
.x
) % BltInfo
->PatternSurface
->sizlBitmap
.cx
;
442 for (DestY
= BltInfo
->DestRect
.top
; DestY
< BltInfo
->DestRect
.bottom
; DestY
++)
445 PatternX
= orgPatternX
;
447 for (DestX
= BltInfo
->DestRect
.left
; DestX
< BltInfo
->DestRect
.right
; DestX
++, DestBits
++)
450 Pattern
= DIB_GetSource(BltInfo
->PatternSurface
, PatternX
, PatternY
, BltInfo
->XlatePatternToDest
);
451 *DestBits
= DIB_DoRop(BltInfo
->Rop4
, *DestBits
, 0, Pattern
);
454 PatternX
%= BltInfo
->PatternSurface
->sizlBitmap
.cx
;
458 PatternY
%= BltInfo
->PatternSurface
->sizlBitmap
.cy
;
460 DestBits
= (PULONG
)((ULONG_PTR
)DestBits
+ Delta
);
463 else if ((!UsesSource
) && (!BltInfo
->PatternSurface
))
468 Pattern
= BltInfo
->Brush
->iSolidColor
;
471 for (DestY
= BltInfo
->DestRect
.top
; DestY
< BltInfo
->DestRect
.bottom
; DestY
++)
474 for (DestX
= BltInfo
->DestRect
.left
; DestX
< BltInfo
->DestRect
.right
; DestX
++, DestBits
++)
476 *DestBits
= DIB_DoRop(BltInfo
->Rop4
, *DestBits
, 0, Pattern
);
479 DestBits
= (PULONG
)((ULONG_PTR
)DestBits
+ Delta
);
487 /* Optimize functions for bitblt */
491 DIB_32DstInvert(PBLTINFO BltInfo
)
496 ULONG bottom
= BltInfo
->DestRect
.bottom
;
497 ULONG right
= BltInfo
->DestRect
.right
;
498 ULONG delta
= BltInfo
->DestSurface
->lDelta
- ((BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
) <<2) ;
500 DestBits
= (PULONG
)(BltInfo
->DestSurface
->pvScan0
+ (BltInfo
->DestRect
.left
<< 2) +
501 BltInfo
->DestRect
.top
* BltInfo
->DestSurface
->lDelta
);
503 for (DestY
= BltInfo
->DestRect
.top
; DestY
< bottom
; DestY
++)
505 for (DestX
= BltInfo
->DestRect
.left
; DestX
< right
; DestX
++, DestBits
++)
507 *DestBits
= ~*DestBits
;
510 DestBits
= (PULONG
)((ULONG_PTR
)DestBits
+ delta
);
520 DIB32_SrcErase(PBLTINFO BltInfo
)
522 BOOLEAN status
= FALSE
;
524 switch (BltInfo
->SourceSurface
->iBitmapFormat
)
533 ULONG SourceX
, SourceY
;
536 ULONG bottom
= BltInfo
->DestRect
.bottom
;
537 ULONG right
= BltInfo
->DestRect
.right
;
538 ULONG delta
= BltInfo
->DestSurface
->lDelta
- ((BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
) <<2) ;
540 DestBits
= (PULONG
)(BltInfo
->DestSurface
->pvScan0
+ (BltInfo
->DestRect
.left
<< 2) +
541 BltInfo
->DestRect
.top
* BltInfo
->DestSurface
->lDelta
);
543 SourceY
= BltInfo
->SourcePoint
.y
;
545 for (DestY
= BltInfo
->DestRect
.top
; DestY
< bottom
; DestY
++)
547 SourceX
= BltInfo
->SourcePoint
.x
;
548 for (DestX
= BltInfo
->DestRect
.left
; DestX
< right
; DestX
++, DestBits
++, SourceX
++)
550 *DestBits
= ~(*DestBits
& DIB_GetSource(BltInfo
->SourceSurface
, SourceX
,
551 SourceY
, BltInfo
->XlateSourceToDest
));
554 DestBits
= (PULONG
)((ULONG_PTR
)DestBits
+ delta
);
571 DIB32_NotSrcErase(PBLTINFO BltInfo
)
573 BOOLEAN status
= FALSE
;
575 switch (BltInfo
->SourceSurface
->iBitmapFormat
)
584 ULONG SourceX
, SourceY
;
587 ULONG bottom
= BltInfo
->DestRect
.bottom
;
588 ULONG right
= BltInfo
->DestRect
.right
;
589 ULONG delta
= BltInfo
->DestSurface
->lDelta
- ((BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
) <<2);
591 DestBits
= (PULONG
)(BltInfo
->DestSurface
->pvScan0
+ (BltInfo
->DestRect
.left
<< 2) +
592 BltInfo
->DestRect
.top
* BltInfo
->DestSurface
->lDelta
);
594 SourceY
= BltInfo
->SourcePoint
.y
;
596 for (DestY
= BltInfo
->DestRect
.top
; DestY
< bottom
; DestY
++)
598 SourceX
= BltInfo
->SourcePoint
.x
;
599 for (DestX
= BltInfo
->DestRect
.left
; DestX
< right
; DestX
++, DestBits
++, SourceX
++)
601 *DestBits
= ~(*DestBits
| DIB_GetSource(BltInfo
->SourceSurface
, SourceX
,
602 SourceY
, BltInfo
->XlateSourceToDest
));
605 DestBits
= (PULONG
)((ULONG_PTR
)DestBits
+ delta
);
622 DIB32_SrcPaint(PBLTINFO BltInfo
)
624 BOOLEAN status
= FALSE
;
626 switch (BltInfo
->SourceSurface
->iBitmapFormat
)
634 ULONG SourceX
, SourceY
;
637 ULONG bottom
= BltInfo
->DestRect
.bottom
;
638 ULONG right
= BltInfo
->DestRect
.right
;
639 ULONG delta
= BltInfo
->DestSurface
->lDelta
- ((BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
) <<2) ;
641 DestBits
= (PULONG
)(BltInfo
->DestSurface
->pvScan0
+ (BltInfo
->DestRect
.left
<< 2) +
642 BltInfo
->DestRect
.top
* BltInfo
->DestSurface
->lDelta
);
644 SourceY
= BltInfo
->SourcePoint
.y
;
646 for (DestY
= BltInfo
->DestRect
.top
; DestY
< bottom
; DestY
++)
648 SourceX
= BltInfo
->SourcePoint
.x
;
649 for (DestX
= BltInfo
->DestRect
.left
; DestX
< right
; DestX
++, DestBits
++, SourceX
++)
651 *DestBits
= (*DestBits
| DIB_GetSource(BltInfo
->SourceSurface
, SourceX
,
652 SourceY
, BltInfo
->XlateSourceToDest
));
655 DestBits
= (PULONG
)((ULONG_PTR
)DestBits
+ delta
);
666 ULONG SourceX
, SourceY
;
669 ULONG bottom
= BltInfo
->DestRect
.bottom
;
670 ULONG right
= BltInfo
->DestRect
.right
;
671 ULONG delta
= BltInfo
->DestSurface
->lDelta
- ((BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
) <<2) ;
673 DestBits
= (PULONG
)(BltInfo
->DestSurface
->pvScan0
+ (BltInfo
->DestRect
.left
<< 2) +
674 BltInfo
->DestRect
.top
* BltInfo
->DestSurface
->lDelta
);
676 SourceY
= BltInfo
->SourcePoint
.y
;
678 for (DestY
= BltInfo
->DestRect
.top
; DestY
< bottom
; DestY
++)
680 SourceX
= BltInfo
->SourcePoint
.x
;
681 for (DestX
= BltInfo
->DestRect
.left
; DestX
< right
; DestX
++, DestBits
++, SourceX
++)
683 *DestBits
= (*DestBits
| DIB_32BPP_GetPixel(BltInfo
->SourceSurface
, SourceX
, SourceY
));
686 DestBits
= (PULONG
)((ULONG_PTR
)DestBits
+ delta
);
702 DIB_32BPP_ColorFill(SURFOBJ
* DestSurface
, RECTL
* DestRect
, ULONG color
)
706 for (DestY
= DestRect
->top
; DestY
< DestRect
->bottom
; DestY
++)
708 DIB_32BPP_HLine (DestSurface
, DestRect
->left
, DestRect
->right
, DestY
, color
);
715 =======================================
716 Stretching functions goes below
717 Some parts of code are based on an
718 article "Bresenhame image scaling"
719 Dr. Dobb Journal, May 2002
720 =======================================
723 typedef unsigned long PIXEL
;
725 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
727 /* 32-bit Color (___ format) */
728 inline PIXEL
average32(PIXEL a
, PIXEL b
)
730 return a
; // FIXME: Temp hack to remove "PCB-effect" from the image
733 void ScaleLineAvg32(PIXEL
*Target
, PIXEL
*Source
, int SrcWidth
, int TgtWidth
)
735 int NumPixels
= TgtWidth
;
736 int IntPart
= SrcWidth
/ TgtWidth
;
737 int FractPart
= SrcWidth
% TgtWidth
;
738 int Mid
= TgtWidth
>> 1;
743 skip
= (TgtWidth
< SrcWidth
) ? 0 : (TgtWidth
/ (2*SrcWidth
) + 1);
746 while (NumPixels
-- > 0) {
749 p
= average32(p
, *(Source
+1));
763 FinalCopy32(PIXEL
*Target
, PIXEL
*Source
, PSPAN ClipSpans
, UINT ClipSpansCount
, UINT
*SpanIndex
,
764 UINT DestY
, RECTL
*DestRect
)
768 while (ClipSpans
[*SpanIndex
].Y
< DestY
769 || (ClipSpans
[*SpanIndex
].Y
== DestY
770 && ClipSpans
[*SpanIndex
].X
+ ClipSpans
[*SpanIndex
].Width
< DestRect
->left
))
773 if (ClipSpansCount
<= *SpanIndex
)
775 /* No more spans, everything else is clipped away, we're done */
779 while (ClipSpans
[*SpanIndex
].Y
== DestY
)
781 if (ClipSpans
[*SpanIndex
].X
< DestRect
->right
)
783 Left
= max(ClipSpans
[*SpanIndex
].X
, DestRect
->left
);
784 Right
= min(ClipSpans
[*SpanIndex
].X
+ ClipSpans
[*SpanIndex
].Width
, DestRect
->right
);
785 memcpy(Target
+ Left
- DestRect
->left
, Source
+ Left
- DestRect
->left
,
786 (Right
- Left
) * sizeof(PIXEL
));
789 if (ClipSpansCount
<= *SpanIndex
)
791 /* No more spans, everything else is clipped away, we're done */
799 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
800 BOOLEAN
ScaleRectAvg32(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
801 RECTL
* DestRect
, RECTL
*SourceRect
,
802 POINTL
* MaskOrigin
, POINTL BrushOrigin
,
803 CLIPOBJ
*ClipRegion
, XLATEOBJ
*ColorTranslation
,
806 int NumPixels
= DestRect
->bottom
- DestRect
->top
;
807 int IntPart
= (((SourceRect
->bottom
- SourceRect
->top
) / (DestRect
->bottom
- DestRect
->top
)) * SourceSurf
->lDelta
) / 4;
808 int FractPart
= (SourceRect
->bottom
- SourceRect
->top
) % (DestRect
->bottom
- DestRect
->top
);
809 int Mid
= (DestRect
->bottom
- DestRect
->top
) >> 1;
812 PIXEL
*ScanLine
, *ScanLineAhead
;
813 PIXEL
*PrevSource
= NULL
;
814 PIXEL
*PrevSourceAhead
= NULL
;
815 PIXEL
*Target
= (PIXEL
*) (DestSurf
->pvScan0
+ (DestRect
->top
* DestSurf
->lDelta
) + 4 * DestRect
->left
);
816 PIXEL
*Source
= (PIXEL
*) (SourceSurf
->pvScan0
+ (SourceRect
->top
* SourceSurf
->lDelta
) + 4 * SourceRect
->left
);
822 if (! ClipobjToSpans(&ClipSpans
, &ClipSpansCount
, ClipRegion
, DestRect
))
826 if (0 == ClipSpansCount
)
828 /* No clip spans == empty clipping region, everything clipped away */
829 ASSERT(NULL
== ClipSpans
);
832 skip
= (DestRect
->bottom
- DestRect
->top
< SourceRect
->bottom
- SourceRect
->top
) ? 0 : ((DestRect
->bottom
- DestRect
->top
) / (2 * (SourceRect
->bottom
- SourceRect
->top
)) + 1);
835 ScanLine
= (PIXEL
*)ExAllocatePool(PagedPool
, (DestRect
->right
- DestRect
->left
) * sizeof(PIXEL
));
836 ScanLineAhead
= (PIXEL
*)ExAllocatePool(PagedPool
, (DestRect
->right
- DestRect
->left
) * sizeof(PIXEL
));
838 DestY
= DestRect
->top
;
840 while (NumPixels
-- > 0) {
841 if (Source
!= PrevSource
) {
842 if (Source
== PrevSourceAhead
) {
843 /* the next scan line has already been scaled and stored in
844 * ScanLineAhead; swap the buffers that ScanLine and ScanLineAhead
847 PIXEL
*tmp
= ScanLine
;
848 ScanLine
= ScanLineAhead
;
851 ScaleLineAvg32(ScanLine
, Source
, SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
856 if (E
>= Mid
&& PrevSourceAhead
!= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
)) {
858 ScaleLineAvg32(ScanLineAhead
, (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
), SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
859 for (x
= 0; x
< DestRect
->right
- DestRect
->left
; x
++)
860 ScanLine
[x
] = average32(ScanLine
[x
], ScanLineAhead
[x
]);
861 PrevSourceAhead
= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
);
864 if (! FinalCopy32(Target
, ScanLine
, ClipSpans
, ClipSpansCount
, &SpanIndex
, DestY
, DestRect
))
866 /* No more spans, everything else is clipped away, we're done */
867 ExFreePool(ClipSpans
);
868 ExFreePool(ScanLine
);
869 ExFreePool(ScanLineAhead
);
873 Target
= (PIXEL
*)((BYTE
*)Target
+ DestSurf
->lDelta
);
876 if (E
>= DestRect
->bottom
- DestRect
->top
) {
877 E
-= DestRect
->bottom
- DestRect
->top
;
878 Source
= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
);
882 if (skip
> 0 && Source
!= PrevSource
)
883 ScaleLineAvg32(ScanLine
, Source
, SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
885 if (! FinalCopy32(Target
, ScanLine
, ClipSpans
, ClipSpansCount
, &SpanIndex
, DestY
, DestRect
))
887 /* No more spans, everything else is clipped away, we're done */
888 ExFreePool(ClipSpans
);
889 ExFreePool(ScanLine
);
890 ExFreePool(ScanLineAhead
);
894 Target
= (PIXEL
*)((BYTE
*)Target
+ DestSurf
->lDelta
);
897 ExFreePool(ClipSpans
);
898 ExFreePool(ScanLine
);
899 ExFreePool(ScanLineAhead
);
905 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
906 BOOLEAN
DIB_32BPP_StretchBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
907 RECTL
* DestRect
, RECTL
*SourceRect
,
908 POINTL
* MaskOrigin
, POINTL BrushOrigin
,
909 CLIPOBJ
*ClipRegion
, XLATEOBJ
*ColorTranslation
,
927 BOOLEAN DesIsBiggerY
=FALSE
;
929 DPRINT("DIB_32BPP_StretchBlt: Source BPP: %u, srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
930 BitsPerFormat(SourceSurf
->iBitmapFormat
), SourceRect
->left
, SourceRect
->top
, SourceRect
->right
,
931 SourceRect
->bottom
, DestRect
->left
, DestRect
->top
, DestRect
->right
, DestRect
->bottom
);
933 SrcSizeY
= SourceRect
->bottom
;
934 SrcSizeX
= SourceRect
->right
;
936 DesSizeY
= DestRect
->bottom
;
937 DesSizeX
= DestRect
->right
;
939 zoomX
= DesSizeX
/ SrcSizeX
;
940 if (zoomX
==0) zoomX
=1;
942 zoomY
= DesSizeY
/ SrcSizeY
;
943 if (zoomY
==0) zoomY
=1;
945 if (DesSizeY
>SrcSizeY
)
948 switch(SourceSurf
->iBitmapFormat
)
951 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
952 /* This is a reference implementation, it hasn't been optimized for speed */
955 /* Draw one Hline on X - Led to the Des Zoom In*/
956 if (DesSizeX
>SrcSizeX
)
958 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
961 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
963 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
965 if (sy
> SourceRect
->bottom
) break;
969 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
971 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
973 if (sx
> SourceRect
->right
) break;
975 saveX
= DesX
+ zoomX
;
977 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
978 for (count
=DesY
;count
<saveY
;count
++)
979 DIB_32BPP_HLine(DestSurf
, DesX
, saveX
, count
, 0);
981 for (count
=DesY
;count
<saveY
;count
++)
982 DIB_32BPP_HLine(DestSurf
, DesX
, saveX
, count
, 1);
989 /* Draw one Hline on X - Led to the Des Zoom Out*/
991 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
994 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
996 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
998 if (sy
> SourceRect
->bottom
) break;
1002 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1004 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1006 if (sx
> SourceRect
->right
) break;
1008 saveX
= DesX
+ zoomX
;
1010 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
1011 for (count
=DesY
;count
<saveY
;count
++)
1012 DIB_32BPP_HLine(DestSurf
, DesX
, saveX
, count
, 0);
1014 for (count
=DesY
;count
<saveY
;count
++)
1015 DIB_32BPP_HLine(DestSurf
, DesX
, saveX
, count
, 1);
1024 if (DesSizeX
>SrcSizeX
)
1026 /* Draw one pixel on X - Led to the Des Zoom In*/
1027 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1030 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1032 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1034 if (sy
> SourceRect
->bottom
) break;
1038 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1040 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1042 if (sx
> SourceRect
->right
) break;
1044 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
1045 for (count
=DesY
;count
<saveY
;count
++)
1046 DIB_32BPP_PutPixel(DestSurf
, DesX
, count
, 0);
1048 for (count
=DesY
;count
<saveY
;count
++)
1049 DIB_32BPP_PutPixel(DestSurf
, DesX
, count
, 1);
1057 /* Draw one pixel on X - Led to the Des Zoom Out*/
1058 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1061 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1063 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1065 if (sy
> SourceRect
->bottom
) break;
1069 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1071 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1073 if (sx
> SourceRect
->right
) break;
1075 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
1076 for (count
=DesY
;count
<saveY
;count
++)
1077 DIB_32BPP_PutPixel(DestSurf
, DesX
, count
, 0);
1079 for (count
=DesY
;count
<saveY
;count
++)
1080 DIB_32BPP_PutPixel(DestSurf
, DesX
, count
, 1);
1089 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
1090 /* This is a reference implementation, it hasn't been optimized for speed */
1093 /* Draw one Hline on X - Led to the Des Zoom In*/
1094 if (DesSizeX
>SrcSizeX
)
1096 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1099 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1101 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1103 if (sy
> SourceRect
->bottom
) break;
1107 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1109 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1111 if (sx
> SourceRect
->right
) break;
1113 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
1115 saveX
= DesX
+ zoomX
;
1116 for (count
=DesY
;count
<saveY
;count
++)
1117 DIB_32BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1123 /* Draw one Hline on X - Led to the Des Zoom Out*/
1125 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1128 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1130 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1132 if (sy
> SourceRect
->bottom
) break;
1136 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1138 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1140 if (sx
> SourceRect
->right
) break;
1142 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
1144 saveX
= DesX
+ zoomX
;
1145 for (count
=DesY
;count
<saveY
;count
++)
1146 DIB_32BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1155 if (DesSizeX
>SrcSizeX
)
1157 /* Draw one pixel on X - Led to the Des Zoom In*/
1158 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1161 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1163 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1165 if (sy
> SourceRect
->bottom
) break;
1169 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1171 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1173 if (sx
> SourceRect
->right
) break;
1175 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
1177 for (count
=DesY
;count
<saveY
;count
++)
1178 DIB_32BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1184 /* Draw one pixel on X - Led to the Des Zoom Out*/
1185 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1188 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1190 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1192 if (sy
> SourceRect
->bottom
) break;
1196 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1198 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1200 if (sx
> SourceRect
->right
) break;
1202 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
1204 for (count
=DesY
;count
<saveY
;count
++)
1205 DIB_32BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1213 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
1214 /* This is a reference implementation, it hasn't been optimized for speed */
1217 /* Draw one Hline on X - Led to the Des Zoom In*/
1218 if (DesSizeX
>SrcSizeX
)
1220 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1223 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1225 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1227 if (sy
> SourceRect
->bottom
) break;
1231 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1233 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1235 if (sx
> SourceRect
->right
) break;
1237 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
1239 saveX
= DesX
+ zoomX
;
1240 for (count
=DesY
;count
<saveY
;count
++)
1241 DIB_32BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1247 /* Draw one Hline on X - Led to the Des Zoom Out*/
1249 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1252 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1254 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1256 if (sy
> SourceRect
->bottom
) break;
1260 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1262 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1264 if (sx
> SourceRect
->right
) break;
1266 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
1268 saveX
= DesX
+ zoomX
;
1269 for (count
=DesY
;count
<saveY
;count
++)
1270 DIB_32BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1279 if (DesSizeX
>SrcSizeX
)
1281 /* Draw one pixel on X - Led to the Des Zoom In*/
1282 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1285 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1287 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1289 if (sy
> SourceRect
->bottom
) break;
1293 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1295 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1297 if (sx
> SourceRect
->right
) break;
1299 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
1301 for (count
=DesY
;count
<saveY
;count
++)
1302 DIB_32BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1308 /* Draw one pixel on X - Led to the Des Zoom Out*/
1309 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1312 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1314 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1316 if (sy
> SourceRect
->bottom
) break;
1320 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1322 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1324 if (sx
> SourceRect
->right
) break;
1326 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
1328 for (count
=DesY
;count
<saveY
;count
++)
1329 DIB_32BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1337 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
1338 /* This is a reference implementation, it hasn't been optimized for speed */
1341 /* Draw one Hline on X - Led to the Des Zoom In*/
1342 if (DesSizeX
>SrcSizeX
)
1344 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1347 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1349 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1351 if (sy
> SourceRect
->bottom
) break;
1355 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1357 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1359 if (sx
> SourceRect
->right
) break;
1361 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
1363 saveX
= DesX
+ zoomX
;
1364 for (count
=DesY
;count
<saveY
;count
++)
1365 DIB_32BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1371 /* Draw one Hline on X - Led to the Des Zoom Out*/
1373 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1376 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1378 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1380 if (sy
> SourceRect
->bottom
) break;
1384 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1386 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1388 if (sx
> SourceRect
->right
) break;
1390 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
1392 saveX
= DesX
+ zoomX
;
1393 for (count
=DesY
;count
<saveY
;count
++)
1394 DIB_32BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1403 if (DesSizeX
>SrcSizeX
)
1405 /* Draw one pixel on X - Led to the Des Zoom In*/
1406 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1409 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1411 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1413 if (sy
> SourceRect
->bottom
) break;
1417 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1419 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1421 if (sx
> SourceRect
->right
) break;
1423 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
1425 for (count
=DesY
;count
<saveY
;count
++)
1426 DIB_32BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1432 /* Draw one pixel on X - Led to the Des Zoom Out*/
1433 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1436 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1438 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1440 if (sy
> SourceRect
->bottom
) break;
1444 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1446 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1448 if (sx
> SourceRect
->right
) break;
1450 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
1452 for (count
=DesY
;count
<saveY
;count
++)
1453 DIB_32BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1461 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
1462 /* This is a reference implementation, it hasn't been optimized for speed */
1465 /* Draw one Hline on X - Led to the Des Zoom In*/
1466 if (DesSizeX
>SrcSizeX
)
1468 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1471 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1473 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1475 if (sy
> SourceRect
->bottom
) break;
1479 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1481 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1483 if (sx
> SourceRect
->right
) break;
1485 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1487 saveX
= DesX
+ zoomX
;
1488 for (count
=DesY
;count
<saveY
;count
++)
1489 DIB_32BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1495 /* Draw one Hline on X - Led to the Des Zoom Out*/
1497 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1500 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1502 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1504 if (sy
> SourceRect
->bottom
) break;
1508 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1510 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1512 if (sx
> SourceRect
->right
) break;
1514 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1516 saveX
= DesX
+ zoomX
;
1517 for (count
=DesY
;count
<saveY
;count
++)
1518 DIB_32BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1527 if (DesSizeX
>SrcSizeX
)
1529 /* Draw one pixel on X - Led to the Des Zoom In*/
1530 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1533 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1535 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1537 if (sy
> SourceRect
->bottom
) break;
1541 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1543 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1545 if (sx
> SourceRect
->right
) break;
1547 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1549 for (count
=DesY
;count
<saveY
;count
++)
1550 DIB_32BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1556 /* Draw one pixel on X - Led to the Des Zoom Out*/
1557 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1560 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1562 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1564 if (sy
> SourceRect
->bottom
) break;
1568 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1570 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1572 if (sx
> SourceRect
->right
) break;
1574 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1576 for (count
=DesY
;count
<saveY
;count
++)
1577 DIB_32BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1585 return ScaleRectAvg32(DestSurf
, SourceSurf
, DestRect
, SourceRect
, MaskOrigin
, BrushOrigin
,
1586 ClipRegion
, ColorTranslation
, Mode
);
1590 //DPRINT1("DIB_32BPP_StretchBlt: Unhandled Source BPP: %u\n", BitsPerFormat(SourceSurf->iBitmapFormat));
1600 DIB_32BPP_TransparentBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
1601 RECTL
* DestRect
, POINTL
*SourcePoint
,
1602 XLATEOBJ
*ColorTranslation
, ULONG iTransColor
)
1604 ULONG X
, Y
, SourceX
, SourceY
, Source
, wd
;
1607 SourceY
= SourcePoint
->y
;
1608 DestBits
= (ULONG
*)(DestSurf
->pvScan0
+
1609 (DestRect
->left
<< 2) +
1610 DestRect
->top
* DestSurf
->lDelta
);
1611 wd
= DestSurf
->lDelta
- ((DestRect
->right
- DestRect
->left
) << 2);
1613 for(Y
= DestRect
->top
; Y
< DestRect
->bottom
; Y
++)
1615 SourceX
= SourcePoint
->x
;
1616 for(X
= DestRect
->left
; X
< DestRect
->right
; X
++, DestBits
++, SourceX
++)
1618 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
, SourceY
);
1619 if(Source
!= iTransColor
)
1621 *DestBits
= XLATEOBJ_iXlate(ColorTranslation
, Source
);
1626 DestBits
= (ULONG
*)((ULONG_PTR
)DestBits
+ wd
);