2 * DIB Engine BitBlt Primitives
4 * Copyright 2009 Massimo Del Fedele
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/port.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(dibdrv
);
28 /* shrinks a line -- srcWidth >= dstWidth */
29 static void ShrinkLine(DWORD
*dst
, int dstWidth
, DWORD
*src
, int srcWidth
)
37 while(dstPos
< dstWidth
)
40 while(delta
< srcWidth
)
51 /* expands a line -- srcWidth <= dstWidth */
52 static void ExpandLine(DWORD
*dst
, int dstWidth
, DWORD
*src
, int srcWidth
)
59 while(srcPos
< srcWidth
)
61 while(delta
< dstWidth
)
73 static void StretchLine(DWORD
*dst
, int dstWidth
, DWORD
*src
, int srcWidth
)
75 if(srcWidth
> dstWidth
)
76 ShrinkLine(dst
, dstWidth
, src
, srcWidth
);
77 else if(srcWidth
< dstWidth
)
78 ExpandLine(dst
, dstWidth
, src
, srcWidth
);
80 memcpy(dst
, src
, 4 * srcWidth
);
83 /* ------------------------------------------------------------*/
84 /* BLITTING PRIMITIVES */
85 BOOL
_DIBDRV_BitBlt_generic(DIBDRVPHYSDEV
*physDevDst
, INT xDst
, INT yDst
,
86 INT width
, INT height
, const DIBDRVPHYSDEV
*physDevSrc
,
87 INT xSrc
, INT ySrc
, DWORD rop
)
92 DIBDRVBITMAP
*dstBmp
, *patBmp
;
93 const DIBDRVBITMAP
*srcBmp
;
94 DWORD
*wDstPnt
, *wSrcPnt
, *wPatPnt
;
95 BOOL usePat
, useSrc
, useDst
;
99 /* 32 bit RGB source and destination buffer, if needed */
100 DWORD
*sBuf
= 0, *dBuf
= 0, *pBuf
= 0;
102 /* get elements usage */
103 usePat
= (((rop
>> 4) & 0x0f0000) != (rop
& 0x0f0000));
104 useSrc
= (((rop
>> 2) & 0x330000) != (rop
& 0x330000));
105 useDst
= (((rop
>> 1) & 0x550000) != (rop
& 0x550000));
107 /* gets source, dest and pattern bitmaps, if available */
108 if(usePat
&& physDevDst
->isBrushBitmap
)
109 patBmp
= &physDevDst
->brushBmpCache
;
114 srcBmp
= &physDevSrc
->physBitmap
;
117 dstBmp
= &physDevDst
->physBitmap
;
119 /* gets pattern color, in case it's needed */
121 patColor
= physDevDst
->brushColor
;
125 /* allocate 32 bit RGB destination buffer */
126 if(!(dBuf
= (DWORD
*)HeapAlloc( GetProcessHeap(), 0, width
* 4)))
129 MAYBE(TRACE("dstBmp:%p(%s), xDst:%d, yDst:%d, width:%d, height:%d, srcBmp:%p(%s), xSrc:%d, ySrc:%d, rop:%8x\n",
130 dstBmp
, _DIBDRVBITMAP_GetFormatName(dstBmp
), xDst
, yDst
, width
, height
,
131 srcBmp
, _DIBDRVBITMAP_GetFormatName(srcBmp
), xSrc
, ySrc
, rop
));
133 /* some simple ROPs optimizations */
137 MAYBE(TRACE("BLACKNESS\n"));
138 memset(dBuf
, 0x00, width
* 4);
139 for(yd
= yDst
; yd
< yDst
+height
; yd
++)
140 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, width
, dBuf
);
144 MAYBE(TRACE("WHITENESS\n"));
145 for(dwBuf
= dBuf
, i
= width
; i
; i
--)
146 *dwBuf
++ = 0x00ffffff;
147 for(yd
= yDst
; yd
< yDst
+height
; yd
++)
148 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, width
, dBuf
);
152 MAYBE(TRACE("SRCCOPY\n"));
153 for(ys
= ySrc
, yd
= yDst
; ys
< ySrc
+height
; ys
++, yd
++)
155 srcBmp
->funcs
->GetLine(srcBmp
, ys
, xSrc
, width
, dBuf
);
156 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, width
, dBuf
);
160 /* fallback for generic ROP operation */
163 if(useSrc
&& useDst
&& usePat
&& physDevDst
->isBrushBitmap
)
165 MAYBE(TRACE("BitBlt use: src+dst+pat - pattern brush\n"));
166 if(!(sBuf
= HeapAlloc( GetProcessHeap(), 0, width
* 4)))
168 if(!(pBuf
= HeapAlloc( GetProcessHeap(), 0, width
* 4)))
170 for(ys
= ySrc
, yd
= yDst
; ys
< ySrc
+height
; ys
++, yd
++)
172 srcBmp
->funcs
->GetLine(srcBmp
, ys
, xSrc
, width
, sBuf
);
173 dstBmp
->funcs
->GetLine(dstBmp
, ys
, xDst
, width
, dBuf
);
174 patBmp
->funcs
->GetLine(patBmp
, ys
%patBmp
->height
, 0, width
, pBuf
);
178 for(i
= width
; i
> 0 ; i
--)
180 *wDstPnt
= _DIBDRV_ROP3(*wPatPnt
++, *wSrcPnt
++, *wDstPnt
, rop
);
183 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, width
, dBuf
);
186 else if(useSrc
&& useDst
)
189 MAYBE(TRACE("BitBlt use: src+dst+pat - solid brush\n"));
191 MAYBE(TRACE("BitBlt use: src+dst\n"));
192 if(!(sBuf
= HeapAlloc( GetProcessHeap(), 0, width
* 4)))
194 for(ys
= ySrc
, yd
= yDst
; ys
< ySrc
+height
; ys
++, yd
++)
196 srcBmp
->funcs
->GetLine(srcBmp
, ys
, xSrc
, width
, sBuf
);
197 dstBmp
->funcs
->GetLine(dstBmp
, yd
, xDst
, width
, dBuf
);
200 for(i
= width
; i
> 0 ; i
--)
202 *wDstPnt
= _DIBDRV_ROP3(patColor
, *wSrcPnt
++, *wDstPnt
, rop
);
205 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, width
, dBuf
);
208 else if(useSrc
&& usePat
&& physDevDst
->isBrushBitmap
)
210 MAYBE(TRACE("BitBlt use: src+pat -- pattern brush\n"));
211 if(!(pBuf
= HeapAlloc( GetProcessHeap(), 0, width
* 4)))
213 for(ys
= ySrc
, yd
= yDst
; ys
< ySrc
+height
; ys
++, yd
++)
215 srcBmp
->funcs
->GetLine(srcBmp
, ys
, xSrc
, width
, dBuf
);
216 patBmp
->funcs
->GetLine(patBmp
, ys
%patBmp
->height
, 0, width
, pBuf
);
220 for(i
= width
; i
> 0 ; i
--)
222 *wDstPnt
= _DIBDRV_ROP3(*wPatPnt
++, *wSrcPnt
++, 0, rop
);
225 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, width
, dBuf
);
231 MAYBE(TRACE("BitBlt use: src+pat - solid brush\n"));
233 MAYBE(TRACE("BitBlt use: src\n"));
234 for(ys
= ySrc
, yd
= yDst
; ys
< ySrc
+height
; ys
++, yd
++)
236 srcBmp
->funcs
->GetLine(srcBmp
, ys
, xSrc
, width
, dBuf
);
239 for(i
= width
; i
> 0 ; i
--)
241 *wDstPnt
= _DIBDRV_ROP3(patColor
, *wSrcPnt
++, 0, rop
);
244 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, width
, dBuf
);
247 else if(useDst
&& usePat
&& physDevDst
->isBrushBitmap
)
249 MAYBE(TRACE("BitBlt use: dst+pat -- pattern brush\n"));
250 if(!(pBuf
= HeapAlloc( GetProcessHeap(), 0, width
* 4)))
252 for(ys
= ySrc
, yd
= yDst
; ys
< ySrc
+height
; ys
++, yd
++)
254 dstBmp
->funcs
->GetLine(srcBmp
, ys
, xDst
, width
, dBuf
);
255 patBmp
->funcs
->GetLine(patBmp
, ys
%patBmp
->height
, 0, width
, pBuf
);
258 for(i
= width
; i
> 0 ; i
--)
260 *wDstPnt
= _DIBDRV_ROP3(*wPatPnt
++, 0, *wDstPnt
, rop
);
263 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, width
, dBuf
);
269 MAYBE(TRACE("BitBlt use: dst+pat - solid brush\n"));
271 MAYBE(TRACE("BitBlt use: dst\n"));
272 for(ys
= ySrc
, yd
= yDst
; ys
< ySrc
+height
; ys
++, yd
++)
274 dstBmp
->funcs
->GetLine(srcBmp
, ys
, xDst
, width
, dBuf
);
276 for(i
= width
; i
> 0 ; i
--)
278 *wDstPnt
= _DIBDRV_ROP3(patColor
, 0, *wDstPnt
, rop
);
281 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, width
, dBuf
);
284 else if(usePat
&& physDevDst
->isBrushBitmap
)
286 MAYBE(TRACE("BitBlt use: pat -- pattern brush\n"));
287 if(!(pBuf
= HeapAlloc( GetProcessHeap(), 0, width
* 4)))
289 for(ys
= ySrc
, yd
= yDst
; ys
< ySrc
+height
; ys
++, yd
++)
291 patBmp
->funcs
->GetLine(patBmp
, ys
%patBmp
->height
, 0, width
, pBuf
);
294 for(i
= width
; i
> 0 ; i
--)
296 *wDstPnt
= _DIBDRV_ROP3(*wPatPnt
++, 0, 0, rop
);
299 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, width
, dBuf
);
304 MAYBE(TRACE("BitBlt use: pat -- solid brush -- rop is %02x, color is %08x\n", rop
, patColor
));
305 MAYBE(TRACE("Dest BMP is a '%s'\n", _DIBDRVBITMAP_GetFormatName(dstBmp
)));
306 MAYBE(TRACE("xDst = %d, yDst = %d, width = %d, height = %d\n", xDst
, yDst
, width
, height
));
307 for(yd
= yDst
; yd
< yDst
+height
; yd
++)
310 for(i
= width
; i
> 0 ; i
--)
312 *wDstPnt
= _DIBDRV_ROP3(patColor
, 0, 0, rop
);
315 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, width
, dBuf
);
319 ERR("What happened ?????? \n");
324 if(sBuf
) HeapFree( GetProcessHeap(), 0, sBuf
);
325 if(dBuf
) HeapFree( GetProcessHeap(), 0, dBuf
);
326 if(pBuf
) HeapFree( GetProcessHeap(), 0, pBuf
);
330 /* ------------------------------------------------------------*/
331 /* STRETCHING PRIMITIVES */
332 BOOL
_DIBDRV_StretchBlt_generic(DIBDRVPHYSDEV
*physDevDst
, INT xDst
, INT yDst
,
333 INT widthDst
, INT heightDst
, const DIBDRVPHYSDEV
*physDevSrc
,
334 INT xSrc
, INT ySrc
, int widthSrc
, int heightSrc
, DWORD rop
)
339 DIBDRVBITMAP
*dstBmp
, *patBmp
;
340 const DIBDRVBITMAP
*srcBmp
;
341 DWORD
*wDstPnt
, *wSrcPnt
, *wPatPnt
;
342 BOOL usePat
, useSrc
, useDst
;
346 /* 32 bit RGB source and destination buffer, if needed */
347 DWORD
*sBufOrig
= 0, *sBufStr
= 0, *dBuf
= 0, *pBuf
= 0;
349 /* get elements usage */
350 usePat
= (((rop
>> 4) & 0x0f0000) != (rop
& 0x0f0000));
351 useSrc
= (((rop
>> 2) & 0x330000) != (rop
& 0x330000));
352 useDst
= (((rop
>> 1) & 0x550000) != (rop
& 0x550000));
354 /* gets source, dest and pattern bitmaps, if available */
355 if(usePat
&& physDevDst
->isBrushBitmap
)
356 patBmp
= &physDevDst
->brushBmpCache
;
361 srcBmp
= &physDevSrc
->physBitmap
;
364 dstBmp
= &physDevDst
->physBitmap
;
366 /* gets pattern color, in case it's needed */
368 patColor
= physDevDst
->brushColor
;
372 /* allocate 32 bit RGB destination buffer */
373 if(!(dBuf
= (DWORD
*)HeapAlloc( GetProcessHeap(), 0, widthDst
* 4)))
376 MAYBE(TRACE("dstBmp:%p(%s), xDst:%d, yDst:%d, widthDst:%d, heightDst:%d, srcBmp:%p(%s), xSrc:%d, ySrc:%d, , widthSrc:%d, heightSrc:%drop:%8x\n",
377 dstBmp
, _DIBDRVBITMAP_GetFormatName(dstBmp
), xDst
, yDst
, widthDst
, heightDst
,
378 srcBmp
, _DIBDRVBITMAP_GetFormatName(srcBmp
), xSrc
, ySrc
, widthSrc
, heightSrc
, rop
));
380 /* some simple ROPs optimizations */
384 MAYBE(TRACE("BLACKNESS\n"));
385 memset(dBuf
, 0x00, widthDst
* 4);
386 for(yd
= yDst
; yd
< yDst
+heightDst
; yd
++)
387 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, widthDst
, dBuf
);
391 MAYBE(TRACE("WHITENESS\n"));
392 for(dwBuf
= dBuf
, i
= widthDst
; i
; i
--)
393 *dwBuf
++ = 0x00ffffff;
394 for(yd
= yDst
; yd
< yDst
+heightDst
; yd
++)
395 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, widthDst
, dBuf
);
399 MAYBE(TRACE("SRCCOPY\n"));
400 sBufOrig
= HeapAlloc(GetProcessHeap(), 0, widthSrc
* 4);
401 if(heightSrc
> heightDst
)
406 while(yd
< heightDst
)
408 srcBmp
->funcs
->GetLine(srcBmp
, ys
+ ySrc
, xSrc
, widthSrc
, sBufOrig
);
409 StretchLine(dBuf
, widthDst
, sBufOrig
, widthSrc
);
410 dstBmp
->funcs
->PutLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
411 while(delta
< heightSrc
)
420 else if(heightSrc
< heightDst
)
425 while(ys
< heightSrc
)
427 srcBmp
->funcs
->GetLine(srcBmp
, ys
+ ySrc
, xSrc
, widthSrc
, sBufOrig
);
428 StretchLine(dBuf
, widthDst
, sBufOrig
, widthSrc
);
429 while(delta
< heightDst
)
431 dstBmp
->funcs
->PutLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
441 for(ys
= ySrc
, yd
= yDst
; ys
< ySrc
+heightSrc
; ys
++, yd
++)
443 srcBmp
->funcs
->GetLine(srcBmp
, ys
, xSrc
, widthSrc
, sBufOrig
);
444 StretchLine(dBuf
, widthDst
, sBufOrig
, widthSrc
);
445 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, widthDst
, dBuf
);
450 /* fallback for generic ROP operation */
453 if(useSrc
&& useDst
&& usePat
&& physDevDst
->isBrushBitmap
)
455 MAYBE(TRACE("StretchBlt use: src+dst+pat - pattern brush\n"));
456 if(!(sBufOrig
= HeapAlloc(GetProcessHeap(), 0, widthSrc
* 4)))
458 if(!(sBufStr
= HeapAlloc(GetProcessHeap(), 0, widthDst
* 4)))
460 if(!(pBuf
= HeapAlloc( GetProcessHeap(), 0, widthDst
* 4)))
462 if(heightSrc
> heightDst
)
467 while(yd
< heightDst
)
469 srcBmp
->funcs
->GetLine(srcBmp
, ys
+ ySrc
, xSrc
, widthSrc
, sBufOrig
);
470 StretchLine(sBufStr
, widthDst
, sBufOrig
, widthSrc
);
471 dstBmp
->funcs
->GetLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
472 patBmp
->funcs
->GetLine(patBmp
, (yd
+ yDst
)%patBmp
->height
, 0, widthDst
, pBuf
);
476 for(i
= widthDst
; i
> 0 ; i
--)
478 *wDstPnt
= _DIBDRV_ROP3(*wPatPnt
++, *wSrcPnt
++, *wDstPnt
, rop
);
481 dstBmp
->funcs
->PutLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
482 while(delta
< heightSrc
)
491 else if(heightSrc
< heightDst
)
496 while(ys
< heightSrc
)
498 srcBmp
->funcs
->GetLine(srcBmp
, ys
+ ySrc
, xSrc
, widthSrc
, sBufOrig
);
499 StretchLine(sBufStr
, widthDst
, sBufOrig
, widthSrc
);
500 dstBmp
->funcs
->GetLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
501 patBmp
->funcs
->GetLine(patBmp
, (yd
+ yDst
)%patBmp
->height
, 0, widthDst
, pBuf
);
502 while(delta
< heightDst
)
507 for(i
= widthDst
; i
> 0 ; i
--)
509 *wDstPnt
= _DIBDRV_ROP3(*wPatPnt
++, *wSrcPnt
++, *wDstPnt
, rop
);
512 dstBmp
->funcs
->PutLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
522 for(ys
= ySrc
, yd
= yDst
; ys
< ySrc
+heightSrc
; ys
++, yd
++)
524 srcBmp
->funcs
->GetLine(srcBmp
, ys
, xSrc
, widthSrc
, sBufOrig
);
525 StretchLine(sBufStr
, widthDst
, sBufOrig
, widthSrc
);
526 dstBmp
->funcs
->GetLine(dstBmp
, ys
, xDst
, widthDst
, dBuf
);
527 patBmp
->funcs
->GetLine(patBmp
, ys
%patBmp
->height
, 0, widthDst
, pBuf
);
531 for(i
= widthDst
; i
> 0 ; i
--)
533 *wDstPnt
= _DIBDRV_ROP3(*wPatPnt
++, *wSrcPnt
++, *wDstPnt
, rop
);
536 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, widthDst
, dBuf
);
540 else if(useSrc
&& useDst
)
543 MAYBE(TRACE("StretchBlt use: src+dst+pat - solid brush\n"));
545 MAYBE(TRACE("StretchBlt use: src+dst\n"));
546 if(!(sBufOrig
= HeapAlloc(GetProcessHeap(), 0, widthSrc
* 4)))
548 if(!(sBufStr
= HeapAlloc(GetProcessHeap(), 0, widthDst
* 4)))
550 if(heightSrc
> heightDst
)
555 while(yd
< heightDst
)
557 srcBmp
->funcs
->GetLine(srcBmp
, ys
+ ySrc
, xSrc
, widthSrc
, sBufOrig
);
558 StretchLine(sBufStr
, widthDst
, sBufOrig
, widthSrc
);
559 dstBmp
->funcs
->GetLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
562 for(i
= widthDst
; i
> 0 ; i
--)
564 *wDstPnt
= _DIBDRV_ROP3(patColor
, *wSrcPnt
++, *wDstPnt
, rop
);
567 dstBmp
->funcs
->PutLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
568 while(delta
< heightSrc
)
577 else if(heightSrc
< heightDst
)
582 while(ys
< heightSrc
)
584 srcBmp
->funcs
->GetLine(srcBmp
, ys
+ ySrc
, xSrc
, widthSrc
, sBufOrig
);
585 StretchLine(sBufStr
, widthDst
, sBufOrig
, widthSrc
);
586 dstBmp
->funcs
->GetLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
587 while(delta
< heightDst
)
591 for(i
= widthDst
; i
> 0 ; i
--)
593 *wDstPnt
= _DIBDRV_ROP3(patColor
, *wSrcPnt
++, *wDstPnt
, rop
);
596 dstBmp
->funcs
->PutLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
606 for(ys
= ySrc
, yd
= yDst
; ys
< ySrc
+heightSrc
; ys
++, yd
++)
608 srcBmp
->funcs
->GetLine(srcBmp
, ys
, xSrc
, widthSrc
, sBufOrig
);
609 StretchLine(sBufStr
, widthDst
, sBufOrig
, widthSrc
);
610 dstBmp
->funcs
->GetLine(dstBmp
, ys
, xDst
, widthDst
, dBuf
);
613 for(i
= widthDst
; i
> 0 ; i
--)
615 *wDstPnt
= _DIBDRV_ROP3(patColor
, *wSrcPnt
++, *wDstPnt
, rop
);
618 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, widthDst
, dBuf
);
622 else if(useSrc
&& usePat
&& physDevDst
->isBrushBitmap
)
624 MAYBE(TRACE("StretchBlt use: src+pat -- pattern brush\n"));
625 if(!(sBufOrig
= HeapAlloc(GetProcessHeap(), 0, widthSrc
* 4)))
627 if(!(sBufStr
= HeapAlloc(GetProcessHeap(), 0, widthDst
* 4)))
629 if(!(pBuf
= HeapAlloc( GetProcessHeap(), 0, widthDst
* 4)))
631 if(heightSrc
> heightDst
)
636 while(yd
< heightDst
)
638 srcBmp
->funcs
->GetLine(srcBmp
, ys
+ ySrc
, xSrc
, widthSrc
, sBufOrig
);
639 StretchLine(sBufStr
, widthDst
, sBufOrig
, widthSrc
);
640 patBmp
->funcs
->GetLine(patBmp
, (yd
+ yDst
)%patBmp
->height
, 0, widthDst
, pBuf
);
644 for(i
= widthDst
; i
> 0 ; i
--)
646 *wDstPnt
= _DIBDRV_ROP3(*wPatPnt
++, *wSrcPnt
++, 0, rop
);
649 dstBmp
->funcs
->PutLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
650 while(delta
< heightSrc
)
659 else if(heightSrc
< heightDst
)
664 while(ys
< heightSrc
)
666 srcBmp
->funcs
->GetLine(srcBmp
, ys
+ ySrc
, xSrc
, widthSrc
, sBufOrig
);
667 StretchLine(sBufStr
, widthDst
, sBufOrig
, widthSrc
);
668 patBmp
->funcs
->GetLine(patBmp
, (yd
+ yDst
)%patBmp
->height
, 0, widthDst
, pBuf
);
669 while(delta
< heightDst
)
674 for(i
= widthDst
; i
> 0 ; i
--)
676 *wDstPnt
= _DIBDRV_ROP3(*wPatPnt
++, *wSrcPnt
++, 0, rop
);
679 dstBmp
->funcs
->PutLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
689 for(ys
= ySrc
, yd
= yDst
; ys
< ySrc
+heightSrc
; ys
++, yd
++)
691 srcBmp
->funcs
->GetLine(srcBmp
, ys
, xSrc
, widthSrc
, sBufOrig
);
692 StretchLine(sBufStr
, widthDst
, sBufOrig
, widthSrc
);
693 patBmp
->funcs
->GetLine(patBmp
, ys
%patBmp
->height
, 0, widthDst
, pBuf
);
697 for(i
= widthDst
; i
> 0 ; i
--)
699 *wDstPnt
= _DIBDRV_ROP3(*wPatPnt
++, *wSrcPnt
++, 0, rop
);
702 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, widthDst
, dBuf
);
709 MAYBE(TRACE("StretchBlt use: src+pat - solid brush\n"));
711 MAYBE(TRACE("StretchBlt use: src\n"));
712 if(!(sBufOrig
= HeapAlloc(GetProcessHeap(), 0, widthSrc
* 4)))
714 if(!(sBufStr
= HeapAlloc(GetProcessHeap(), 0, widthDst
* 4)))
716 if(heightSrc
> heightDst
)
721 while(yd
< heightDst
)
723 srcBmp
->funcs
->GetLine(srcBmp
, ys
+ ySrc
, xSrc
, widthSrc
, sBufOrig
);
724 StretchLine(sBufStr
, widthDst
, sBufOrig
, widthSrc
);
727 for(i
= widthDst
; i
> 0 ; i
--)
729 *wDstPnt
= _DIBDRV_ROP3(patColor
, *wSrcPnt
++, 0, rop
);
732 dstBmp
->funcs
->PutLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
733 while(delta
< heightSrc
)
742 else if(heightSrc
< heightDst
)
747 while(ys
< heightSrc
)
749 srcBmp
->funcs
->GetLine(srcBmp
, ys
+ ySrc
, xSrc
, widthSrc
, sBufOrig
);
750 StretchLine(sBufStr
, widthDst
, sBufOrig
, widthSrc
);
751 while(delta
< heightDst
)
755 for(i
= widthDst
; i
> 0 ; i
--)
757 *wDstPnt
= _DIBDRV_ROP3(patColor
, *wSrcPnt
++, 0, rop
);
760 dstBmp
->funcs
->PutLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
770 for(ys
= ySrc
, yd
= yDst
; ys
< ySrc
+heightSrc
; ys
++, yd
++)
772 srcBmp
->funcs
->GetLine(srcBmp
, ys
, xSrc
, widthSrc
, sBufOrig
);
773 StretchLine(sBufStr
, widthDst
, sBufOrig
, widthSrc
);
776 for(i
= widthDst
; i
> 0 ; i
--)
778 *wDstPnt
= _DIBDRV_ROP3(patColor
, *wSrcPnt
++, 0, rop
);
781 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, widthDst
, dBuf
);
785 else if(useDst
&& usePat
&& physDevDst
->isBrushBitmap
)
787 MAYBE(TRACE("StretchBlt use: dst+pat -- pattern brush\n"));
788 if(!(pBuf
= HeapAlloc( GetProcessHeap(), 0, widthDst
* 4)))
790 if(heightSrc
> heightDst
)
795 while(yd
< heightDst
)
797 dstBmp
->funcs
->GetLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
798 patBmp
->funcs
->GetLine(patBmp
, (yd
+ yDst
)%patBmp
->height
, 0, widthDst
, pBuf
);
801 for(i
= widthDst
; i
> 0 ; i
--)
803 *wDstPnt
= _DIBDRV_ROP3(*wPatPnt
++, 0, *wDstPnt
, rop
);
806 dstBmp
->funcs
->PutLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
807 while(delta
< heightSrc
)
816 else if(heightSrc
< heightDst
)
821 while(ys
< heightSrc
)
823 dstBmp
->funcs
->GetLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
824 patBmp
->funcs
->GetLine(patBmp
, (yd
+ yDst
)%patBmp
->height
, 0, widthDst
, pBuf
);
825 while(delta
< heightDst
)
829 for(i
= widthDst
; i
> 0 ; i
--)
831 *wDstPnt
= _DIBDRV_ROP3(*wPatPnt
++, 0, *wDstPnt
, rop
);
834 dstBmp
->funcs
->PutLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
844 for(ys
= ySrc
, yd
= yDst
; ys
< ySrc
+heightSrc
; ys
++, yd
++)
846 dstBmp
->funcs
->GetLine(dstBmp
, ys
, xDst
, widthDst
, dBuf
);
847 patBmp
->funcs
->GetLine(patBmp
, ys
%patBmp
->height
, 0, widthDst
, pBuf
);
850 for(i
= widthDst
; i
> 0 ; i
--)
852 *wDstPnt
= _DIBDRV_ROP3(*wPatPnt
++, 0, *wDstPnt
, rop
);
855 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, widthDst
, dBuf
);
862 MAYBE(TRACE("StretchBlt use: dst+pat - solid brush\n"));
864 MAYBE(TRACE("StretchBlt use: dst\n"));
865 if(heightSrc
> heightDst
)
870 while(yd
< heightDst
)
872 dstBmp
->funcs
->GetLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
874 for(i
= widthDst
; i
> 0 ; i
--)
876 *wDstPnt
= _DIBDRV_ROP3(patColor
, 0, *wDstPnt
, rop
);
879 dstBmp
->funcs
->PutLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
880 while(delta
< heightSrc
)
889 else if(heightSrc
< heightDst
)
894 while(ys
< heightSrc
)
896 dstBmp
->funcs
->GetLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
897 while(delta
< heightDst
)
900 for(i
= widthDst
; i
> 0 ; i
--)
902 *wDstPnt
= _DIBDRV_ROP3(patColor
, 0, *wDstPnt
, rop
);
905 dstBmp
->funcs
->PutLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
915 for(ys
= ySrc
, yd
= yDst
; ys
< ySrc
+heightSrc
; ys
++, yd
++)
917 dstBmp
->funcs
->GetLine(dstBmp
, ys
, xDst
, widthDst
, dBuf
);
919 for(i
= widthDst
; i
> 0 ; i
--)
921 *wDstPnt
= _DIBDRV_ROP3(patColor
, 0, *wDstPnt
, rop
);
924 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, widthDst
, dBuf
);
928 else if(usePat
&& physDevDst
->isBrushBitmap
)
930 MAYBE(TRACE("StretchBlt use: pat -- pattern brush\n"));
931 if(!(pBuf
= HeapAlloc( GetProcessHeap(), 0, widthDst
* 4)))
933 if(heightSrc
> heightDst
)
938 while(yd
< heightDst
)
940 patBmp
->funcs
->GetLine(patBmp
, (yd
+ yDst
)%patBmp
->height
, 0, widthDst
, pBuf
);
943 for(i
= widthDst
; i
> 0 ; i
--)
945 *wDstPnt
= _DIBDRV_ROP3(*wPatPnt
++, 0, 0, rop
);
948 dstBmp
->funcs
->PutLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
949 while(delta
< heightSrc
)
958 else if(heightSrc
< heightDst
)
963 while(ys
< heightSrc
)
965 patBmp
->funcs
->GetLine(patBmp
, (yd
+ yDst
)%patBmp
->height
, 0, widthDst
, pBuf
);
966 while(delta
< heightDst
)
970 for(i
= widthDst
; i
> 0 ; i
--)
972 *wDstPnt
= _DIBDRV_ROP3(*wPatPnt
++, 0, 0, rop
);
975 dstBmp
->funcs
->PutLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
985 for(ys
= ySrc
, yd
= yDst
; ys
< ySrc
+heightSrc
; ys
++, yd
++)
987 patBmp
->funcs
->GetLine(patBmp
, ys
%patBmp
->height
, 0, widthDst
, pBuf
);
990 for(i
= widthDst
; i
> 0 ; i
--)
992 *wDstPnt
= _DIBDRV_ROP3(*wPatPnt
++, 0, 0, rop
);
995 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, widthDst
, dBuf
);
1001 MAYBE(TRACE("StretchBlt use: pat -- solid brush -- rop is %02x, color is %08x\n", rop
, patColor
));
1002 MAYBE(TRACE("Dest BMP is a '%s'\n", _DIBDRVBITMAP_GetFormatName(dstBmp
)));
1003 MAYBE(TRACE("xDst = %d, yDst = %d, widthDst = %d, heightDst = %d\n", xDst
, yDst
, widthDst
, heightDst
));
1004 if(heightSrc
> heightDst
)
1009 while(yd
< heightDst
)
1012 for(i
= widthDst
; i
> 0 ; i
--)
1014 *wDstPnt
= _DIBDRV_ROP3(patColor
, 0, 0, rop
);
1017 dstBmp
->funcs
->PutLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
1018 while(delta
< heightSrc
)
1027 else if(heightSrc
< heightDst
)
1032 while(ys
< heightSrc
)
1034 while(delta
< heightDst
)
1037 for(i
= widthDst
; i
> 0 ; i
--)
1039 *wDstPnt
= _DIBDRV_ROP3(patColor
, 0, 0, rop
);
1042 dstBmp
->funcs
->PutLine(dstBmp
, yd
+ yDst
, xDst
, widthDst
, dBuf
);
1052 for(ys
= ySrc
, yd
= yDst
; ys
< ySrc
+heightSrc
; ys
++, yd
++)
1055 for(i
= widthDst
; i
> 0 ; i
--)
1057 *wDstPnt
= _DIBDRV_ROP3(patColor
, 0, 0, rop
);
1060 dstBmp
->funcs
->PutLine(dstBmp
, yd
, xDst
, widthDst
, dBuf
);
1065 ERR("What happened ?????? \n");
1070 if(sBufOrig
) HeapFree( GetProcessHeap(), 0, sBufOrig
);
1071 if(sBufStr
) HeapFree( GetProcessHeap(), 0, sBufStr
);
1072 if(dBuf
) HeapFree( GetProcessHeap(), 0, dBuf
);
1073 if(pBuf
) HeapFree( GetProcessHeap(), 0, pBuf
);