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
.Rop4
= SRCCOPY
;
141 BltInfo
.DestRect
= *DestRect
;
142 BltInfo
.SourcePoint
= *SourcePoint
;
144 DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
);
146 MouseSafetyOnDrawEnd(psoDest
);
147 if (psoDest
!= psoSource
)
149 SURFACE_UnlockBitmapBits(psurfDest
);
151 SURFACE_UnlockBitmapBits(psurfSource
);
156 // Clip the blt to the clip rectangle
157 RECTL_bIntersectRect(&BltInfo
.DestRect
, DestRect
, &Clip
->rclBounds
);
159 BltInfo
.SourcePoint
.x
= SourcePoint
->x
+ BltInfo
.DestRect
.left
- DestRect
->left
;
160 BltInfo
.SourcePoint
.y
= SourcePoint
->y
+ BltInfo
.DestRect
.top
- DestRect
->top
;
162 DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
);
164 if (psoDest
!= psoSource
)
166 SURFACE_UnlockBitmapBits(psurfDest
);
168 SURFACE_UnlockBitmapBits(psurfSource
);
174 CLIPOBJ_cEnumStart(Clip
, FALSE
, CT_RECTANGLES
, CD_ANY
, 0);
177 EnumMore
= CLIPOBJ_bEnum(Clip
,(ULONG
) sizeof(RectEnum
), (PVOID
) &RectEnum
);
181 RECTL
* prclEnd
= &RectEnum
.arcl
[RectEnum
.c
];
182 RECTL
* prcl
= &RectEnum
.arcl
[0];
185 RECTL_bIntersectRect(&BltInfo
.DestRect
, prcl
, DestRect
);
187 BltInfo
.SourcePoint
.x
= SourcePoint
->x
+ prcl
->left
- DestRect
->left
;
188 BltInfo
.SourcePoint
.y
= SourcePoint
->y
+ prcl
->top
- DestRect
->top
;
190 if(!DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
))
195 } while (prcl
< prclEnd
);
200 if (psoDest
!= psoSource
)
202 SURFACE_UnlockBitmapBits(psurfDest
);
204 SURFACE_UnlockBitmapBits(psurfSource
);
209 if (psoDest
!= psoSource
)
211 SURFACE_UnlockBitmapBits(psurfDest
);
213 SURFACE_UnlockBitmapBits(psurfSource
);
229 MouseSafetyOnDrawStart(psoSource
, ptlSource
->x
, ptlSource
->y
,
230 (ptlSource
->x
+ abs(prclDest
->right
- prclDest
->left
)),
231 (ptlSource
->y
+ abs(prclDest
->bottom
- prclDest
->top
)));
233 MouseSafetyOnDrawStart(psoDest
, prclDest
->left
, prclDest
->top
, prclDest
->right
, prclDest
->bottom
);
235 bResult
= EngCopyBits(psoDest
, psoSource
, pco
, pxlo
, prclDest
, ptlSource
);
237 MouseSafetyOnDrawEnd(psoDest
);
238 MouseSafetyOnDrawEnd(psoSource
);