mirror of
https://github.com/reactos/reactos.git
synced 2025-04-19 12:08:55 +00:00
Prevent painting outside surface
svn path=/trunk/; revision=5019
This commit is contained in:
parent
d4b51b9c1f
commit
d1c76c1e31
1 changed files with 83 additions and 29 deletions
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: bitblt.c,v 1.21 2003/06/28 08:39:18 gvg Exp $
|
/* $Id: bitblt.c,v 1.22 2003/07/09 07:00:00 gvg Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -71,12 +71,15 @@ BOOL STDCALL EngIntersectRect(PRECTL prcDst, PRECTL prcSrc1, PRECTL prcSrc2)
|
||||||
prcDst->top = max(prcSrc1->top, prcSrc2->top);
|
prcDst->top = max(prcSrc1->top, prcSrc2->top);
|
||||||
prcDst->bottom = min(prcSrc1->bottom, prcSrc2->bottom);
|
prcDst->bottom = min(prcSrc1->bottom, prcSrc2->bottom);
|
||||||
|
|
||||||
if (prcDst->top < prcDst->bottom) return(TRUE);
|
if (prcDst->top < prcDst->bottom)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*prcDst = rclEmpty;
|
*prcDst = rclEmpty;
|
||||||
|
|
||||||
return(FALSE);
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOLEAN STDCALL
|
static BOOLEAN STDCALL
|
||||||
|
@ -208,13 +211,6 @@ EngBitBlt(SURFOBJ *DestObj,
|
||||||
RECTL ClipRect;
|
RECTL ClipRect;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
/* Check for degenerate case: if height or width of DestRect is 0 pixels there's
|
|
||||||
nothing to do */
|
|
||||||
if (DestRect->right == DestRect->left || DestRect->bottom == DestRect->top)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL != SourcePoint)
|
if (NULL != SourcePoint)
|
||||||
{
|
{
|
||||||
InputRect.left = SourcePoint->x;
|
InputRect.left = SourcePoint->x;
|
||||||
|
@ -252,6 +248,39 @@ EngBitBlt(SURFOBJ *DestObj,
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputRect = *DestRect;
|
OutputRect = *DestRect;
|
||||||
|
if (NULL != ClipRegion)
|
||||||
|
{
|
||||||
|
if (OutputRect.left < ClipRegion->rclBounds.left)
|
||||||
|
{
|
||||||
|
InputRect.left += ClipRegion->rclBounds.left - OutputRect.left;
|
||||||
|
InputPoint.x += ClipRegion->rclBounds.left - OutputRect.left;
|
||||||
|
OutputRect.left = ClipRegion->rclBounds.left;
|
||||||
|
}
|
||||||
|
if (ClipRegion->rclBounds.right < OutputRect.right)
|
||||||
|
{
|
||||||
|
InputRect.right -= OutputRect.right - ClipRegion->rclBounds.right;
|
||||||
|
OutputRect.right = ClipRegion->rclBounds.right;
|
||||||
|
}
|
||||||
|
if (OutputRect.top < ClipRegion->rclBounds.top)
|
||||||
|
{
|
||||||
|
InputRect.top += ClipRegion->rclBounds.top - OutputRect.top;
|
||||||
|
InputPoint.y += ClipRegion->rclBounds.top - OutputRect.top;
|
||||||
|
OutputRect.top = ClipRegion->rclBounds.top;
|
||||||
|
}
|
||||||
|
if (ClipRegion->rclBounds.bottom < OutputRect.bottom)
|
||||||
|
{
|
||||||
|
InputRect.bottom -= OutputRect.bottom - ClipRegion->rclBounds.bottom;
|
||||||
|
OutputRect.bottom = ClipRegion->rclBounds.bottom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check for degenerate case: if height or width of OutputRect is 0 pixels there's
|
||||||
|
nothing to do */
|
||||||
|
if (OutputRect.right <= OutputRect.left || OutputRect.bottom <= OutputRect.top)
|
||||||
|
{
|
||||||
|
IntEngLeave(&EnterLeaveSource);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (! IntEngEnter(&EnterLeaveDest, DestObj, &OutputRect, FALSE, &Translate, &OutputObj))
|
if (! IntEngEnter(&EnterLeaveDest, DestObj, &OutputRect, FALSE, &Translate, &OutputObj))
|
||||||
{
|
{
|
||||||
|
@ -264,7 +293,6 @@ EngBitBlt(SURFOBJ *DestObj,
|
||||||
OutputRect.top = DestRect->top + Translate.y;
|
OutputRect.top = DestRect->top + Translate.y;
|
||||||
OutputRect.bottom = DestRect->bottom + Translate.y;
|
OutputRect.bottom = DestRect->bottom + Translate.y;
|
||||||
|
|
||||||
|
|
||||||
if (NULL != OutputObj)
|
if (NULL != OutputObj)
|
||||||
{
|
{
|
||||||
OutputGDI = (PSURFGDI)AccessInternalObjectFromUserObject(OutputObj);
|
OutputGDI = (PSURFGDI)AccessInternalObjectFromUserObject(OutputObj);
|
||||||
|
@ -300,7 +328,6 @@ EngBitBlt(SURFOBJ *DestObj,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// We don't handle color translation just yet [we dont have to.. REMOVE REMOVE REMOVE]
|
|
||||||
switch(clippingType)
|
switch(clippingType)
|
||||||
{
|
{
|
||||||
case DC_TRIVIAL:
|
case DC_TRIVIAL:
|
||||||
|
@ -363,30 +390,57 @@ IntEngBitBlt(SURFOBJ *DestObj,
|
||||||
BOOLEAN ret;
|
BOOLEAN ret;
|
||||||
SURFGDI *DestGDI;
|
SURFGDI *DestGDI;
|
||||||
SURFGDI *SourceGDI;
|
SURFGDI *SourceGDI;
|
||||||
|
RECTL OutputRect;
|
||||||
|
POINTL InputPoint;
|
||||||
|
|
||||||
|
if (NULL != SourcePoint)
|
||||||
|
{
|
||||||
|
InputPoint = *SourcePoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clip against the bounds of the clipping region so we won't try to write
|
||||||
|
* outside the surface */
|
||||||
|
if (NULL != ClipRegion)
|
||||||
|
{
|
||||||
|
if (! EngIntersectRect(&OutputRect, DestRect, &ClipRegion->rclBounds))
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
InputPoint.x += OutputRect.left - DestRect->left;
|
||||||
|
InputPoint.y += OutputRect.top - DestRect->top;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OutputRect = *DestRect;
|
||||||
|
}
|
||||||
|
|
||||||
if (NULL != SourceObj)
|
if (NULL != SourceObj)
|
||||||
{
|
{
|
||||||
SourceGDI = (PSURFGDI) AccessInternalObjectFromUserObject(SourceObj);
|
SourceGDI = (PSURFGDI) AccessInternalObjectFromUserObject(SourceObj);
|
||||||
MouseSafetyOnDrawStart(SourceObj, SourceGDI, SourcePoint->x, SourcePoint->y,
|
MouseSafetyOnDrawStart(SourceObj, SourceGDI, InputPoint.x, InputPoint.y,
|
||||||
(SourcePoint->x + abs(DestRect->right - DestRect->left)),
|
(InputPoint.x + abs(DestRect->right - DestRect->left)),
|
||||||
(SourcePoint->y + abs(DestRect->bottom - DestRect->top)));
|
(InputPoint.y + abs(DestRect->bottom - DestRect->top)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No success yet */
|
/* No success yet */
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
DestGDI = (SURFGDI*)AccessInternalObjectFromUserObject(DestObj);
|
DestGDI = (SURFGDI*)AccessInternalObjectFromUserObject(DestObj);
|
||||||
MouseSafetyOnDrawStart(DestObj, DestGDI, DestRect->left, DestRect->top,
|
MouseSafetyOnDrawStart(DestObj, DestGDI, OutputRect.left, OutputRect.top,
|
||||||
DestRect->right, DestRect->bottom);
|
OutputRect.right, OutputRect.bottom);
|
||||||
|
|
||||||
/* Call the driver's DrvBitBlt if available */
|
/* Call the driver's DrvBitBlt if available */
|
||||||
if (NULL != DestGDI->BitBlt) {
|
if (NULL != DestGDI->BitBlt)
|
||||||
|
{
|
||||||
ret = DestGDI->BitBlt(DestObj, SourceObj, Mask, ClipRegion, ColorTranslation,
|
ret = DestGDI->BitBlt(DestObj, SourceObj, Mask, ClipRegion, ColorTranslation,
|
||||||
DestRect, SourcePoint, MaskOrigin, Brush, BrushOrigin, Rop4);
|
&OutputRect, &InputPoint, MaskOrigin, Brush, BrushOrigin,
|
||||||
|
Rop4);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! ret) {
|
if (! ret)
|
||||||
|
{
|
||||||
ret = EngBitBlt(DestObj, SourceObj, Mask, ClipRegion, ColorTranslation,
|
ret = EngBitBlt(DestObj, SourceObj, Mask, ClipRegion, ColorTranslation,
|
||||||
DestRect, SourcePoint, MaskOrigin, Brush, BrushOrigin, Rop4);
|
&OutputRect, &InputPoint, MaskOrigin, Brush, BrushOrigin,
|
||||||
|
Rop4);
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseSafetyOnDrawEnd(DestObj, DestGDI);
|
MouseSafetyOnDrawEnd(DestObj, DestGDI);
|
||||||
|
|
Loading…
Reference in a new issue