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.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS kernel
22 * PURPOSE: GDI EngCopyBits Function
23 * FILE: subsys/win32k/eng/copybits.c
24 * PROGRAMER: Jason Filby
38 EngCopyBits(SURFOBJ
*psoDest
,
41 XLATEOBJ
*ColorTranslation
,
53 ASSERT(psoDest
!= NULL
&& psoSource
!= NULL
&& DestRect
!= NULL
&& SourcePoint
!= NULL
);
55 psurfSource
= CONTAINING_RECORD(psoSource
, SURFACE
, SurfObj
);
56 SURFACE_LockBitmapBits(psurfSource
);
58 psurfDest
= CONTAINING_RECORD(psoDest
, SURFACE
, SurfObj
);
59 if (psoDest
!= psoSource
)
61 SURFACE_LockBitmapBits(psurfDest
);
64 // FIXME: Don't punt to the driver's DrvCopyBits immediately. Instead,
65 // mark the copy block function to be DrvCopyBits instead of the
66 // GDI's copy bit function so as to remove clipping from the
67 // driver's responsibility
69 // If one of the surfaces isn't managed by the GDI
70 if((psoDest
->iType
!=STYPE_BITMAP
) || (psoSource
->iType
!=STYPE_BITMAP
))
72 // Destination surface is device managed
73 if(psoDest
->iType
!=STYPE_BITMAP
)
75 /* FIXME: Eng* functions shouldn't call Drv* functions. ? */
76 if (psurfDest
->flHooks
& HOOK_COPYBITS
)
78 ret
= GDIDEVFUNCS(psoDest
).CopyBits(
79 psoDest
, psoSource
, Clip
, ColorTranslation
, DestRect
, SourcePoint
);
81 if (psoDest
!= psoSource
)
83 SURFACE_UnlockBitmapBits(psurfDest
);
85 SURFACE_UnlockBitmapBits(psurfSource
);
91 // Source surface is device managed
92 if(psoSource
->iType
!=STYPE_BITMAP
)
94 /* FIXME: Eng* functions shouldn't call Drv* functions. ? */
95 if (psurfSource
->flHooks
& HOOK_COPYBITS
)
97 ret
= GDIDEVFUNCS(psoSource
).CopyBits(
98 psoDest
, psoSource
, Clip
, ColorTranslation
, DestRect
, SourcePoint
);
100 if (psoDest
!= psoSource
)
102 SURFACE_UnlockBitmapBits(psurfDest
);
104 SURFACE_UnlockBitmapBits(psurfSource
);
110 // If CopyBits wasn't hooked, BitBlt must be
111 ret
= IntEngBitBlt(psoDest
, psoSource
,
112 NULL
, Clip
, ColorTranslation
, DestRect
, SourcePoint
,
113 NULL
, NULL
, NULL
, ROP3_TO_ROP4(SRCCOPY
));
115 if (psoDest
!= psoSource
)
117 SURFACE_UnlockBitmapBits(psurfDest
);
119 SURFACE_UnlockBitmapBits(psurfSource
);
124 // Determine clipping type
125 if (Clip
== (CLIPOBJ
*) NULL
)
127 clippingType
= DC_TRIVIAL
;
129 clippingType
= Clip
->iDComplexity
;
132 BltInfo
.DestSurface
= psoDest
;
133 BltInfo
.SourceSurface
= psoSource
;
134 BltInfo
.PatternSurface
= NULL
;
135 BltInfo
.XlateSourceToDest
= ColorTranslation
;
136 BltInfo
.XlatePatternToDest
= NULL
;
137 BltInfo
.Rop4
= SRCCOPY
;
142 BltInfo
.DestRect
= *DestRect
;
143 BltInfo
.SourcePoint
= *SourcePoint
;
145 DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
);
147 MouseSafetyOnDrawEnd(psoDest
);
148 if (psoDest
!= psoSource
)
150 SURFACE_UnlockBitmapBits(psurfDest
);
152 SURFACE_UnlockBitmapBits(psurfSource
);
157 // Clip the blt to the clip rectangle
158 EngIntersectRect(&BltInfo
.DestRect
, DestRect
, &Clip
->rclBounds
);
160 BltInfo
.SourcePoint
.x
= SourcePoint
->x
+ BltInfo
.DestRect
.left
- DestRect
->left
;
161 BltInfo
.SourcePoint
.y
= SourcePoint
->y
+ BltInfo
.DestRect
.top
- DestRect
->top
;
163 DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
);
165 if (psoDest
!= psoSource
)
167 SURFACE_UnlockBitmapBits(psurfDest
);
169 SURFACE_UnlockBitmapBits(psurfSource
);
175 CLIPOBJ_cEnumStart(Clip
, FALSE
, CT_RECTANGLES
, CD_ANY
, 0);
178 EnumMore
= CLIPOBJ_bEnum(Clip
,(ULONG
) sizeof(RectEnum
), (PVOID
) &RectEnum
);
182 RECTL
* prclEnd
= &RectEnum
.arcl
[RectEnum
.c
];
183 RECTL
* prcl
= &RectEnum
.arcl
[0];
186 EngIntersectRect(&BltInfo
.DestRect
, prcl
, DestRect
);
188 BltInfo
.SourcePoint
.x
= SourcePoint
->x
+ prcl
->left
- DestRect
->left
;
189 BltInfo
.SourcePoint
.y
= SourcePoint
->y
+ prcl
->top
- DestRect
->top
;
191 if(!DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
))
196 } while (prcl
< prclEnd
);
201 if (psoDest
!= psoSource
)
203 SURFACE_UnlockBitmapBits(psurfDest
);
205 SURFACE_UnlockBitmapBits(psurfSource
);
210 if (psoDest
!= psoSource
)
212 SURFACE_UnlockBitmapBits(psurfDest
);
214 SURFACE_UnlockBitmapBits(psurfSource
);
230 MouseSafetyOnDrawStart(psoSource
, ptlSource
->x
, ptlSource
->y
,
231 (ptlSource
->x
+ abs(prclDest
->right
- prclDest
->left
)),
232 (ptlSource
->y
+ abs(prclDest
->bottom
- prclDest
->top
)));
234 MouseSafetyOnDrawStart(psoDest
, prclDest
->left
, prclDest
->top
, prclDest
->right
, prclDest
->bottom
);
236 bResult
= EngCopyBits(psoDest
, psoSource
, pco
, pxlo
, prclDest
, ptlSource
);
238 MouseSafetyOnDrawEnd(psoDest
);
239 MouseSafetyOnDrawEnd(psoSource
);