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
11 #include <ddk/winddi.h>
14 #include "../dib/dib.h"
15 #include <include/mouse.h>
16 #include <include/object.h>
17 #include <include/eng.h>
20 EngCopyBits(SURFOBJ *Dest,
23 XLATEOBJ *ColorTranslation,
28 SURFGDI *DestGDI, *SourceGDI;
35 MouseSafetyOnDrawStart(Source, SourceGDI, SourcePoint->x, SourcePoint->y,
36 (SourcePoint->x + abs(DestRect->right - DestRect->left)),
37 (SourcePoint->y + abs(DestRect->bottom - DestRect->top)));
38 MouseSafetyOnDrawStart(Dest, DestGDI, DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
40 // FIXME: Don't punt to the driver's DrvCopyBits immediately. Instead,
41 // mark the copy block function to be DrvCopyBits instead of the
42 // GDI's copy bit function so as to remove clipping from the
43 // driver's responsibility
45 // If one of the surfaces isn't managed by the GDI
46 if((Dest->iType!=STYPE_BITMAP) || (Source->iType!=STYPE_BITMAP))
48 // Destination surface is device managed
49 if(Dest->iType!=STYPE_BITMAP)
51 DestGDI = (PSURFGDI)AccessInternalObjectFromUserObject(Dest);
53 if (DestGDI->CopyBits!=NULL)
55 ret = DestGDI->CopyBits(Dest, Source, Clip, ColorTranslation, DestRect, SourcePoint);
57 MouseSafetyOnDrawEnd(Source, SourceGDI);
58 MouseSafetyOnDrawEnd(Dest, DestGDI);
64 // Source surface is device managed
65 if(Source->iType!=STYPE_BITMAP)
67 SourceGDI = (PSURFGDI)AccessInternalObjectFromUserObject(Source);
69 if (SourceGDI->CopyBits!=NULL)
71 ret = SourceGDI->CopyBits(Dest, Source, Clip, ColorTranslation, DestRect, SourcePoint);
73 MouseSafetyOnDrawEnd(Source, SourceGDI);
74 MouseSafetyOnDrawEnd(Dest, DestGDI);
80 // If CopyBits wasn't hooked, BitBlt must be
81 ret = EngBitBlt(Dest, Source,
82 NULL, Clip, ColorTranslation, DestRect, SourcePoint,
85 MouseSafetyOnDrawEnd(Source, SourceGDI);
86 MouseSafetyOnDrawEnd(Dest, DestGDI);
91 // Determine clipping type
92 if (Clip == (CLIPOBJ *) NULL)
94 clippingType = DC_TRIVIAL;
96 clippingType = Clip->iDComplexity;
99 // We only handle XO_TABLE translations at the momement
100 if ((ColorTranslation == NULL) || (ColorTranslation->flXlate & XO_TRIVIAL) ||
101 (ColorTranslation->flXlate & XO_TABLE))
103 SourceGDI = (PSURFGDI)AccessInternalObjectFromUserObject(Source);
104 DestGDI = (PSURFGDI)AccessInternalObjectFromUserObject(Dest);
109 DestGDI->DIB_BitBlt(Dest, Source, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation);
111 MouseSafetyOnDrawEnd(Source, SourceGDI);
112 MouseSafetyOnDrawEnd(Dest, DestGDI);
117 // Clip the blt to the clip rectangle
118 EngIntersectRect(&rclTmp, DestRect, &Clip->rclBounds);
120 ptlTmp.x = SourcePoint->x + rclTmp.left - DestRect->left;
121 ptlTmp.y = SourcePoint->y + rclTmp.top - DestRect->top;
123 DestGDI->DIB_BitBlt(Dest, Source, DestGDI, SourceGDI, &rclTmp, &ptlTmp, ColorTranslation);
125 MouseSafetyOnDrawEnd(Source, SourceGDI);
126 MouseSafetyOnDrawEnd(Dest, DestGDI);
132 CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_ANY, ENUM_RECT_LIMIT);
135 EnumMore = CLIPOBJ_bEnum(Clip,(ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
139 RECTL* prclEnd = &RectEnum.arcl[RectEnum.c];
140 RECTL* prcl = &RectEnum.arcl[0];
143 EngIntersectRect(prcl, prcl, DestRect);
145 ptlTmp.x = SourcePoint->x + prcl->left - DestRect->left;
146 ptlTmp.y = SourcePoint->y + prcl->top - DestRect->top;
148 if(!DestGDI->DIB_BitBlt(Dest, Source, DestGDI, SourceGDI,
149 prcl, &ptlTmp, ColorTranslation)) return FALSE;
153 } while (prcl < prclEnd);
158 MouseSafetyOnDrawEnd(Source, SourceGDI);
\r
159 MouseSafetyOnDrawEnd(Dest, DestGDI);
165 MouseSafetyOnDrawEnd(Source, SourceGDI);
166 MouseSafetyOnDrawEnd(Dest, DestGDI);