2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Win32k subsystem
4 * PURPOSE: GDI BitBlt Functions
5 * FILE: win32ss/gdi/eng/bitblt.c
6 * PROGRAMER: Jason Filby
15 XCLIPOBJ gxcoTrivial
=
21 {LONG_MIN
, LONG_MIN
, LONG_MAX
, LONG_MAX
}, /* rclBounds */
22 DC_TRIVIAL
, /* idCOmplexity */
23 FC_RECT
, /* iFComplexity */
24 TC_RECTANGLES
, /* iMode */
31 typedef BOOLEAN (APIENTRY
*PBLTRECTFUNC
)(SURFOBJ
* OutputObj
,
34 XLATEOBJ
* ColorTranslation
,
42 static BOOLEAN APIENTRY
43 BltMask(SURFOBJ
* psoDest
,
46 XLATEOBJ
* ColorTranslation
,
55 BYTE
*pjMskLine
, *pjMskCurrent
;
56 BYTE fjMaskBit0
, fjMaskBit
;
59 ULONG PatternWidth
= 0, PatternHeight
= 0;
60 LONG PatternX0
= 0, PatternX
= 0, PatternY
= 0;
61 LONG SrcX
= 0, SrcY
= 0;
62 PFN_DIB_PutPixel fnDest_PutPixel
= NULL
;
63 PFN_DIB_GetPixel fnPattern_GetPixel
= NULL
, fnSrc_GetPixel
= NULL
, fnDest_GetPixel
;
64 ULONG Pattern
= 0, Source
= 0, Dest
= 0;
65 DWORD fgndRop
, bkgndRop
;
67 ASSERT(IS_VALID_ROP4(Rop4
));
68 ASSERT(psoMask
->iBitmapFormat
== BMF_1BPP
);
70 fgndRop
= ROP4_FGND(Rop4
);
71 bkgndRop
= ROP4_BKGND(Rop4
);
73 //DPRINT1("Rop4 : 0x%08x\n", Rop4);
75 /* Determine pattern */
76 if (pbo
&& pbo
->iSolidColor
== 0xFFFFFFFF)
78 psoPattern
= BRUSHOBJ_psoPattern(pbo
);
81 PatternWidth
= psoPattern
->sizlBitmap
.cx
;
82 PatternHeight
= psoPattern
->sizlBitmap
.cy
;
83 fnPattern_GetPixel
= DibFunctionsForBitmapFormat
[psoPattern
->iBitmapFormat
].DIB_GetPixel
;
89 cx
= prclDest
->right
- prclDest
->left
;
90 cy
= prclDest
->bottom
- prclDest
->top
;
91 if ((pptlMask
->x
+ cx
> psoMask
->sizlBitmap
.cx
) ||
92 (pptlMask
->y
+ cy
> psoMask
->sizlBitmap
.cy
))
97 pjMskLine
= (PBYTE
)psoMask
->pvScan0
+ pptlMask
->y
* psoMask
->lDelta
+ (pptlMask
->x
>> 3);
98 fjMaskBit0
= 0x80 >> (pptlMask
->x
& 0x07);
100 fnDest_PutPixel
= DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_PutPixel
;
101 fnDest_GetPixel
= DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_GetPixel
;
103 /* Do we have a source */
107 ASSERT(ROP4_USES_SOURCE(Rop4
));
108 fnSrc_GetPixel
= DibFunctionsForBitmapFormat
[psoSource
->iBitmapFormat
].DIB_GetPixel
;
109 SrcY
= pptlSource
->y
;
110 SrcX
= pptlSource
->x
;
115 PatternY
= (prclDest
->top
- pptlBrush
->y
) % PatternHeight
;
118 PatternY
+= PatternHeight
;
120 PatternX0
= (prclDest
->left
- pptlBrush
->x
) % PatternWidth
;
123 PatternX0
+= PatternWidth
;
125 PatternX
= PatternX0
;
129 Pattern
= pbo
? pbo
->iSolidColor
: 0;
132 for (y
= prclDest
->top
; y
< prclDest
->bottom
; y
++)
134 pjMskCurrent
= pjMskLine
;
135 fjMaskBit
= fjMaskBit0
;
137 for (x
= prclDest
->left
; x
< prclDest
->right
; x
++)
139 Rop4
= (*pjMskCurrent
& fjMaskBit
) ? fgndRop
: bkgndRop
;
143 if(ROP4_USES_PATTERN(Rop4
))
144 Pattern
= fnPattern_GetPixel(psoPattern
, PatternX
, PatternY
);
146 PatternX
%= PatternWidth
;
151 if(ROP4_USES_SOURCE(Rop4
))
153 Source
= XLATEOBJ_iXlate(ColorTranslation
,
154 fnSrc_GetPixel(psoSource
, SrcX
, SrcY
));
159 if(ROP4_USES_DEST(Rop4
))
160 Dest
= fnDest_GetPixel(psoDest
, x
, y
);
162 fnDest_PutPixel(psoDest
,
169 fjMaskBit
= _rotr8(fjMaskBit
, 1);
170 pjMskCurrent
+= (fjMaskBit
>> 7);
172 pjMskLine
+= psoMask
->lDelta
;
176 PatternY
%= PatternHeight
;
177 PatternX
= PatternX0
;
182 SrcX
= pptlSource
->x
;
191 static BOOLEAN APIENTRY
192 BltPatCopy(SURFOBJ
* Dest
,
195 XLATEOBJ
* ColorTranslation
,
203 // These functions are assigned if we're working with a DIB
204 // The assigned functions depend on the bitsPerPixel of the DIB
206 DibFunctionsForBitmapFormat
[Dest
->iBitmapFormat
].DIB_ColorFill(Dest
, DestRect
, pbo
? pbo
->iSolidColor
: 0);
211 static BOOLEAN APIENTRY
212 CallDibBitBlt(SURFOBJ
* OutputObj
,
215 XLATEOBJ
* ColorTranslation
,
227 BltInfo
.DestSurface
= OutputObj
;
228 BltInfo
.SourceSurface
= InputObj
;
229 BltInfo
.PatternSurface
= NULL
;
230 BltInfo
.XlateSourceToDest
= ColorTranslation
;
231 BltInfo
.DestRect
= *OutputRect
;
232 BltInfo
.SourcePoint
= *InputPoint
;
234 if ((Rop4
& 0xFF) == R3_OPINDEX_SRCCOPY
)
235 return DibFunctionsForBitmapFormat
[OutputObj
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
);
238 BltInfo
.BrushOrigin
= *BrushOrigin
;
242 if (ROP4_USES_PATTERN(Rop4
) && pbo
&& pbo
->iSolidColor
== 0xFFFFFFFF)
244 psoPattern
= BRUSHOBJ_psoPattern(pbo
);
247 BltInfo
.PatternSurface
= psoPattern
;
251 /* FIXME: What to do here? */
259 Result
= DibFunctionsForBitmapFormat
[OutputObj
->iBitmapFormat
].DIB_BitBlt(&BltInfo
);
264 INT __cdecl
abs(INT nm
);
281 IN POINTL
*pptlBrush
,
291 ProbeForRead(prclTrg
, sizeof(RECTL
), 1);
292 RtlCopyMemory(&rclTrg
,prclTrg
, sizeof(RECTL
));
294 ProbeForRead(pptlSrc
, sizeof(POINTL
), 1);
295 RtlCopyMemory(&ptlSrc
, pptlSrc
, sizeof(POINTL
));
297 ProbeForRead(pptlMask
, sizeof(POINTL
), 1);
298 RtlCopyMemory(&ptlMask
, pptlMask
, sizeof(POINTL
));
300 ProbeForRead(pptlBrush
, sizeof(POINTL
), 1);
301 RtlCopyMemory(&ptlBrush
, pptlBrush
, sizeof(POINTL
));
304 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
306 _SEH2_YIELD(return FALSE
);
310 return EngBitBlt(psoTrg
, psoSrc
, psoMask
, pco
, pxlo
, &rclTrg
, &ptlSrc
, &ptlMask
, pbo
, &ptlBrush
, Rop4
);
319 _Inout_ SURFOBJ
*psoTrg
,
320 _In_opt_ SURFOBJ
*psoSrc
,
321 _In_opt_ SURFOBJ
*psoMask
,
322 _In_opt_ CLIPOBJ
*pco
,
323 _In_opt_ XLATEOBJ
*pxlo
,
325 _In_opt_ POINTL
*pptlSrc
,
326 _In_opt_ POINTL
*pptlMask
,
327 _In_opt_ BRUSHOBJ
*pbo
,
328 _In_opt_ POINTL
*pptlBrush
,
338 SURFOBJ
* InputObj
= 0;
340 PBLTRECTFUNC BltRectFunc
;
346 BOOL UsesSource
, UsesMask
;
347 POINTL AdjustedBrushOrigin
;
349 UsesSource
= ROP4_USES_SOURCE(rop4
);
350 UsesMask
= ROP4_USES_MASK(rop4
);
352 if (rop4
== ROP4_NOOP
)
354 /* Copy destination onto itself: nop */
358 //DPRINT1("rop4 : 0x%08x\n", rop4);
360 OutputRect
= *prclTrg
;
361 RECTL_vMakeWellOrdered(&OutputRect
);
365 if (!psoSrc
|| !pptlSrc
)
370 /* Make sure we don't try to copy anything outside the valid source
372 InputPoint
= *pptlSrc
;
373 if (InputPoint
.x
< 0)
375 OutputRect
.left
-= InputPoint
.x
;
378 if (InputPoint
.y
< 0)
380 OutputRect
.top
-= InputPoint
.y
;
383 if (psoSrc
->sizlBitmap
.cx
< InputPoint
.x
+
384 OutputRect
.right
- OutputRect
.left
)
386 OutputRect
.right
= OutputRect
.left
+
387 psoSrc
->sizlBitmap
.cx
- InputPoint
.x
;
389 if (psoSrc
->sizlBitmap
.cy
< InputPoint
.y
+
390 OutputRect
.bottom
- OutputRect
.top
)
392 OutputRect
.bottom
= OutputRect
.top
+
393 psoSrc
->sizlBitmap
.cy
- InputPoint
.y
;
396 InputRect
.left
= InputPoint
.x
;
397 InputRect
.right
= InputPoint
.x
+ (OutputRect
.right
- OutputRect
.left
);
398 InputRect
.top
= InputPoint
.y
;
399 InputRect
.bottom
= InputPoint
.y
+ (OutputRect
.bottom
- OutputRect
.top
);
405 InputPoint
.x
= InputPoint
.y
= 0;
407 InputRect
.right
= prclTrg
->right
- prclTrg
->left
;
409 InputRect
.bottom
= prclTrg
->bottom
- prclTrg
->top
;
414 if (OutputRect
.left
< pco
->rclBounds
.left
)
416 InputRect
.left
+= pco
->rclBounds
.left
- OutputRect
.left
;
417 InputPoint
.x
+= pco
->rclBounds
.left
- OutputRect
.left
;
418 OutputRect
.left
= pco
->rclBounds
.left
;
420 if (pco
->rclBounds
.right
< OutputRect
.right
)
422 InputRect
.right
-= OutputRect
.right
- pco
->rclBounds
.right
;
423 OutputRect
.right
= pco
->rclBounds
.right
;
425 if (OutputRect
.top
< pco
->rclBounds
.top
)
427 InputRect
.top
+= pco
->rclBounds
.top
- OutputRect
.top
;
428 InputPoint
.y
+= pco
->rclBounds
.top
- OutputRect
.top
;
429 OutputRect
.top
= pco
->rclBounds
.top
;
431 if (pco
->rclBounds
.bottom
< OutputRect
.bottom
)
433 InputRect
.bottom
-= OutputRect
.bottom
- pco
->rclBounds
.bottom
;
434 OutputRect
.bottom
= pco
->rclBounds
.bottom
;
438 /* Check for degenerate case: if height or width of OutputRect is 0 pixels
439 there's nothing to do */
440 if (OutputRect
.right
<= OutputRect
.left
||
441 OutputRect
.bottom
<= OutputRect
.top
)
450 AdjustedBrushOrigin
.x
= pptlBrush
->x
;
451 AdjustedBrushOrigin
.y
= pptlBrush
->y
;
455 AdjustedBrushOrigin
.x
= 0;
456 AdjustedBrushOrigin
.y
= 0;
459 /* Determine clipping type */
460 if (pco
== (CLIPOBJ
*) NULL
)
462 clippingType
= DC_TRIVIAL
;
466 clippingType
= pco
->iDComplexity
;
469 /* Check if we need a mask but have no mask surface */
470 if (UsesMask
&& (psoMask
== NULL
))
472 /* Check if the BRUSHOBJ can provide the mask */
473 psoMask
= BRUSHOBJ_psoMask(pbo
);
476 /* We have no mask, assume the mask is all foreground */
477 rop4
= (rop4
& 0xFF) | ((rop4
& 0xFF) << 8);
484 BltRectFunc
= BltMask
;
486 else if ((rop4
& 0xFF) == R3_OPINDEX_PATCOPY
)
488 if (pbo
&& pbo
->iSolidColor
== 0xFFFFFFFF)
489 BltRectFunc
= CallDibBitBlt
;
491 BltRectFunc
= BltPatCopy
;
495 BltRectFunc
= CallDibBitBlt
;
499 switch (clippingType
)
502 Ret
= (*BltRectFunc
)(OutputObj
,
510 &AdjustedBrushOrigin
,
514 /* Clip the blt to the clip rectangle */
515 ClipRect
.left
= pco
->rclBounds
.left
;
516 ClipRect
.right
= pco
->rclBounds
.right
;
517 ClipRect
.top
= pco
->rclBounds
.top
;
518 ClipRect
.bottom
= pco
->rclBounds
.bottom
;
519 if (RECTL_bIntersectRect(&CombinedRect
, &OutputRect
, &ClipRect
))
524 AdjustedBrushOrigin
.x
= BrushOrigin
->x
+ CombinedRect
.left
- OutputRect
.left
;
525 AdjustedBrushOrigin
.y
= BrushOrigin
->y
+ CombinedRect
.top
- OutputRect
.top
;
528 Pt
.x
= InputPoint
.x
+ CombinedRect
.left
- OutputRect
.left
;
529 Pt
.y
= InputPoint
.y
+ CombinedRect
.top
- OutputRect
.top
;
530 Ret
= (*BltRectFunc
)(OutputObj
,
538 &AdjustedBrushOrigin
,
544 if (OutputObj
== InputObj
)
546 if (OutputRect
.top
< InputPoint
.y
)
548 Direction
= OutputRect
.left
< InputPoint
.x
?
549 CD_RIGHTDOWN
: CD_LEFTDOWN
;
553 Direction
= OutputRect
.left
< InputPoint
.x
?
554 CD_RIGHTUP
: CD_LEFTUP
;
561 CLIPOBJ_cEnumStart(pco
, FALSE
, CT_RECTANGLES
, Direction
, 0);
564 EnumMore
= CLIPOBJ_bEnum(pco
, sizeof(RectEnum
),
567 for (i
= 0; i
< RectEnum
.c
; i
++)
569 ClipRect
.left
= RectEnum
.arcl
[i
].left
;
570 ClipRect
.right
= RectEnum
.arcl
[i
].right
;
571 ClipRect
.top
= RectEnum
.arcl
[i
].top
;
572 ClipRect
.bottom
= RectEnum
.arcl
[i
].bottom
;
573 if (RECTL_bIntersectRect(&CombinedRect
, &OutputRect
, &ClipRect
))
578 AdjustedBrushOrigin
.x
= BrushOrigin
->x
+ CombinedRect
.left
- OutputRect
.left
;
579 AdjustedBrushOrigin
.y
= BrushOrigin
->y
+ CombinedRect
.top
- OutputRect
.top
;
582 Pt
.x
= InputPoint
.x
+ CombinedRect
.left
- OutputRect
.left
;
583 Pt
.y
= InputPoint
.y
+ CombinedRect
.top
- OutputRect
.top
;
584 Ret
= (*BltRectFunc
)(OutputObj
,
592 &AdjustedBrushOrigin
,
619 SURFACE
*psurfSrc
= NULL
;
624 PFN_DrvBitBlt pfnBitBlt
;
627 psurfTrg
= CONTAINING_RECORD(psoTrg
, SURFACE
, SurfObj
);
629 /* FIXME: Should we really allow to pass non-well-ordered rects? */
630 rclClipped
= *prclTrg
;
631 RECTL_vMakeWellOrdered(&rclClipped
);
633 //DPRINT1("Rop4 : 0x%08x\n", Rop4);
636 ASSERT(IS_VALID_ROP4(Rop4
));
640 /* Clip target rect against the bounds of the clipping region */
641 if (!RECTL_bIntersectRect(&rclClipped
, &rclClipped
, &pco
->rclBounds
))
647 /* Don't pass a clipobj with only a single rect */
648 if (pco
->iDComplexity
== DC_RECT
)
652 pco
= &gxcoTrivial
.ClipObj
;
654 if (ROP4_USES_SOURCE(Rop4
))
657 psurfSrc
= CONTAINING_RECORD(psoSrc
, SURFACE
, SurfObj
);
659 /* Calculate source rect */
660 rclSrc
.left
= pptlSrc
->x
+ rclClipped
.left
- prclTrg
->left
;
661 rclSrc
.top
= pptlSrc
->y
+ rclClipped
.top
- prclTrg
->top
;
662 rclSrc
.right
= rclSrc
.left
+ rclClipped
.right
- rclClipped
.left
;
663 rclSrc
.bottom
= rclSrc
.top
+ rclClipped
.bottom
- rclClipped
.top
;
664 pptlSrc
= (PPOINTL
)&rclSrc
;
675 ptlBrush
.x
= pptlBrush
->x
+ rclClipped
.left
- prclTrg
->left
;
676 ptlBrush
.y
= pptlBrush
->y
+ rclClipped
.top
- prclTrg
->top
;
678 ptlBrush
= *pptlBrush
;
682 /* Is the target surface device managed? */
683 if (psurfTrg
->flags
& HOOK_BITBLT
)
685 /* Is the source a different device managed surface? */
686 if (psoSrc
&& psoSrc
->hdev
!= psoTrg
->hdev
&& psurfSrc
->flags
& HOOK_BITBLT
)
688 DPRINT1("Need to copy to standard bitmap format!\n");
692 pfnBitBlt
= GDIDEVFUNCS(psoTrg
).BitBlt
;
695 /* Is the source surface device managed? */
696 else if (psoSrc
&& psurfSrc
->flags
& HOOK_BITBLT
)
698 pfnBitBlt
= GDIDEVFUNCS(psoSrc
).BitBlt
;
702 pfnBitBlt
= EngBitBlt
;
705 bResult
= pfnBitBlt(psoTrg
,
714 pptlBrush
? &ptlBrush
: NULL
,
717 // FIXME: cleanup temp surface!
722 #endif // !_USE_DIBLIB_
724 /**** REACTOS FONT RENDERING CODE *********************************************/
726 /* renders the alpha mask bitmap */
727 static BOOLEAN APIENTRY
728 AlphaBltMask(SURFOBJ
* psoDest
,
729 SURFOBJ
* psoSource
, // unused
731 XLATEOBJ
* pxloRGB2Dest
,
734 POINTL
* pptlSource
, // unused
741 ULONG Background
, BrushColor
, NewColor
;
744 ASSERT(psoSource
== NULL
);
745 ASSERT(pptlSource
== NULL
);
747 dx
= prclDest
->right
- prclDest
->left
;
748 dy
= prclDest
->bottom
- prclDest
->top
;
752 BrushColor
= XLATEOBJ_iXlate(pxloBrush
, pbo
? pbo
->iSolidColor
: 0);
753 r
= (int)GetRValue(BrushColor
);
754 g
= (int)GetGValue(BrushColor
);
755 b
= (int)GetBValue(BrushColor
);
757 tMask
= (PBYTE
)psoMask
->pvScan0
+ (pptlMask
->y
* psoMask
->lDelta
) + pptlMask
->x
;
758 for (j
= 0; j
< dy
; j
++)
761 for (i
= 0; i
< dx
; i
++)
767 DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_PutPixel(
768 psoDest
, prclDest
->left
+ i
, prclDest
->top
+ j
, pbo
? pbo
->iSolidColor
: 0);
772 Background
= DIB_GetSource(psoDest
, prclDest
->left
+ i
, prclDest
->top
+ j
,
776 RGB((*lMask
* (r
- GetRValue(Background
)) >> 8) + GetRValue(Background
),
777 (*lMask
* (g
- GetGValue(Background
)) >> 8) + GetGValue(Background
),
778 (*lMask
* (b
- GetBValue(Background
)) >> 8) + GetBValue(Background
));
780 Background
= XLATEOBJ_iXlate(pxloRGB2Dest
, NewColor
);
781 DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_PutPixel(
782 psoDest
, prclDest
->left
+ i
, prclDest
->top
+ j
, Background
);
787 tMask
+= psoMask
->lDelta
;
799 EngMaskBitBlt(SURFOBJ
*psoDest
,
802 XLATEOBJ
*DestColorTranslation
,
803 XLATEOBJ
*SourceColorTranslation
,
817 INTENG_ENTER_LEAVE EnterLeaveSource
;
818 INTENG_ENTER_LEAVE EnterLeaveDest
;
826 POINTL AdjustedBrushOrigin
;
832 InputRect
.left
= pptlMask
->x
;
833 InputRect
.right
= pptlMask
->x
+ (DestRect
->right
- DestRect
->left
);
834 InputRect
.top
= pptlMask
->y
;
835 InputRect
.bottom
= pptlMask
->y
+ (DestRect
->bottom
- DestRect
->top
);
840 InputRect
.right
= DestRect
->right
- DestRect
->left
;
842 InputRect
.bottom
= DestRect
->bottom
- DestRect
->top
;
845 OutputRect
= *DestRect
;
846 if (NULL
!= ClipRegion
)
848 if (OutputRect
.left
< ClipRegion
->rclBounds
.left
)
850 InputRect
.left
+= ClipRegion
->rclBounds
.left
- OutputRect
.left
;
851 OutputRect
.left
= ClipRegion
->rclBounds
.left
;
853 if (ClipRegion
->rclBounds
.right
< OutputRect
.right
)
855 InputRect
.right
-= OutputRect
.right
- ClipRegion
->rclBounds
.right
;
856 OutputRect
.right
= ClipRegion
->rclBounds
.right
;
858 if (OutputRect
.top
< ClipRegion
->rclBounds
.top
)
860 InputRect
.top
+= ClipRegion
->rclBounds
.top
- OutputRect
.top
;
861 OutputRect
.top
= ClipRegion
->rclBounds
.top
;
863 if (ClipRegion
->rclBounds
.bottom
< OutputRect
.bottom
)
865 InputRect
.bottom
-= OutputRect
.bottom
- ClipRegion
->rclBounds
.bottom
;
866 OutputRect
.bottom
= ClipRegion
->rclBounds
.bottom
;
870 if (! IntEngEnter(&EnterLeaveSource
, psoMask
, &InputRect
, TRUE
, &Translate
, &psoInput
))
875 InputPoint
.x
= InputRect
.left
+ Translate
.x
;
876 InputPoint
.y
= InputRect
.top
+ Translate
.y
;
878 /* Check for degenerate case: if height or width of OutputRect is 0 pixels there's
880 if (OutputRect
.right
<= OutputRect
.left
|| OutputRect
.bottom
<= OutputRect
.top
)
882 IntEngLeave(&EnterLeaveSource
);
886 if (! IntEngEnter(&EnterLeaveDest
, psoDest
, &OutputRect
, FALSE
, &Translate
, &psoOutput
))
888 IntEngLeave(&EnterLeaveSource
);
892 OutputRect
.left
= DestRect
->left
+ Translate
.x
;
893 OutputRect
.right
= DestRect
->right
+ Translate
.x
;
894 OutputRect
.top
= DestRect
->top
+ Translate
.y
;
895 OutputRect
.bottom
= DestRect
->bottom
+ Translate
.y
;
899 AdjustedBrushOrigin
.x
= BrushOrigin
->x
+ Translate
.x
;
900 AdjustedBrushOrigin
.y
= BrushOrigin
->y
+ Translate
.y
;
903 AdjustedBrushOrigin
= Translate
;
905 // Determine clipping type
906 if (ClipRegion
== (CLIPOBJ
*) NULL
)
908 clippingType
= DC_TRIVIAL
;
910 clippingType
= ClipRegion
->iDComplexity
;
913 switch (clippingType
)
916 if (psoMask
->iBitmapFormat
== BMF_8BPP
)
917 Ret
= AlphaBltMask(psoOutput
, NULL
, psoInput
, DestColorTranslation
, SourceColorTranslation
,
918 &OutputRect
, NULL
, &InputPoint
, pbo
, &AdjustedBrushOrigin
);
920 Ret
= BltMask(psoOutput
, NULL
, psoInput
, DestColorTranslation
,
921 &OutputRect
, NULL
, &InputPoint
, pbo
, &AdjustedBrushOrigin
,
925 // Clip the blt to the clip rectangle
926 ClipRect
.left
= ClipRegion
->rclBounds
.left
+ Translate
.x
;
927 ClipRect
.right
= ClipRegion
->rclBounds
.right
+ Translate
.x
;
928 ClipRect
.top
= ClipRegion
->rclBounds
.top
+ Translate
.y
;
929 ClipRect
.bottom
= ClipRegion
->rclBounds
.bottom
+ Translate
.y
;
930 if (RECTL_bIntersectRect(&CombinedRect
, &OutputRect
, &ClipRect
))
932 Pt
.x
= InputPoint
.x
+ CombinedRect
.left
- OutputRect
.left
;
933 Pt
.y
= InputPoint
.y
+ CombinedRect
.top
- OutputRect
.top
;
934 if (psoMask
->iBitmapFormat
== BMF_8BPP
)
936 Ret
= AlphaBltMask(psoOutput
, NULL
, psoInput
, DestColorTranslation
, SourceColorTranslation
,
937 &CombinedRect
, NULL
, &Pt
, pbo
, &AdjustedBrushOrigin
);
941 Ret
= BltMask(psoOutput
, NULL
, psoInput
, DestColorTranslation
,
942 &CombinedRect
, NULL
, &Pt
, pbo
, &AdjustedBrushOrigin
, ROP4_MASK
);
948 if (psoOutput
== psoInput
)
950 if (OutputRect
.top
< InputPoint
.y
)
952 Direction
= OutputRect
.left
< InputPoint
.x
? CD_RIGHTDOWN
: CD_LEFTDOWN
;
956 Direction
= OutputRect
.left
< InputPoint
.x
? CD_RIGHTUP
: CD_LEFTUP
;
963 CLIPOBJ_cEnumStart(ClipRegion
, FALSE
, CT_RECTANGLES
, Direction
, 0);
966 EnumMore
= CLIPOBJ_bEnum(ClipRegion
,(ULONG
) sizeof(RectEnum
), (PVOID
) &RectEnum
);
968 for (i
= 0; i
< RectEnum
.c
; i
++)
970 ClipRect
.left
= RectEnum
.arcl
[i
].left
+ Translate
.x
;
971 ClipRect
.right
= RectEnum
.arcl
[i
].right
+ Translate
.x
;
972 ClipRect
.top
= RectEnum
.arcl
[i
].top
+ Translate
.y
;
973 ClipRect
.bottom
= RectEnum
.arcl
[i
].bottom
+ Translate
.y
;
974 if (RECTL_bIntersectRect(&CombinedRect
, &OutputRect
, &ClipRect
))
976 Pt
.x
= InputPoint
.x
+ CombinedRect
.left
- OutputRect
.left
;
977 Pt
.y
= InputPoint
.y
+ CombinedRect
.top
- OutputRect
.top
;
978 if (psoMask
->iBitmapFormat
== BMF_8BPP
)
980 Ret
= AlphaBltMask(psoOutput
, NULL
, psoInput
,
981 DestColorTranslation
,
982 SourceColorTranslation
,
983 &CombinedRect
, NULL
, &Pt
, pbo
,
984 &AdjustedBrushOrigin
) && Ret
;
988 Ret
= BltMask(psoOutput
, NULL
, psoInput
,
989 DestColorTranslation
, &CombinedRect
, NULL
,
990 &Pt
, pbo
, &AdjustedBrushOrigin
,
1001 IntEngLeave(&EnterLeaveDest
);
1002 IntEngLeave(&EnterLeaveSource
);
1010 _Inout_ SURFOBJ
*psoDest
,
1011 _In_ SURFOBJ
*psoMask
,
1013 _In_ XLATEOBJ
*pxloDest
,
1014 _In_ XLATEOBJ
*pxloSource
,
1015 _In_ RECTL
*prclDest
,
1016 _In_ POINTL
*pptlMask
,
1018 _In_ POINTL
*pptlBrushOrg
)
1022 POINTL ptMask
= {0,0};
1029 /* Is this a 1 BPP mask? */
1030 if (psoMask
->iBitmapFormat
== BMF_1BPP
)
1032 /* Use IntEngBitBlt with an appropriate ROP4 */
1033 return IntEngBitBlt(psoDest
,
1046 ASSERT(psoMask
->iBitmapFormat
== BMF_8BPP
);
1053 /* Clip against the bounds of the clipping region so we won't try to write
1054 * outside the surface */
1057 /* Intersect with the clip bounds and check if everything was clipped */
1058 if (!RECTL_bIntersectRect(&rcDest
, prclDest
, &pco
->rclBounds
))
1063 /* Adjust the mask point */
1064 ptMask
.x
+= rcDest
.left
- prclDest
->left
;
1065 ptMask
.y
+= rcDest
.top
- prclDest
->top
;
1072 /* Check if the target surface is device managed */
1073 if (psoDest
->iType
!= STYPE_BITMAP
)
1077 rcTemp
.right
= rcDest
.right
- rcDest
.left
;
1078 rcTemp
.bottom
= rcDest
.bottom
- rcDest
.top
;
1080 /* Allocate a temporary surface */
1081 psurfTemp
= SURFACE_AllocSurface(STYPE_BITMAP
,
1084 psoDest
->iBitmapFormat
,
1089 if (psurfTemp
== NULL
)
1094 /* Copy the current target surface bits to the temp surface */
1095 ret
= EngCopyBits(&psurfTemp
->SurfObj
,
1104 /* Do the operation on the temp surface */
1105 ret
= EngMaskBitBlt(&psurfTemp
->SurfObj
,
1118 /* Copy the result back to the dest surface */
1119 ret
= EngCopyBits(psoDest
,
1120 &psurfTemp
->SurfObj
,
1127 /* Delete the temp surface */
1128 GDIOBJ_vDeleteObject(&psurfTemp
->BaseObject
);
1132 /* Do the operation on the target surface */
1133 ret
= EngMaskBitBlt(psoDest
,