Add information letting us know creation deletion of services has worked.
[reactos.git] / reactos / subsys / win32k / eng / copybits.c
1 /*
2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
4 *
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.
9 *
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.
14 *
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.
18 */
19 /*
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
25 * REVISION HISTORY:
26 * 8/18/1999: Created
27 */
28
29 #include <w32k.h>
30
31 #define NDEBUG
32 #include <debug.h>
33
34 /*
35 * @implemented
36 */
37 BOOL STDCALL
38 EngCopyBits(SURFOBJ *Dest,
39 SURFOBJ *Source,
40 CLIPOBJ *Clip,
41 XLATEOBJ *ColorTranslation,
42 RECTL *DestRect,
43 POINTL *SourcePoint)
44 {
45 BOOLEAN ret;
46 BYTE clippingType;
47 RECT_ENUM RectEnum;
48 BOOL EnumMore;
49 BLTINFO BltInfo;
50 BITMAPOBJ *DestObj = NULL;
51 BITMAPOBJ *SourceObj;
52
53 ASSERT(Dest != NULL && Source != NULL && DestRect != NULL && SourcePoint != NULL);
54
55 SourceObj = CONTAINING_RECORD(Source, BITMAPOBJ, SurfObj);
56 BITMAPOBJ_LockBitmapBits(SourceObj);
57 MouseSafetyOnDrawStart(Source, SourcePoint->x, SourcePoint->y,
58 (SourcePoint->x + abs(DestRect->right - DestRect->left)),
59 (SourcePoint->y + abs(DestRect->bottom - DestRect->top)));
60 if (Dest != Source)
61 {
62 DestObj = CONTAINING_RECORD(Dest, BITMAPOBJ, SurfObj);
63 BITMAPOBJ_LockBitmapBits(DestObj);
64 }
65 MouseSafetyOnDrawStart(Dest, DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
66
67 // FIXME: Don't punt to the driver's DrvCopyBits immediately. Instead,
68 // mark the copy block function to be DrvCopyBits instead of the
69 // GDI's copy bit function so as to remove clipping from the
70 // driver's responsibility
71
72 // If one of the surfaces isn't managed by the GDI
73 if((Dest->iType!=STYPE_BITMAP) || (Source->iType!=STYPE_BITMAP))
74 {
75 // Destination surface is device managed
76 if(Dest->iType!=STYPE_BITMAP)
77 {
78 /* FIXME: Eng* functions shouldn't call Drv* functions. ? */
79 /* FIXME: Remove typecast. */
80 if (((BITMAPOBJ*)Dest)->flHooks & HOOK_COPYBITS)
81 {
82 ret = GDIDEVFUNCS(Dest).CopyBits(
83 Dest, Source, Clip, ColorTranslation, DestRect, SourcePoint);
84
85 MouseSafetyOnDrawEnd(Dest);
86 if (Dest != Source)
87 {
88 BITMAPOBJ_UnlockBitmapBits(DestObj);
89 }
90 MouseSafetyOnDrawEnd(Source);
91 BITMAPOBJ_UnlockBitmapBits(SourceObj);
92
93 return ret;
94 }
95 }
96
97 // Source surface is device managed
98 if(Source->iType!=STYPE_BITMAP)
99 {
100 /* FIXME: Eng* functions shouldn't call Drv* functions. ? */
101 /* FIXME: Remove typecast. */
102 if (((BITMAPOBJ*)Source)->flHooks & HOOK_COPYBITS)
103 {
104 ret = GDIDEVFUNCS(Source).CopyBits(
105 Dest, Source, Clip, ColorTranslation, DestRect, SourcePoint);
106
107 MouseSafetyOnDrawEnd(Dest);
108 if (Dest != Source)
109 {
110 BITMAPOBJ_UnlockBitmapBits(DestObj);
111 }
112 MouseSafetyOnDrawEnd(Source);
113 BITMAPOBJ_UnlockBitmapBits(SourceObj);
114
115 return ret;
116 }
117 }
118
119 // If CopyBits wasn't hooked, BitBlt must be
120 ret = IntEngBitBlt(Dest, Source,
121 NULL, Clip, ColorTranslation, DestRect, SourcePoint,
122 NULL, NULL, NULL, ROP3_TO_ROP4(SRCCOPY));
123
124 MouseSafetyOnDrawEnd(Dest);
125 if (Dest != Source)
126 {
127 BITMAPOBJ_UnlockBitmapBits(DestObj);
128 }
129 MouseSafetyOnDrawEnd(Source);
130 BITMAPOBJ_UnlockBitmapBits(SourceObj);
131
132 return ret;
133 }
134
135 // Determine clipping type
136 if (Clip == (CLIPOBJ *) NULL)
137 {
138 clippingType = DC_TRIVIAL;
139 } else {
140 clippingType = Clip->iDComplexity;
141 }
142
143 BltInfo.DestSurface = Dest;
144 BltInfo.SourceSurface = Source;
145 BltInfo.PatternSurface = NULL;
146 BltInfo.XlateSourceToDest = ColorTranslation;
147 BltInfo.XlatePatternToDest = NULL;
148 BltInfo.Rop4 = SRCCOPY;
149
150 switch(clippingType)
151 {
152 case DC_TRIVIAL:
153 BltInfo.DestRect = *DestRect;
154 BltInfo.SourcePoint = *SourcePoint;
155
156 DibFunctionsForBitmapFormat[Dest->iBitmapFormat].DIB_BitBltSrcCopy(&BltInfo);
157
158 MouseSafetyOnDrawEnd(Dest);
159 if (Dest != Source)
160 {
161 BITMAPOBJ_UnlockBitmapBits(DestObj);
162 }
163 MouseSafetyOnDrawEnd(Source);
164 BITMAPOBJ_UnlockBitmapBits(SourceObj);
165
166 return(TRUE);
167
168 case DC_RECT:
169 // Clip the blt to the clip rectangle
170 EngIntersectRect(&BltInfo.DestRect, DestRect, &Clip->rclBounds);
171
172 BltInfo.SourcePoint.x = SourcePoint->x + BltInfo.DestRect.left - DestRect->left;
173 BltInfo.SourcePoint.y = SourcePoint->y + BltInfo.DestRect.top - DestRect->top;
174
175 DibFunctionsForBitmapFormat[Dest->iBitmapFormat].DIB_BitBltSrcCopy(&BltInfo);
176
177 MouseSafetyOnDrawEnd(Dest);
178 if (Dest != Source)
179 {
180 BITMAPOBJ_UnlockBitmapBits(DestObj);
181 }
182 MouseSafetyOnDrawEnd(Source);
183 BITMAPOBJ_UnlockBitmapBits(SourceObj);
184
185 return(TRUE);
186
187 case DC_COMPLEX:
188
189 CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_ANY, 0);
190
191 do {
192 EnumMore = CLIPOBJ_bEnum(Clip,(ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
193
194 if (RectEnum.c > 0)
195 {
196 RECTL* prclEnd = &RectEnum.arcl[RectEnum.c];
197 RECTL* prcl = &RectEnum.arcl[0];
198
199 do {
200 EngIntersectRect(&BltInfo.DestRect, prcl, DestRect);
201
202 BltInfo.SourcePoint.x = SourcePoint->x + prcl->left - DestRect->left;
203 BltInfo.SourcePoint.y = SourcePoint->y + prcl->top - DestRect->top;
204
205 if(!DibFunctionsForBitmapFormat[Dest->iBitmapFormat].DIB_BitBltSrcCopy(&BltInfo))
206 return FALSE;
207
208 prcl++;
209
210 } while (prcl < prclEnd);
211 }
212
213 } while(EnumMore);
214
215 MouseSafetyOnDrawEnd(Dest);
216 if (Dest != Source)
217 {
218 BITMAPOBJ_UnlockBitmapBits(DestObj);
219 }
220 MouseSafetyOnDrawEnd(Source);
221 BITMAPOBJ_UnlockBitmapBits(SourceObj);
222
223 return(TRUE);
224 }
225
226 MouseSafetyOnDrawEnd(Dest);
227 if (Dest != Source)
228 {
229 BITMAPOBJ_UnlockBitmapBits(DestObj);
230 }
231 MouseSafetyOnDrawEnd(Source);
232 BITMAPOBJ_UnlockBitmapBits(SourceObj);
233
234 return FALSE;
235 }
236
237 /* EOF */