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 along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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
);
85 // Source surface is device managed
86 if (psoSource
->iType
!=STYPE_BITMAP
)
88 /* FIXME: Eng* functions shouldn't call Drv* functions. ? */
89 if (psurfSource
->flHooks
& HOOK_COPYBITS
)
91 ret
= GDIDEVFUNCS(psoSource
).CopyBits(
92 psoDest
, psoSource
, Clip
, ColorTranslation
, DestRect
, SourcePoint
);
98 // If CopyBits wasn't hooked, BitBlt must be
99 ret
= IntEngBitBlt(psoDest
, psoSource
,
100 NULL
, Clip
, ColorTranslation
, DestRect
, SourcePoint
,
101 NULL
, NULL
, NULL
, ROP3_TO_ROP4(SRCCOPY
));
106 // Determine clipping type
109 clippingType
= DC_TRIVIAL
;
113 clippingType
= Clip
->iDComplexity
;
116 BltInfo
.DestSurface
= psoDest
;
117 BltInfo
.SourceSurface
= psoSource
;
118 BltInfo
.PatternSurface
= NULL
;
119 BltInfo
.XlateSourceToDest
= ColorTranslation
;
120 BltInfo
.Rop4
= SRCCOPY
;
122 switch (clippingType
)
125 BltInfo
.DestRect
= *DestRect
;
126 BltInfo
.SourcePoint
= *SourcePoint
;
128 ret
= DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
);
132 // Clip the blt to the clip rectangle
133 RECTL_bIntersectRect(&BltInfo
.DestRect
, DestRect
, &Clip
->rclBounds
);
135 BltInfo
.SourcePoint
.x
= SourcePoint
->x
+ BltInfo
.DestRect
.left
- DestRect
->left
;
136 BltInfo
.SourcePoint
.y
= SourcePoint
->y
+ BltInfo
.DestRect
.top
- DestRect
->top
;
138 ret
= DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
);
143 CLIPOBJ_cEnumStart(Clip
, FALSE
, CT_RECTANGLES
, CD_ANY
, 0);
147 EnumMore
= CLIPOBJ_bEnum(Clip
,(ULONG
) sizeof(RectEnum
), (PVOID
) &RectEnum
);
151 RECTL
* prclEnd
= &RectEnum
.arcl
[RectEnum
.c
];
152 RECTL
* prcl
= &RectEnum
.arcl
[0];
156 RECTL_bIntersectRect(&BltInfo
.DestRect
, prcl
, DestRect
);
158 BltInfo
.SourcePoint
.x
= SourcePoint
->x
+ prcl
->left
- DestRect
->left
;
159 BltInfo
.SourcePoint
.y
= SourcePoint
->y
+ prcl
->top
- DestRect
->top
;
161 if (!DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
))
169 } while (prcl
< prclEnd
);
183 if (psoDest
!= psoSource
)
185 SURFACE_UnlockBitmapBits(psurfDest
);
187 SURFACE_UnlockBitmapBits(psurfSource
);
201 return EngCopyBits(psoDest
, psoSource
, pco
, pxlo
, prclDest
, ptlSource
);