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
18 EngCopyBits(SURFOBJ
*psoDest
,
21 XLATEOBJ
*ColorTranslation
,
32 RECTL rclDest
= *DestRect
;
33 POINTL ptlSrc
= *SourcePoint
;
35 ASSERT(psoDest
!= NULL
&& psoSource
!= NULL
&& DestRect
!= NULL
&& SourcePoint
!= NULL
);
37 psurfSource
= CONTAINING_RECORD(psoSource
, SURFACE
, SurfObj
);
38 psurfDest
= CONTAINING_RECORD(psoDest
, SURFACE
, SurfObj
);
40 /* Clip dest rect against source surface size / source point */
41 if (psoSource
->sizlBitmap
.cx
- ptlSrc
.x
< rclDest
.right
- rclDest
.left
)
42 rclDest
.right
= rclDest
.left
+ psoSource
->sizlBitmap
.cx
- ptlSrc
.x
;
43 if (psoSource
->sizlBitmap
.cy
- ptlSrc
.y
< rclDest
.bottom
- rclDest
.top
)
44 rclDest
.bottom
= rclDest
.top
+ psoSource
->sizlBitmap
.cy
- ptlSrc
.y
;
46 /* Clip dest rect against target surface size */
47 if (rclDest
.right
> psoDest
->sizlBitmap
.cx
)
48 rclDest
.right
= psoDest
->sizlBitmap
.cx
;
49 if (rclDest
.bottom
> psoDest
->sizlBitmap
.cy
)
50 rclDest
.bottom
= psoDest
->sizlBitmap
.cy
;
51 if (RECTL_bIsEmptyRect(&rclDest
)) return TRUE
;
54 // FIXME: Don't punt to the driver's DrvCopyBits immediately. Instead,
55 // mark the copy block function to be DrvCopyBits instead of the
56 // GDI's copy bit function so as to remove clipping from the
57 // driver's responsibility
59 // If one of the surfaces isn't managed by the GDI
60 if ((psoDest
->iType
!=STYPE_BITMAP
) || (psoSource
->iType
!=STYPE_BITMAP
))
62 // Destination surface is device managed
63 if (psoDest
->iType
!=STYPE_BITMAP
)
65 /* FIXME: Eng* functions shouldn't call Drv* functions. ? */
66 if (psurfDest
->flags
& HOOK_COPYBITS
)
68 ret
= GDIDEVFUNCS(psoDest
).CopyBits(
69 psoDest
, psoSource
, Clip
, ColorTranslation
, DestRect
, SourcePoint
);
75 // Source surface is device managed
76 if (psoSource
->iType
!=STYPE_BITMAP
)
78 /* FIXME: Eng* functions shouldn't call Drv* functions. ? */
79 if (psurfSource
->flags
& HOOK_COPYBITS
)
81 ret
= GDIDEVFUNCS(psoSource
).CopyBits(
82 psoDest
, psoSource
, Clip
, ColorTranslation
, DestRect
, SourcePoint
);
88 // If CopyBits wasn't hooked, BitBlt must be
89 ret
= IntEngBitBlt(psoDest
, psoSource
,
90 NULL
, Clip
, ColorTranslation
, DestRect
, SourcePoint
,
91 NULL
, NULL
, NULL
, ROP4_FROM_INDEX(R3_OPINDEX_SRCCOPY
));
96 // Determine clipping type
99 clippingType
= DC_TRIVIAL
;
103 clippingType
= Clip
->iDComplexity
;
106 BltInfo
.DestSurface
= psoDest
;
107 BltInfo
.SourceSurface
= psoSource
;
108 BltInfo
.PatternSurface
= NULL
;
109 BltInfo
.XlateSourceToDest
= ColorTranslation
;
110 BltInfo
.Rop4
= ROP4_FROM_INDEX(R3_OPINDEX_SRCCOPY
);
112 switch (clippingType
)
115 BltInfo
.DestRect
= *DestRect
;
116 BltInfo
.SourcePoint
= *SourcePoint
;
118 ret
= DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
);
122 // Clip the blt to the clip rectangle
123 RECTL_bIntersectRect(&BltInfo
.DestRect
, DestRect
, &Clip
->rclBounds
);
125 BltInfo
.SourcePoint
.x
= SourcePoint
->x
+ BltInfo
.DestRect
.left
- DestRect
->left
;
126 BltInfo
.SourcePoint
.y
= SourcePoint
->y
+ BltInfo
.DestRect
.top
- DestRect
->top
;
128 ret
= DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
);
133 CLIPOBJ_cEnumStart(Clip
, FALSE
, CT_RECTANGLES
, CD_ANY
, 0);
137 EnumMore
= CLIPOBJ_bEnum(Clip
,(ULONG
) sizeof(RectEnum
), (PVOID
) &RectEnum
);
141 RECTL
* prclEnd
= &RectEnum
.arcl
[RectEnum
.c
];
142 RECTL
* prcl
= &RectEnum
.arcl
[0];
146 RECTL_bIntersectRect(&BltInfo
.DestRect
, prcl
, DestRect
);
148 BltInfo
.SourcePoint
.x
= SourcePoint
->x
+ prcl
->left
- DestRect
->left
;
149 BltInfo
.SourcePoint
.y
= SourcePoint
->y
+ prcl
->top
- DestRect
->top
;
151 if (!DibFunctionsForBitmapFormat
[psoDest
->iBitmapFormat
].DIB_BitBltSrcCopy(&BltInfo
))
159 } while (prcl
< prclEnd
);
185 return EngCopyBits(psoDest
, psoSource
, pco
, pxlo
, prclDest
, ptlSource
);