mirror of
https://github.com/reactos/reactos.git
synced 2024-09-06 02:37:06 +00:00
Don't copy from/to outside the visible screen region
svn path=/trunk/; revision=8142
This commit is contained in:
parent
76414f84fd
commit
8143621407
|
@ -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: misc.c,v 1.2 2003/05/18 17:16:17 ea Exp $ */
|
/* $Id: misc.c,v 1.3 2004/02/10 23:40:55 gvg Exp $ */
|
||||||
#include <ddk/winddi.h>
|
#include <ddk/winddi.h>
|
||||||
#include <include/dib.h>
|
#include <include/dib.h>
|
||||||
#include <include/object.h>
|
#include <include/object.h>
|
||||||
|
@ -36,6 +36,7 @@ IntEngEnter(PINTENG_ENTER_LEAVE EnterLeave,
|
||||||
SIZEL BitmapSize;
|
SIZEL BitmapSize;
|
||||||
POINTL SrcPoint;
|
POINTL SrcPoint;
|
||||||
LONG Width;
|
LONG Width;
|
||||||
|
RECTL ClippedDestRect;
|
||||||
|
|
||||||
/* Normalize */
|
/* Normalize */
|
||||||
if (DestRect->right < DestRect->left)
|
if (DestRect->right < DestRect->left)
|
||||||
|
@ -76,11 +77,36 @@ IntEngEnter(PINTENG_ENTER_LEAVE EnterLeave,
|
||||||
EnterLeave->DestRect.bottom = BitmapSize.cy;
|
EnterLeave->DestRect.bottom = BitmapSize.cy;
|
||||||
SrcPoint.x = DestRect->left;
|
SrcPoint.x = DestRect->left;
|
||||||
SrcPoint.y = DestRect->top;
|
SrcPoint.y = DestRect->top;
|
||||||
|
ClippedDestRect = EnterLeave->DestRect;
|
||||||
|
if (SrcPoint.x < 0)
|
||||||
|
{
|
||||||
|
ClippedDestRect.left -= SrcPoint.x;
|
||||||
|
SrcPoint.x = 0;
|
||||||
|
}
|
||||||
|
if (DestObj->sizlBitmap.cx < SrcPoint.x + ClippedDestRect.right - ClippedDestRect.left)
|
||||||
|
{
|
||||||
|
ClippedDestRect.right = ClippedDestRect.left + DestObj->sizlBitmap.cx - SrcPoint.x;
|
||||||
|
}
|
||||||
|
if (SrcPoint.y < 0)
|
||||||
|
{
|
||||||
|
ClippedDestRect.top -= SrcPoint.y;
|
||||||
|
SrcPoint.y = 0;
|
||||||
|
}
|
||||||
|
if (DestObj->sizlBitmap.cy < SrcPoint.y + ClippedDestRect.bottom - ClippedDestRect.top)
|
||||||
|
{
|
||||||
|
ClippedDestRect.bottom = ClippedDestRect.top + DestObj->sizlBitmap.cy - SrcPoint.y;
|
||||||
|
}
|
||||||
EnterLeave->TrivialClipObj = EngCreateClip();
|
EnterLeave->TrivialClipObj = EngCreateClip();
|
||||||
EnterLeave->TrivialClipObj->iDComplexity = DC_TRIVIAL;
|
EnterLeave->TrivialClipObj->iDComplexity = DC_TRIVIAL;
|
||||||
if (! EnterLeave->DestGDI->CopyBits(*OutputObj, DestObj,
|
if (ClippedDestRect.left < (*OutputObj)->sizlBitmap.cx &&
|
||||||
|
0 <= ClippedDestRect.right &&
|
||||||
|
SrcPoint.x < DestObj->sizlBitmap.cx &&
|
||||||
|
ClippedDestRect.top <= (*OutputObj)->sizlBitmap.cy &&
|
||||||
|
0 <= ClippedDestRect.bottom &&
|
||||||
|
SrcPoint.y < DestObj->sizlBitmap.cy &&
|
||||||
|
! EnterLeave->DestGDI->CopyBits(*OutputObj, DestObj,
|
||||||
EnterLeave->TrivialClipObj, NULL,
|
EnterLeave->TrivialClipObj, NULL,
|
||||||
&EnterLeave->DestRect, &SrcPoint))
|
&ClippedDestRect, &SrcPoint))
|
||||||
{
|
{
|
||||||
EngDeleteClip(EnterLeave->TrivialClipObj);
|
EngDeleteClip(EnterLeave->TrivialClipObj);
|
||||||
EngFreeMem((*OutputObj)->pvBits);
|
EngFreeMem((*OutputObj)->pvBits);
|
||||||
|
@ -120,11 +146,41 @@ IntEngLeave(PINTENG_ENTER_LEAVE EnterLeave)
|
||||||
{
|
{
|
||||||
SrcPoint.x = 0;
|
SrcPoint.x = 0;
|
||||||
SrcPoint.y = 0;
|
SrcPoint.y = 0;
|
||||||
|
if (EnterLeave->DestRect.left < 0)
|
||||||
|
{
|
||||||
|
SrcPoint.x = - EnterLeave->DestRect.left;
|
||||||
|
EnterLeave->DestRect.left = 0;
|
||||||
|
}
|
||||||
|
if (EnterLeave->DestObj->sizlBitmap.cx < EnterLeave->DestRect.right)
|
||||||
|
{
|
||||||
|
EnterLeave->DestRect.right = EnterLeave->DestObj->sizlBitmap.cx;
|
||||||
|
}
|
||||||
|
if (EnterLeave->DestRect.top < 0)
|
||||||
|
{
|
||||||
|
SrcPoint.y = - EnterLeave->DestRect.top;
|
||||||
|
EnterLeave->DestRect.top = 0;
|
||||||
|
}
|
||||||
|
if (EnterLeave->DestObj->sizlBitmap.cy < EnterLeave->DestRect.bottom)
|
||||||
|
{
|
||||||
|
EnterLeave->DestRect.bottom = EnterLeave->DestObj->sizlBitmap.cy;
|
||||||
|
}
|
||||||
|
if (SrcPoint.x < EnterLeave->OutputObj->sizlBitmap.cx &&
|
||||||
|
EnterLeave->DestRect.left <= EnterLeave->DestRect.right &&
|
||||||
|
EnterLeave->DestRect.left < EnterLeave->DestObj->sizlBitmap.cx &&
|
||||||
|
SrcPoint.y < EnterLeave->OutputObj->sizlBitmap.cy &&
|
||||||
|
EnterLeave->DestRect.top <= EnterLeave->DestRect.bottom &&
|
||||||
|
EnterLeave->DestRect.top < EnterLeave->DestObj->sizlBitmap.cy)
|
||||||
|
{
|
||||||
Result = EnterLeave->DestGDI->CopyBits(EnterLeave->DestObj,
|
Result = EnterLeave->DestGDI->CopyBits(EnterLeave->DestObj,
|
||||||
EnterLeave->OutputObj,
|
EnterLeave->OutputObj,
|
||||||
EnterLeave->TrivialClipObj, NULL,
|
EnterLeave->TrivialClipObj, NULL,
|
||||||
&EnterLeave->DestRect, &SrcPoint);
|
&EnterLeave->DestRect, &SrcPoint);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Result = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
EngFreeMem(EnterLeave->OutputObj->pvBits);
|
EngFreeMem(EnterLeave->OutputObj->pvBits);
|
||||||
EngDeleteSurface(EnterLeave->OutputBitmap);
|
EngDeleteSurface(EnterLeave->OutputBitmap);
|
||||||
EngDeleteClip(EnterLeave->TrivialClipObj);
|
EngDeleteClip(EnterLeave->TrivialClipObj);
|
||||||
|
|
Loading…
Reference in a new issue