From 22914447019845ba3ba238e5814b59939e744f19 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Mon, 10 Oct 2011 17:58:56 +0200 Subject: Imported nxagent-3.3.0-18.tar.gz Summary: Imported nxagent-3.3.0-18.tar.gz Keywords: Imported nxagent-3.3.0-18.tar.gz into Git repository --- nx-X11/programs/Xserver/hw/nxagent/GCOps.c | 87 ++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) (limited to 'nx-X11/programs/Xserver/hw/nxagent/GCOps.c') diff --git a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c index 83aa04f11..9afd6e392 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c +++ b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c @@ -594,6 +594,8 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, unsigned int format; unsigned long planeMask = 0xffffffff; + int oldDstxyValue; + RegionPtr pDstRegion; int skip = 0; @@ -605,6 +607,91 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, (void *) pDstDrawable, srcx, srcy, dstx, dsty, width, height); #endif + /* + * Here, before using fbDoCopy() called by fbCopyArea(), + * it should be provided that the cast in fbDoCopy() from + * int to short int would not cut off significative bits. + */ + + if (dstx + pDstDrawable->x + width > 32767) + { + #ifdef WARNING + fprintf(stderr, "nxagentCopyArea: x2 exceeding short int.\n"); + #endif + + width = 32767 - dstx - pDstDrawable->x; + + if (width <= 0) + { + #ifdef TEST + fprintf(stderr, "nxagentCopyArea: Returning null on x2 check.\n"); + #endif + + return NullRegion; + } + } + + if (dstx + pDstDrawable->x < -32768) + { + #ifdef WARNING + fprintf(stderr, "nxagentCopyArea: x1 exceeding short int.\n"); + #endif + + width += pDstDrawable->x + dstx + 32768; + srcx -= pDstDrawable->x + dstx + 32768; + dstx = -32768 - pDstDrawable->x; + + if (width <= 0) + { + #ifdef TEST + fprintf(stderr, "nxagentCopyArea: Returning null on x1 check.\n"); + #endif + + return NullRegion; + } + } + + oldDstxyValue = dsty; + + if (dsty + pDstDrawable->y + height > 32767) + { + #ifdef WARNING + fprintf(stderr, "nxagentCopyArea: y2 exceeding short int.\n"); + #endif + + height = 32767 - dsty - pDstDrawable->y; + + if (height <= 0) + { + #ifdef TEST + fprintf(stderr, "nxagentCopyArea: Returning null on y2 check.\n"); + #endif + + return NullRegion; + } + } + + if (dsty + pDstDrawable->y < -32768) + { + #ifdef WARNING + fprintf(stderr, "nxagentCopyArea: y1 exceeding short int.\n"); + #endif + + height += 32768 + pDstDrawable->y + dsty; + srcy -= 32768 + pDstDrawable->y + dsty; + dsty = -32768 - pDstDrawable->y; + + if (height <= 0) + { + #ifdef TEST + fprintf(stderr, "nxagentCopyArea: Returning null on y1 check.\n"); + #endif + + return NullRegion; + } + } + + if (nxagentGCTrap == 1 || nxagentShmTrap == 1) { if (pSrcDrawable -> type == DRAWABLE_PIXMAP && -- cgit v1.2.3