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
,
52 RECTL rclDest
= *DestRect
;
53 POINTL ptlSrc
= *SourcePoint
;
55 ASSERT(psoDest
!= NULL
&& psoSource
!= NULL
&& DestRect
!= NULL
&& SourcePoint
!= NULL
);
57 psurfSource
= CONTAINING_RECORD(psoSource
, SURFACE
, SurfObj
);
58 psurfDest
= CONTAINING_RECORD(psoDest
, SURFACE
, SurfObj
);
60 /* Clip dest rect against source surface size / source point */
61 if (psoSource
->sizlBitmap
.cx
- ptlSrc
.x
< rclDest
.right
- rclDest
.left
)
62 rclDest
.right
= rclDest
.left
+ psoSource
->sizlBitmap
.cx
- ptlSrc
.x
;
63 if (psoSource
->sizlBitmap
.cy
- ptlSrc
.y
< rclDest
.bottom
- rclDest
.top
)
64 rclDest
.bottom
= rclDest
.top
+ psoSource
->sizlBitmap
.cy
- ptlSrc
.y
;
66 /* Clip dest rect against target surface size */
67 if (rclDest
.right
> psoDest
->sizlBitmap
.cx
)
68 rclDest
.right
= psoDest
->sizlBitmap
.cx
;
69 if (rclDest
.bottom
> psoDest
->sizlBitmap
.cy
)
70 rclDest
.bottom
= psoDest
->sizlBitmap
.cy
;
71 if (RECTL_bIsEmptyRect(&rclDest
)) return TRUE
;
74 // FIXME: Don't punt to the driver's DrvCopyBits immediately. Instead,
75 // mark the copy block function to be DrvCopyBits instead of the
76 // GDI's copy bit function so as to remove clipping from the
77 // driver's responsibility
79 // If one of the surfaces isn't managed by the GDI
80 if ((psoDest
->iType
!=STYPE_BITMAP
) || (psoSource
->iType
!=STYPE_BITMAP
))
82 // Destination surface is device managed
83 if (psoDest
->iType
!=STYPE_BITMAP
)
85 /* FIXME: Eng* functions shouldn't call Drv* functions. ? */
86 if (psurfDest
->flags
& HOOK_COPYBITS
)
88 ret
= GDIDEVFUNCS(psoDest
).CopyBits(
89 psoDest
, psoSource
, Clip
, ColorTranslation
, DestRect
, SourcePoint
);
95 // Source surface is device managed
96 if (psoSource
->iType
!=STYPE_BITMAP
)
98 /* FIXME: Eng* functions shouldn't call Drv* functions. ? */
99 if (psurfSource
->flags
& HOOK_COPYBITS
)
101 ret
= GDIDEVFUNCS(psoSource
).CopyBits(
102 psoDest
, psoSource
, Clip
, ColorTranslation
, DestRect
, SourcePoint
);
108 // If CopyBits wasn't hooked, BitBlt must be
109 ret
= IntEngBitBlt(psoDest
, psoSource
,
110 NULL
, Clip
, ColorTranslation
, DestRect
, SourcePoint
,
111 NULL
, NULL
, NULL
, ROP4_FROM_INDEX(R3_OPINDEX_SRCCOPY
));
116 // Determine clipping type
119 clippingType
= DC_TRIVIAL
;
123 clippingType
= Clip
->iDComplexity
;
126 BltInfo
.DestSurface
= psoDest
;
127 BltInfo
.SourceSurface
= psoSource
;
128 BltInfo
.PatternSurface
= NULL
;
129 BltInfo
.XlateSourceToDest
= ColorTranslation
;
130 BltInfo
.Rop4
= ROP4_FROM_INDEX(R3_OPINDEX_SRCCOPY
);
132 switch (clippingType
)
135 BltInfo
.DestRect
= *DestRect
;
136 BltInfo
.SourcePoint
= *SourcePoint
;
138 ret
= DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
);
142 // Clip the blt to the clip rectangle
143 RECTL_bIntersectRect(&BltInfo
.DestRect
, DestRect
, &Clip
->rclBounds
);
145 BltInfo
.SourcePoint
.x
= SourcePoint
->x
+ BltInfo
.DestRect
.left
- DestRect
->left
;
146 BltInfo
.SourcePoint
.y
= SourcePoint
->y
+ BltInfo
.DestRect
.top
- DestRect
->top
;
148 ret
= DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
);
153 CLIPOBJ_cEnumStart(Clip
, FALSE
, CT_RECTANGLES
, CD_ANY
, 0);
157 EnumMore
= CLIPOBJ_bEnum(Clip
,(ULONG
) sizeof(RectEnum
), (PVOID
) &RectEnum
);
161 RECTL
* prclEnd
= &RectEnum
.arcl
[RectEnum
.c
];
162 RECTL
* prcl
= &RectEnum
.arcl
[0];
166 RECTL_bIntersectRect(&BltInfo
.DestRect
, prcl
, DestRect
);
168 BltInfo
.SourcePoint
.x
= SourcePoint
->x
+ prcl
->left
- DestRect
->left
;
169 BltInfo
.SourcePoint
.y
= SourcePoint
->y
+ prcl
->top
- DestRect
->top
;
171 if (!DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
))
179 } while (prcl
< prclEnd
);
205 return EngCopyBits(psoDest
, psoSource
, pco
, pxlo
, prclDest
, ptlSource
);