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 psurfDest
= CONTAINING_RECORD(psoDest
, SURFACE
, SurfObj
);
58 // FIXME: Don't punt to the driver's DrvCopyBits immediately. Instead,
59 // mark the copy block function to be DrvCopyBits instead of the
60 // GDI's copy bit function so as to remove clipping from the
61 // driver's responsibility
63 // If one of the surfaces isn't managed by the GDI
64 if ((psoDest
->iType
!=STYPE_BITMAP
) || (psoSource
->iType
!=STYPE_BITMAP
))
66 // Destination surface is device managed
67 if (psoDest
->iType
!=STYPE_BITMAP
)
69 /* FIXME: Eng* functions shouldn't call Drv* functions. ? */
70 if (psurfDest
->flags
& HOOK_COPYBITS
)
72 ret
= GDIDEVFUNCS(psoDest
).CopyBits(
73 psoDest
, psoSource
, Clip
, ColorTranslation
, DestRect
, SourcePoint
);
79 // Source surface is device managed
80 if (psoSource
->iType
!=STYPE_BITMAP
)
82 /* FIXME: Eng* functions shouldn't call Drv* functions. ? */
83 if (psurfSource
->flags
& HOOK_COPYBITS
)
85 ret
= GDIDEVFUNCS(psoSource
).CopyBits(
86 psoDest
, psoSource
, Clip
, ColorTranslation
, DestRect
, SourcePoint
);
92 // If CopyBits wasn't hooked, BitBlt must be
93 ret
= IntEngBitBlt(psoDest
, psoSource
,
94 NULL
, Clip
, ColorTranslation
, DestRect
, SourcePoint
,
95 NULL
, NULL
, NULL
, ROP3_TO_ROP4(SRCCOPY
));
100 // Determine clipping type
103 clippingType
= DC_TRIVIAL
;
107 clippingType
= Clip
->iDComplexity
;
110 BltInfo
.DestSurface
= psoDest
;
111 BltInfo
.SourceSurface
= psoSource
;
112 BltInfo
.PatternSurface
= NULL
;
113 BltInfo
.XlateSourceToDest
= ColorTranslation
;
114 BltInfo
.Rop4
= SRCCOPY
;
116 switch (clippingType
)
119 BltInfo
.DestRect
= *DestRect
;
120 BltInfo
.SourcePoint
= *SourcePoint
;
122 ret
= DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
);
126 // Clip the blt to the clip rectangle
127 RECTL_bIntersectRect(&BltInfo
.DestRect
, DestRect
, &Clip
->rclBounds
);
129 BltInfo
.SourcePoint
.x
= SourcePoint
->x
+ BltInfo
.DestRect
.left
- DestRect
->left
;
130 BltInfo
.SourcePoint
.y
= SourcePoint
->y
+ BltInfo
.DestRect
.top
- DestRect
->top
;
132 ret
= DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
);
137 CLIPOBJ_cEnumStart(Clip
, FALSE
, CT_RECTANGLES
, CD_ANY
, 0);
141 EnumMore
= CLIPOBJ_bEnum(Clip
,(ULONG
) sizeof(RectEnum
), (PVOID
) &RectEnum
);
145 RECTL
* prclEnd
= &RectEnum
.arcl
[RectEnum
.c
];
146 RECTL
* prcl
= &RectEnum
.arcl
[0];
150 RECTL_bIntersectRect(&BltInfo
.DestRect
, prcl
, DestRect
);
152 BltInfo
.SourcePoint
.x
= SourcePoint
->x
+ prcl
->left
- DestRect
->left
;
153 BltInfo
.SourcePoint
.y
= SourcePoint
->y
+ prcl
->top
- DestRect
->top
;
155 if (!DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
))
163 } while (prcl
< prclEnd
);
189 return EngCopyBits(psoDest
, psoSource
, pco
, pxlo
, prclDest
, ptlSource
);