2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: GDI BitBlt Functions
5 * FILE: subsys/win32k/eng/bitblt.c
6 * PROGRAMER: Jason Filby
17 typedef BOOLEAN (APIENTRY
*PBLTRECTFUNC
)(SURFOBJ
* OutputObj
,
20 XLATEOBJ
* ColorTranslation
,
28 static BOOLEAN APIENTRY
29 BltMask(SURFOBJ
* psoDest
,
30 SURFOBJ
* psoSource
, // unused
32 XLATEOBJ
* ColorTranslation
, // unused
34 POINTL
* pptlSource
, // unused
41 BYTE
*pjMskLine
, *pjMskCurrent
;
42 BYTE fjMaskBit0
, fjMaskBit
;
44 PEBRUSHOBJ pebo
= NULL
;
45 SURFOBJ
*psoPattern
= NULL
;
46 PSURFACE psurfPattern
;
47 ULONG PatternWidth
= 0, PatternHeight
= 0;
48 LONG PatternX0
= 0, PatternX
= 0, PatternY
= 0;
49 PFN_DIB_PutPixel fnDest_PutPixel
= NULL
;
50 PFN_DIB_GetPixel fnPattern_GetPixel
= NULL
;
54 ASSERT(psoSource
== NULL
);
55 ASSERT(pptlSource
== NULL
);
62 if (pbo
&& pbo
->iSolidColor
== 0xFFFFFFFF)
64 pebo
= CONTAINING_RECORD(pbo
, EBRUSHOBJ
, BrushObject
);
66 hbmPattern
= EBRUSHOBJ_pvGetEngBrush(pebo
);
67 psurfPattern
= SURFACE_LockSurface(hbmPattern
);
68 if (psurfPattern
!= NULL
)
70 psoPattern
= &psurfPattern
->SurfObj
;
71 PatternWidth
= psoPattern
->sizlBitmap
.cx
;
72 PatternHeight
= psoPattern
->sizlBitmap
.cy
;
73 fnPattern_GetPixel
= DibFunctionsForBitmapFormat
[psoPattern
->iBitmapFormat
].DIB_GetPixel
;
79 pjMskLine
= (PBYTE
)psoMask
->pvScan0
+ pptlMask
->y
* psoMask
->lDelta
+ (pptlMask
->x
>> 3);
80 fjMaskBit0
= 0x80 >> (pptlMask
->x
& 0x07);
82 fnDest_PutPixel
= DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_PutPixel
;
85 PatternY
= (prclDest
->top
- pptlBrush
->y
) % PatternHeight
;
88 PatternY
+= PatternHeight
;
90 PatternX0
= (prclDest
->left
- pptlBrush
->x
) % PatternWidth
;
93 PatternX0
+= PatternWidth
;
96 for (y
= prclDest
->top
; y
< prclDest
->bottom
; y
++)
98 pjMskCurrent
= pjMskLine
;
99 fjMaskBit
= fjMaskBit0
;
100 PatternX
= PatternX0
;
102 for (x
= prclDest
->left
; x
< prclDest
->right
; x
++)
104 if (*pjMskCurrent
& fjMaskBit
)
106 fnDest_PutPixel(psoDest
, x
, y
,
107 fnPattern_GetPixel(psoPattern
, PatternX
, PatternY
));
109 fjMaskBit
= _rotr8(fjMaskBit
, 1);
110 pjMskCurrent
+= (fjMaskBit
>> 7);
112 PatternX
%= PatternWidth
;
114 pjMskLine
+= psoMask
->lDelta
;
116 PatternY
%= PatternHeight
;
121 Pattern
= pbo
? pbo
->iSolidColor
: 0;
122 for (y
= prclDest
->top
; y
< prclDest
->bottom
; y
++)
124 pjMskCurrent
= pjMskLine
;
125 fjMaskBit
= fjMaskBit0
;
127 for (x
= prclDest
->left
; x
< prclDest
->right
; x
++)
129 if (*pjMskCurrent
& fjMaskBit
)
131 fnDest_PutPixel(psoDest
, x
, y
, Pattern
);
133 fjMaskBit
= _rotr8(fjMaskBit
, 1);
134 pjMskCurrent
+= (fjMaskBit
>> 7);
136 pjMskLine
+= psoMask
->lDelta
;
141 SURFACE_UnlockSurface(psurfPattern
);
146 static BOOLEAN APIENTRY
147 BltPatCopy(SURFOBJ
* Dest
,
150 XLATEOBJ
* ColorTranslation
,
158 // These functions are assigned if we're working with a DIB
159 // The assigned functions depend on the bitsPerPixel of the DIB
161 DibFunctionsForBitmapFormat
[Dest
->iBitmapFormat
].DIB_ColorFill(Dest
, DestRect
, pbo
? pbo
->iSolidColor
: 0);
166 static BOOLEAN APIENTRY
167 CallDibBitBlt(SURFOBJ
* OutputObj
,
170 XLATEOBJ
* ColorTranslation
,
179 PEBRUSHOBJ GdiBrush
= NULL
;
180 SURFACE
*psurfPattern
;
184 BltInfo
.DestSurface
= OutputObj
;
185 BltInfo
.SourceSurface
= InputObj
;
186 BltInfo
.PatternSurface
= NULL
;
187 BltInfo
.XlateSourceToDest
= ColorTranslation
;
188 BltInfo
.DestRect
= *OutputRect
;
189 BltInfo
.SourcePoint
= *InputPoint
;
191 if (ROP3_TO_ROP4(SRCCOPY
) == Rop4
)
192 return DibFunctionsForBitmapFormat
[OutputObj
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
);
195 BltInfo
.BrushOrigin
= *BrushOrigin
;
199 if (ROP4_USES_PATTERN(Rop4
) && pbo
&& pbo
->iSolidColor
== 0xFFFFFFFF)
201 GdiBrush
= CONTAINING_RECORD(pbo
, EBRUSHOBJ
, BrushObject
);
202 hbmPattern
= EBRUSHOBJ_pvGetEngBrush(GdiBrush
);
203 psurfPattern
= SURFACE_LockSurface(hbmPattern
);
206 BltInfo
.PatternSurface
= &psurfPattern
->SurfObj
;
210 /* FIXME - What to do here? */
218 Result
= DibFunctionsForBitmapFormat
[OutputObj
->iBitmapFormat
].DIB_BitBlt(&BltInfo
);
223 SURFACE_UnlockSurface(psurfPattern
);
229 INT __cdecl
abs(INT nm
);
246 IN POINTL
*pptlBrush
,
256 ProbeForRead(prclTrg
, sizeof(RECTL
), 1);
257 RtlCopyMemory(&rclTrg
,prclTrg
, sizeof(RECTL
));
259 ProbeForRead(pptlSrc
, sizeof(POINTL
), 1);
260 RtlCopyMemory(&ptlSrc
, pptlSrc
, sizeof(POINTL
));
262 ProbeForRead(pptlMask
, sizeof(POINTL
), 1);
263 RtlCopyMemory(&ptlMask
, pptlMask
, sizeof(POINTL
));
265 ProbeForRead(pptlBrush
, sizeof(POINTL
), 1);
266 RtlCopyMemory(&ptlBrush
, pptlBrush
, sizeof(POINTL
));
269 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
271 _SEH2_YIELD(return FALSE
);
275 return EngBitBlt(psoTrg
, psoSrc
, psoMask
, pco
, pxlo
, &rclTrg
, &ptlSrc
, &ptlMask
, pbo
, &ptlBrush
, rop4
);
282 EngBitBlt(SURFOBJ
*DestObj
,
286 XLATEOBJ
*ColorTranslation
,
301 SURFOBJ
* InputObj
= 0;
303 PBLTRECTFUNC BltRectFunc
;
310 POINTL AdjustedBrushOrigin
;
312 UsesSource
= ROP4_USES_SOURCE(rop4
);
315 /* Copy destination onto itself: nop */
319 OutputRect
= *DestRect
;
320 if (OutputRect
.right
< OutputRect
.left
)
322 OutputRect
.left
= DestRect
->right
;
323 OutputRect
.right
= DestRect
->left
;
325 if (OutputRect
.bottom
< OutputRect
.top
)
327 OutputRect
.left
= DestRect
->right
;
328 OutputRect
.right
= DestRect
->left
;
333 if (NULL
== SourcePoint
)
338 /* Make sure we don't try to copy anything outside the valid source
340 InputPoint
= *SourcePoint
;
341 if (InputPoint
.x
< 0)
343 OutputRect
.left
-= InputPoint
.x
;
346 if (InputPoint
.y
< 0)
348 OutputRect
.top
-= InputPoint
.y
;
351 if (SourceObj
->sizlBitmap
.cx
< InputPoint
.x
+
352 OutputRect
.right
- OutputRect
.left
)
354 OutputRect
.right
= OutputRect
.left
+
355 SourceObj
->sizlBitmap
.cx
- InputPoint
.x
;
357 if (SourceObj
->sizlBitmap
.cy
< InputPoint
.y
+
358 OutputRect
.bottom
- OutputRect
.top
)
360 OutputRect
.bottom
= OutputRect
.top
+
361 SourceObj
->sizlBitmap
.cy
- InputPoint
.y
;
364 InputRect
.left
= InputPoint
.x
;
365 InputRect
.right
= InputPoint
.x
+ (OutputRect
.right
- OutputRect
.left
);
366 InputRect
.top
= InputPoint
.y
;
367 InputRect
.bottom
= InputPoint
.y
+ (OutputRect
.bottom
- OutputRect
.top
);
369 InputObj
= SourceObj
;
374 InputRect
.right
= DestRect
->right
- DestRect
->left
;
376 InputRect
.bottom
= DestRect
->bottom
- DestRect
->top
;
379 if (NULL
!= ClipRegion
)
381 if (OutputRect
.left
< ClipRegion
->rclBounds
.left
)
383 InputRect
.left
+= ClipRegion
->rclBounds
.left
- OutputRect
.left
;
384 InputPoint
.x
+= ClipRegion
->rclBounds
.left
- OutputRect
.left
;
385 OutputRect
.left
= ClipRegion
->rclBounds
.left
;
387 if (ClipRegion
->rclBounds
.right
< OutputRect
.right
)
389 InputRect
.right
-= OutputRect
.right
- ClipRegion
->rclBounds
.right
;
390 OutputRect
.right
= ClipRegion
->rclBounds
.right
;
392 if (OutputRect
.top
< ClipRegion
->rclBounds
.top
)
394 InputRect
.top
+= ClipRegion
->rclBounds
.top
- OutputRect
.top
;
395 InputPoint
.y
+= ClipRegion
->rclBounds
.top
- OutputRect
.top
;
396 OutputRect
.top
= ClipRegion
->rclBounds
.top
;
398 if (ClipRegion
->rclBounds
.bottom
< OutputRect
.bottom
)
400 InputRect
.bottom
-= OutputRect
.bottom
- ClipRegion
->rclBounds
.bottom
;
401 OutputRect
.bottom
= ClipRegion
->rclBounds
.bottom
;
405 /* Check for degenerate case: if height or width of OutputRect is 0 pixels
406 there's nothing to do */
407 if (OutputRect
.right
<= OutputRect
.left
||
408 OutputRect
.bottom
<= OutputRect
.top
)
417 AdjustedBrushOrigin
.x
= BrushOrigin
->x
;
418 AdjustedBrushOrigin
.y
= BrushOrigin
->y
;
422 AdjustedBrushOrigin
.x
= 0;
423 AdjustedBrushOrigin
.y
= 0;
426 /* Determine clipping type */
427 if (ClipRegion
== (CLIPOBJ
*) NULL
)
429 clippingType
= DC_TRIVIAL
;
433 clippingType
= ClipRegion
->iDComplexity
;
438 BltRectFunc
= BltMask
;
440 else if (ROP3_TO_ROP4(PATCOPY
) == rop4
)
442 if (pbo
&& pbo
->iSolidColor
== 0xFFFFFFFF)
443 BltRectFunc
= CallDibBitBlt
;
445 BltRectFunc
= BltPatCopy
;
449 BltRectFunc
= CallDibBitBlt
;
453 switch (clippingType
)
456 Ret
= (*BltRectFunc
)(OutputObj
, InputObj
, Mask
, ColorTranslation
,
457 &OutputRect
, &InputPoint
, MaskOrigin
, pbo
,
458 &AdjustedBrushOrigin
, rop4
);
461 /* Clip the blt to the clip rectangle */
462 ClipRect
.left
= ClipRegion
->rclBounds
.left
;
463 ClipRect
.right
= ClipRegion
->rclBounds
.right
;
464 ClipRect
.top
= ClipRegion
->rclBounds
.top
;
465 ClipRect
.bottom
= ClipRegion
->rclBounds
.bottom
;
466 if (RECTL_bIntersectRect(&CombinedRect
, &OutputRect
, &ClipRect
))
468 Pt
.x
= InputPoint
.x
+ CombinedRect
.left
- OutputRect
.left
;
469 Pt
.y
= InputPoint
.y
+ CombinedRect
.top
- OutputRect
.top
;
470 Ret
= (*BltRectFunc
)(OutputObj
, InputObj
, Mask
, ColorTranslation
,
471 &CombinedRect
, &Pt
, MaskOrigin
, pbo
,
472 &AdjustedBrushOrigin
, rop4
);
477 if (OutputObj
== InputObj
)
479 if (OutputRect
.top
< InputPoint
.y
)
481 Direction
= OutputRect
.left
< InputPoint
.x
?
482 CD_RIGHTDOWN
: CD_LEFTDOWN
;
486 Direction
= OutputRect
.left
< InputPoint
.x
?
487 CD_RIGHTUP
: CD_LEFTUP
;
494 CLIPOBJ_cEnumStart(ClipRegion
, FALSE
, CT_RECTANGLES
, Direction
, 0);
497 EnumMore
= CLIPOBJ_bEnum(ClipRegion
,(ULONG
) sizeof(RectEnum
),
500 for (i
= 0; i
< RectEnum
.c
; i
++)
502 ClipRect
.left
= RectEnum
.arcl
[i
].left
;
503 ClipRect
.right
= RectEnum
.arcl
[i
].right
;
504 ClipRect
.top
= RectEnum
.arcl
[i
].top
;
505 ClipRect
.bottom
= RectEnum
.arcl
[i
].bottom
;
506 if (RECTL_bIntersectRect(&CombinedRect
, &OutputRect
, &ClipRect
))
508 Pt
.x
= InputPoint
.x
+ CombinedRect
.left
- OutputRect
.left
;
509 Pt
.y
= InputPoint
.y
+ CombinedRect
.top
- OutputRect
.top
;
510 Ret
= (*BltRectFunc
)(OutputObj
, InputObj
, Mask
,
511 ColorTranslation
, &CombinedRect
, &Pt
,
512 MaskOrigin
, pbo
, &AdjustedBrushOrigin
,
539 SURFACE
*psurfSrc
= NULL
;
543 // INTENG_ENTER_LEAVE EnterLeaveSource;
544 // INTENG_ENTER_LEAVE EnterLeaveDest;
545 PFN_DrvBitBlt pfnBitBlt
;
548 psurfTrg
= CONTAINING_RECORD(psoTrg
, SURFACE
, SurfObj
);
550 /* FIXME: Should we really allow to pass non-well-ordered rects? */
551 rclClipped
= *prclTrg
;
552 RECTL_vMakeWellOrdered(&rclClipped
);
554 /* Clip target rect against the bounds of the clipping region */
557 if (!RECTL_bIntersectRect(&rclClipped
, &rclClipped
, &pco
->rclBounds
))
563 /* Don't pass a clipobj with only a single rect */
564 if (pco
->iDComplexity
== DC_RECT
)
568 if (ROP4_USES_SOURCE(rop4
))
571 psurfSrc
= CONTAINING_RECORD(psoSrc
, SURFACE
, SurfObj
);
573 /* Calculate source rect */
574 rclSrc
.left
= pptlSrc
->x
+ rclClipped
.left
- prclTrg
->left
;
575 rclSrc
.top
= pptlSrc
->y
+ rclClipped
.top
- prclTrg
->top
;
576 rclSrc
.right
= rclSrc
.left
+ rclClipped
.right
- rclClipped
.left
;
577 rclSrc
.bottom
= rclSrc
.top
+ rclClipped
.bottom
- rclClipped
.top
;
585 /* Is the target surface device managed? */
586 if (psurfTrg
->flags
& HOOK_BITBLT
)
588 /* Is the source a different device managed surface? */
589 if (psoSrc
&& psoSrc
->hdev
!= psoTrg
->hdev
&& psurfSrc
->flags
& HOOK_BITBLT
)
591 DPRINT1("Need to copy to standard bitmap format!\n");
595 pfnBitBlt
= GDIDEVFUNCS(psoTrg
).BitBlt
;
598 /* Is the source surface device managed? */
599 else if (psoSrc
&& psurfSrc
->flags
& HOOK_BITBLT
)
601 pfnBitBlt
= GDIDEVFUNCS(psoSrc
).BitBlt
;
605 pfnBitBlt
= EngBitBlt
;
608 bResult
= pfnBitBlt(psoTrg
,
620 // FIXME: cleanup temp surface!
626 /**** REACTOS FONT RENDERING CODE *********************************************/
628 /* renders the alpha mask bitmap */
629 static BOOLEAN APIENTRY
630 AlphaBltMask(SURFOBJ
* psoDest
,
631 SURFOBJ
* psoSource
, // unused
633 XLATEOBJ
* pxloRGB2Dest
,
636 POINTL
* pptlSource
, // unused
643 ULONG Background
, BrushColor
, NewColor
;
646 ASSERT(psoSource
== NULL
);
647 ASSERT(pptlSource
== NULL
);
649 dx
= prclDest
->right
- prclDest
->left
;
650 dy
= prclDest
->bottom
- prclDest
->top
;
654 BrushColor
= XLATEOBJ_iXlate(pxloBrush
, pbo
? pbo
->iSolidColor
: 0);
655 r
= (int)GetRValue(BrushColor
);
656 g
= (int)GetGValue(BrushColor
);
657 b
= (int)GetBValue(BrushColor
);
659 tMask
= (PBYTE
)psoMask
->pvScan0
+ (pptlMask
->y
* psoMask
->lDelta
) + pptlMask
->x
;
660 for (j
= 0; j
< dy
; j
++)
663 for (i
= 0; i
< dx
; i
++)
669 DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_PutPixel(
670 psoDest
, prclDest
->left
+ i
, prclDest
->top
+ j
, pbo
? pbo
->iSolidColor
: 0);
674 Background
= DIB_GetSource(psoDest
, prclDest
->left
+ i
, prclDest
->top
+ j
,
678 RGB((*lMask
* (r
- GetRValue(Background
)) >> 8) + GetRValue(Background
),
679 (*lMask
* (g
- GetGValue(Background
)) >> 8) + GetGValue(Background
),
680 (*lMask
* (b
- GetBValue(Background
)) >> 8) + GetBValue(Background
));
682 Background
= XLATEOBJ_iXlate(pxloRGB2Dest
, NewColor
);
683 DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_PutPixel(
684 psoDest
, prclDest
->left
+ i
, prclDest
->top
+ j
, Background
);
689 tMask
+= psoMask
->lDelta
;
701 EngMaskBitBlt(SURFOBJ
*psoDest
,
704 XLATEOBJ
*DestColorTranslation
,
705 XLATEOBJ
*SourceColorTranslation
,
719 INTENG_ENTER_LEAVE EnterLeaveSource
;
720 INTENG_ENTER_LEAVE EnterLeaveDest
;
728 POINTL AdjustedBrushOrigin
;
734 InputRect
.left
= pptlMask
->x
;
735 InputRect
.right
= pptlMask
->x
+ (DestRect
->right
- DestRect
->left
);
736 InputRect
.top
= pptlMask
->y
;
737 InputRect
.bottom
= pptlMask
->y
+ (DestRect
->bottom
- DestRect
->top
);
742 InputRect
.right
= DestRect
->right
- DestRect
->left
;
744 InputRect
.bottom
= DestRect
->bottom
- DestRect
->top
;
747 OutputRect
= *DestRect
;
748 if (NULL
!= ClipRegion
)
750 if (OutputRect
.left
< ClipRegion
->rclBounds
.left
)
752 InputRect
.left
+= ClipRegion
->rclBounds
.left
- OutputRect
.left
;
753 OutputRect
.left
= ClipRegion
->rclBounds
.left
;
755 if (ClipRegion
->rclBounds
.right
< OutputRect
.right
)
757 InputRect
.right
-= OutputRect
.right
- ClipRegion
->rclBounds
.right
;
758 OutputRect
.right
= ClipRegion
->rclBounds
.right
;
760 if (OutputRect
.top
< ClipRegion
->rclBounds
.top
)
762 InputRect
.top
+= ClipRegion
->rclBounds
.top
- OutputRect
.top
;
763 OutputRect
.top
= ClipRegion
->rclBounds
.top
;
765 if (ClipRegion
->rclBounds
.bottom
< OutputRect
.bottom
)
767 InputRect
.bottom
-= OutputRect
.bottom
- ClipRegion
->rclBounds
.bottom
;
768 OutputRect
.bottom
= ClipRegion
->rclBounds
.bottom
;
772 if (! IntEngEnter(&EnterLeaveSource
, psoMask
, &InputRect
, TRUE
, &Translate
, &psoInput
))
777 InputPoint
.x
= InputRect
.left
+ Translate
.x
;
778 InputPoint
.y
= InputRect
.top
+ Translate
.y
;
780 /* Check for degenerate case: if height or width of OutputRect is 0 pixels there's
782 if (OutputRect
.right
<= OutputRect
.left
|| OutputRect
.bottom
<= OutputRect
.top
)
784 IntEngLeave(&EnterLeaveSource
);
788 if (! IntEngEnter(&EnterLeaveDest
, psoDest
, &OutputRect
, FALSE
, &Translate
, &psoOutput
))
790 IntEngLeave(&EnterLeaveSource
);
794 OutputRect
.left
= DestRect
->left
+ Translate
.x
;
795 OutputRect
.right
= DestRect
->right
+ Translate
.x
;
796 OutputRect
.top
= DestRect
->top
+ Translate
.y
;
797 OutputRect
.bottom
= DestRect
->bottom
+ Translate
.y
;
801 AdjustedBrushOrigin
.x
= BrushOrigin
->x
+ Translate
.x
;
802 AdjustedBrushOrigin
.y
= BrushOrigin
->y
+ Translate
.y
;
805 AdjustedBrushOrigin
= Translate
;
807 // Determine clipping type
808 if (ClipRegion
== (CLIPOBJ
*) NULL
)
810 clippingType
= DC_TRIVIAL
;
812 clippingType
= ClipRegion
->iDComplexity
;
815 switch (clippingType
)
818 if (psoMask
->iBitmapFormat
== BMF_8BPP
)
819 Ret
= AlphaBltMask(psoOutput
, NULL
, psoInput
, DestColorTranslation
, SourceColorTranslation
,
820 &OutputRect
, NULL
, &InputPoint
, pbo
, &AdjustedBrushOrigin
);
822 Ret
= BltMask(psoOutput
, NULL
, psoInput
, DestColorTranslation
,
823 &OutputRect
, NULL
, &InputPoint
, pbo
, &AdjustedBrushOrigin
,
827 // Clip the blt to the clip rectangle
828 ClipRect
.left
= ClipRegion
->rclBounds
.left
+ Translate
.x
;
829 ClipRect
.right
= ClipRegion
->rclBounds
.right
+ Translate
.x
;
830 ClipRect
.top
= ClipRegion
->rclBounds
.top
+ Translate
.y
;
831 ClipRect
.bottom
= ClipRegion
->rclBounds
.bottom
+ Translate
.y
;
832 if (RECTL_bIntersectRect(&CombinedRect
, &OutputRect
, &ClipRect
))
834 Pt
.x
= InputPoint
.x
+ CombinedRect
.left
- OutputRect
.left
;
835 Pt
.y
= InputPoint
.y
+ CombinedRect
.top
- OutputRect
.top
;
836 if (psoMask
->iBitmapFormat
== BMF_8BPP
)
838 Ret
= AlphaBltMask(psoOutput
, NULL
, psoInput
, DestColorTranslation
, SourceColorTranslation
,
839 &CombinedRect
, NULL
, &Pt
, pbo
, &AdjustedBrushOrigin
);
843 Ret
= BltMask(psoOutput
, NULL
, psoInput
, DestColorTranslation
,
844 &CombinedRect
, NULL
, &Pt
, pbo
, &AdjustedBrushOrigin
, R4_MASK
);
850 if (psoOutput
== psoInput
)
852 if (OutputRect
.top
< InputPoint
.y
)
854 Direction
= OutputRect
.left
< InputPoint
.x
? CD_RIGHTDOWN
: CD_LEFTDOWN
;
858 Direction
= OutputRect
.left
< InputPoint
.x
? CD_RIGHTUP
: CD_LEFTUP
;
865 CLIPOBJ_cEnumStart(ClipRegion
, FALSE
, CT_RECTANGLES
, Direction
, 0);
868 EnumMore
= CLIPOBJ_bEnum(ClipRegion
,(ULONG
) sizeof(RectEnum
), (PVOID
) &RectEnum
);
870 for (i
= 0; i
< RectEnum
.c
; i
++)
872 ClipRect
.left
= RectEnum
.arcl
[i
].left
+ Translate
.x
;
873 ClipRect
.right
= RectEnum
.arcl
[i
].right
+ Translate
.x
;
874 ClipRect
.top
= RectEnum
.arcl
[i
].top
+ Translate
.y
;
875 ClipRect
.bottom
= RectEnum
.arcl
[i
].bottom
+ Translate
.y
;
876 if (RECTL_bIntersectRect(&CombinedRect
, &OutputRect
, &ClipRect
))
878 Pt
.x
= InputPoint
.x
+ CombinedRect
.left
- OutputRect
.left
;
879 Pt
.y
= InputPoint
.y
+ CombinedRect
.top
- OutputRect
.top
;
880 if (psoMask
->iBitmapFormat
== BMF_8BPP
)
882 Ret
= AlphaBltMask(psoOutput
, NULL
, psoInput
,
883 DestColorTranslation
,
884 SourceColorTranslation
,
885 &CombinedRect
, NULL
, &Pt
, pbo
,
886 &AdjustedBrushOrigin
) && Ret
;
890 Ret
= BltMask(psoOutput
, NULL
, psoInput
,
891 DestColorTranslation
, &CombinedRect
, NULL
,
892 &Pt
, pbo
, &AdjustedBrushOrigin
,
903 IntEngLeave(&EnterLeaveDest
);
904 IntEngLeave(&EnterLeaveSource
);
910 IntEngMaskBlt(SURFOBJ
*psoDest
,
913 XLATEOBJ
*DestColorTranslation
,
914 XLATEOBJ
*SourceColorTranslation
,
929 InputPoint
= *pptlMask
;
932 /* Clip against the bounds of the clipping region so we won't try to write
933 * outside the surface */
934 if (NULL
!= ClipRegion
)
936 if (!RECTL_bIntersectRect(&OutputRect
, DestRect
, &ClipRegion
->rclBounds
))
940 InputPoint
.x
+= OutputRect
.left
- DestRect
->left
;
941 InputPoint
.y
+= OutputRect
.top
- DestRect
->top
;
945 OutputRect
= *DestRect
;
951 psurfDest
= CONTAINING_RECORD(psoDest
, SURFACE
, SurfObj
);
953 /* Dummy BitBlt to let driver know that it should flush its changes.
954 This should really be done using a call to DrvSynchronizeSurface,
955 but the VMware driver doesn't hook that call. */
956 IntEngBitBlt(psoDest
, NULL
, psoMask
, ClipRegion
, DestColorTranslation
,
957 DestRect
, pptlMask
, pptlMask
, pbo
, BrushOrigin
,
960 ret
= EngMaskBitBlt(psoDest
, psoMask
, ClipRegion
, DestColorTranslation
, SourceColorTranslation
,
961 &OutputRect
, &InputPoint
, pbo
, BrushOrigin
);
963 /* Dummy BitBlt to let driver know that something has changed. */
964 IntEngBitBlt(psoDest
, NULL
, psoMask
, ClipRegion
, DestColorTranslation
,
965 DestRect
, pptlMask
, pptlMask
, pbo
, BrushOrigin
,