2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: GDI EngCopyBits Function
5 * FILE: subsys/win32k/eng/copybits.c
6 * PROGRAMER: Jason Filby
19 _In_ SURFOBJ
*psoDest
,
20 _In_ SURFOBJ
*psoSource
,
21 _In_opt_ CLIPOBJ
*Clip
,
22 _In_opt_ XLATEOBJ
*ColorTranslation
,
24 _In_ POINTL
*SourcePoint
)
33 RECTL rclDest
= *DestRect
;
34 POINTL ptlSrc
= *SourcePoint
;
36 ASSERT(psoDest
!= NULL
&& psoSource
!= NULL
&& DestRect
!= NULL
&& SourcePoint
!= NULL
);
38 psurfSource
= CONTAINING_RECORD(psoSource
, SURFACE
, SurfObj
);
39 psurfDest
= CONTAINING_RECORD(psoDest
, SURFACE
, SurfObj
);
41 /* Clip dest rect against source surface size / source point */
42 if (psoSource
->sizlBitmap
.cx
- ptlSrc
.x
< rclDest
.right
- rclDest
.left
)
43 rclDest
.right
= rclDest
.left
+ psoSource
->sizlBitmap
.cx
- ptlSrc
.x
;
44 if (psoSource
->sizlBitmap
.cy
- ptlSrc
.y
< rclDest
.bottom
- rclDest
.top
)
45 rclDest
.bottom
= rclDest
.top
+ psoSource
->sizlBitmap
.cy
- ptlSrc
.y
;
47 /* Clip dest rect against target surface size */
48 if (rclDest
.right
> psoDest
->sizlBitmap
.cx
)
49 rclDest
.right
= psoDest
->sizlBitmap
.cx
;
50 if (rclDest
.bottom
> psoDest
->sizlBitmap
.cy
)
51 rclDest
.bottom
= psoDest
->sizlBitmap
.cy
;
52 if (RECTL_bIsEmptyRect(&rclDest
)) return TRUE
;
55 // FIXME: Don't punt to the driver's DrvCopyBits immediately. Instead,
56 // mark the copy block function to be DrvCopyBits instead of the
57 // GDI's copy bit function so as to remove clipping from the
58 // driver's responsibility
60 // If one of the surfaces isn't managed by the GDI
61 if ((psoDest
->iType
!=STYPE_BITMAP
) || (psoSource
->iType
!=STYPE_BITMAP
))
63 // Destination surface is device managed
64 if (psoDest
->iType
!=STYPE_BITMAP
)
66 /* FIXME: Eng* functions shouldn't call Drv* functions. ? */
67 if (psurfDest
->flags
& HOOK_COPYBITS
)
69 ret
= GDIDEVFUNCS(psoDest
).CopyBits(
70 psoDest
, psoSource
, Clip
, ColorTranslation
, DestRect
, SourcePoint
);
76 // Source surface is device managed
77 if (psoSource
->iType
!=STYPE_BITMAP
)
79 /* FIXME: Eng* functions shouldn't call Drv* functions. ? */
80 if (psurfSource
->flags
& HOOK_COPYBITS
)
82 ret
= GDIDEVFUNCS(psoSource
).CopyBits(
83 psoDest
, psoSource
, Clip
, ColorTranslation
, DestRect
, SourcePoint
);
89 // If CopyBits wasn't hooked, BitBlt must be
90 ret
= IntEngBitBlt(psoDest
, psoSource
,
91 NULL
, Clip
, ColorTranslation
, DestRect
, SourcePoint
,
92 NULL
, NULL
, NULL
, ROP4_FROM_INDEX(R3_OPINDEX_SRCCOPY
));
97 // Determine clipping type
100 clippingType
= DC_TRIVIAL
;
104 clippingType
= Clip
->iDComplexity
;
107 BltInfo
.DestSurface
= psoDest
;
108 BltInfo
.SourceSurface
= psoSource
;
109 BltInfo
.PatternSurface
= NULL
;
110 BltInfo
.XlateSourceToDest
= ColorTranslation
;
111 BltInfo
.Rop4
= ROP4_FROM_INDEX(R3_OPINDEX_SRCCOPY
);
113 switch (clippingType
)
116 BltInfo
.DestRect
= *DestRect
;
117 BltInfo
.SourcePoint
= *SourcePoint
;
119 ret
= DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
);
123 // Clip the blt to the clip rectangle
124 RECTL_bIntersectRect(&BltInfo
.DestRect
, DestRect
, &Clip
->rclBounds
);
126 BltInfo
.SourcePoint
.x
= SourcePoint
->x
+ BltInfo
.DestRect
.left
- DestRect
->left
;
127 BltInfo
.SourcePoint
.y
= SourcePoint
->y
+ BltInfo
.DestRect
.top
- DestRect
->top
;
129 ret
= DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
);
134 CLIPOBJ_cEnumStart(Clip
, FALSE
, CT_RECTANGLES
, CD_ANY
, 0);
138 EnumMore
= CLIPOBJ_bEnum(Clip
,(ULONG
) sizeof(RectEnum
), (PVOID
) &RectEnum
);
142 RECTL
* prclEnd
= &RectEnum
.arcl
[RectEnum
.c
];
143 RECTL
* prcl
= &RectEnum
.arcl
[0];
147 RECTL_bIntersectRect(&BltInfo
.DestRect
, prcl
, DestRect
);
149 BltInfo
.SourcePoint
.x
= SourcePoint
->x
+ prcl
->left
- DestRect
->left
;
150 BltInfo
.SourcePoint
.y
= SourcePoint
->y
+ prcl
->top
- DestRect
->top
;
152 if (!DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
))
160 } while (prcl
< prclEnd
);
186 return EngCopyBits(psoDest
, psoSource
, pco
, pxlo
, prclDest
, ptlSource
);