From d4a1074ff7b757553757b7fe86adf3a0a737f640 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Fri, 1 May 2020 15:37:22 +0200 Subject: [PATCH] Avoid using RegionInit() because of empty rects It creates an invalid region if given an empty rect. Fortunately RegionInitBoxes() handles that just fine, so use that instead. --- unix/xserver/hw/vnc/vncHooks.c | 52 +++++++++++++++++----------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/unix/xserver/hw/vnc/vncHooks.c b/unix/xserver/hw/vnc/vncHooks.c index 1b6e48b8..f631941b 100644 --- a/unix/xserver/hw/vnc/vncHooks.c +++ b/unix/xserver/hw/vnc/vncHooks.c @@ -486,7 +486,7 @@ static void vncHooksCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, screen_box.x2 = pScreen->width; screen_box.y2 = pScreen->height; - RegionInit(&screen_rgn, &screen_box, 1); + RegionInitBoxes(&screen_rgn, &screen_box, 1); dx = pWin->drawable.x - ptOldOrg.x; dy = pWin->drawable.y - ptOldOrg.y; @@ -526,7 +526,7 @@ static void vncHooksClearToBackground(WindowPtr pWin, int x, int y, int w, box.x2 = w ? (box.x1 + w) : (pWin->drawable.x + pWin->drawable.width); box.y2 = h ? (box.y1 + h) : (pWin->drawable.y + pWin->drawable.height); - RegionInit(®, &box, 0); + RegionInitBoxes(®, &box, 1); RegionIntersect(®, ®, &pWin->clipList); (*pScreen->ClearToBackground) (pWin, x, y, w, h, generateExposures); @@ -690,13 +690,13 @@ static void vncHooksComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, box.y1 = max(pDst->pDrawable->y + yDst, 0); box.x2 = box.x1 + width; box.y2 = box.y1 + height; - RegionInit(&changed, &box, 0); + RegionInitBoxes(&changed, &box, 1); box.x1 = 0; box.y1 = 0; box.x2 = pScreen->width; box.y2 = pScreen->height; - RegionInit(&fbreg, &box, 0); + RegionInitBoxes(&fbreg, &box, 1); RegionIntersect(&changed, &changed, &fbreg); @@ -800,7 +800,7 @@ static void vncHooksGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, fbbox.y1 = 0; fbbox.x2 = pScreen->width; fbbox.y2 = pScreen->height; - RegionInit(&fbreg, &fbbox, 0); + RegionInitBoxes(&fbreg, &fbbox, 1); RegionIntersect(changed, changed, &fbreg); @@ -883,13 +883,13 @@ static void vncHooksTrapezoids(CARD8 op, PicturePtr pSrc, PicturePtr pDst, box.y1 += pDst->pDrawable->y; box.x2 += pDst->pDrawable->x; box.y2 += pDst->pDrawable->y; - RegionInit(&changed, &box, 0); + RegionInitBoxes(&changed, &box, 1); box.x1 = 0; box.y1 = 0; box.x2 = pScreen->width; box.y2 = pScreen->height; - RegionInit(&fbreg, &box, 0); + RegionInitBoxes(&fbreg, &box, 1); RegionIntersect(&changed, &changed, &fbreg); @@ -948,13 +948,13 @@ static void vncHooksTriangles(CARD8 op, PicturePtr pSrc, PicturePtr pDst, box.y1 += pDst->pDrawable->y; box.x2 += pDst->pDrawable->x; box.y2 += pDst->pDrawable->y; - RegionInit(&changed, &box, 0); + RegionInitBoxes(&changed, &box, 1); box.x1 = 0; box.y1 = 0; box.x2 = pScreen->width; box.y2 = pScreen->height; - RegionInit(&fbreg, &box, 0); + RegionInitBoxes(&fbreg, &box, 1); RegionIntersect(&changed, &changed, &fbreg); @@ -1006,13 +1006,13 @@ static void vncHooksTriStrip(CARD8 op, PicturePtr pSrc, PicturePtr pDst, box.y1 += pDst->pDrawable->y; box.x2 += pDst->pDrawable->x; box.y2 += pDst->pDrawable->y; - RegionInit(&changed, &box, 0); + RegionInitBoxes(&changed, &box, 1); box.x1 = 0; box.y1 = 0; box.x2 = pScreen->width; box.y2 = pScreen->height; - RegionInit(&fbreg, &box, 0); + RegionInitBoxes(&fbreg, &box, 1); RegionIntersect(&changed, &changed, &fbreg); @@ -1064,13 +1064,13 @@ static void vncHooksTriFan(CARD8 op, PicturePtr pSrc, PicturePtr pDst, box.y1 += pDst->pDrawable->y; box.x2 += pDst->pDrawable->x; box.y2 += pDst->pDrawable->y; - RegionInit(&changed, &box, 0); + RegionInitBoxes(&changed, &box, 1); box.x1 = 0; box.y1 = 0; box.x2 = pScreen->width; box.y2 = pScreen->height; - RegionInit(&fbreg, &box, 0); + RegionInitBoxes(&fbreg, &box, 1); RegionIntersect(&changed, &changed, &fbreg); @@ -1318,7 +1318,7 @@ static void vncHooksPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, box.x2 = box.x1 + w; box.y2 = box.y1 + h; - RegionInit(®, &box, 0); + RegionInitBoxes(®, &box, 1); RegionIntersect(®, ®, pGC->pCompositeClip); (*pGC->ops->PutImage) (pDrawable, pGC, depth, x, y, w, h, leftPad, format, @@ -1356,7 +1356,7 @@ static RegionPtr vncHooksCopyArea(DrawablePtr pSrc, DrawablePtr pDst, box.x2 = box.x1 + w; box.y2 = box.y1 + h; - RegionInit(&dst, &box, 0); + RegionInitBoxes(&dst, &box, 1); } RegionIntersect(&dst, &dst, pGC->pCompositeClip); @@ -1370,7 +1370,7 @@ static RegionPtr vncHooksCopyArea(DrawablePtr pSrc, DrawablePtr pDst, box.x2 = box.x1 + w; box.y2 = box.y1 + h; - RegionInit(&src, &box, 0); + RegionInitBoxes(&src, &box, 1); if ((pSrc->type == DRAWABLE_WINDOW) && RegionNotEmpty(&((WindowPtr)pSrc)->clipList)) { @@ -1426,7 +1426,7 @@ static RegionPtr vncHooksCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, box.x2 = box.x1 + w; box.y2 = box.y1 + h; - RegionInit(®, &box, 0); + RegionInitBoxes(®, &box, 1); RegionIntersect(®, ®, pGC->pCompositeClip); ret = (*pGC->ops->CopyPlane) (pSrc, pDst, pGC, srcx, srcy, w, h, @@ -1490,7 +1490,7 @@ static void vncHooksPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, box.x2 = maxX + 1 + pDrawable->x; box.y2 = maxY + 1 + pDrawable->y; - RegionInit(®, &box, 0); + RegionInitBoxes(®, &box, 1); RegionIntersect(®, ®, pGC->pCompositeClip); (*pGC->ops->PolyPoint) (pDrawable, pGC, mode, npt, pts); @@ -1929,7 +1929,7 @@ static void vncHooksFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape, box.x2 = maxX + 1 + pDrawable->x; box.y2 = maxY + 1 + pDrawable->y; - RegionInit(®, &box, 0); + RegionInitBoxes(®, &box, 1); RegionIntersect(®, ®, pGC->pCompositeClip); (*pGC->ops->FillPolygon) (pDrawable, pGC, shape, mode, count, pts); @@ -2121,7 +2121,7 @@ static int vncHooksPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, GetTextBoundingRect(pDrawable, pGC->font, x, y, count, &box); - RegionInit(®, &box, 0); + RegionInitBoxes(®, &box, 1); RegionIntersect(®, ®, pGC->pCompositeClip); ret = (*pGC->ops->PolyText8) (pDrawable, pGC, x, y, count, chars); @@ -2155,7 +2155,7 @@ static int vncHooksPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, GetTextBoundingRect(pDrawable, pGC->font, x, y, count, &box); - RegionInit(®, &box, 0); + RegionInitBoxes(®, &box, 1); RegionIntersect(®, ®, pGC->pCompositeClip); ret = (*pGC->ops->PolyText16) (pDrawable, pGC, x, y, count, chars); @@ -2188,7 +2188,7 @@ static void vncHooksImageText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, GetTextBoundingRect(pDrawable, pGC->font, x, y, count, &box); - RegionInit(®, &box, 0); + RegionInitBoxes(®, &box, 1); RegionIntersect(®, ®, pGC->pCompositeClip); (*pGC->ops->ImageText8) (pDrawable, pGC, x, y, count, chars); @@ -2219,7 +2219,7 @@ static void vncHooksImageText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, GetTextBoundingRect(pDrawable, pGC->font, x, y, count, &box); - RegionInit(®, &box, 0); + RegionInitBoxes(®, &box, 1); RegionIntersect(®, ®, pGC->pCompositeClip); (*pGC->ops->ImageText16) (pDrawable, pGC, x, y, count, chars); @@ -2251,7 +2251,7 @@ static void vncHooksImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, GetTextBoundingRect(pDrawable, pGC->font, x, y, nglyph, &box); - RegionInit(®, &box, 0); + RegionInitBoxes(®, &box, 1); RegionIntersect(®, ®, pGC->pCompositeClip); (*pGC->ops->ImageGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); @@ -2283,7 +2283,7 @@ static void vncHooksPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, GetTextBoundingRect(pDrawable, pGC->font, x, y, nglyph, &box); - RegionInit(®, &box, 0); + RegionInitBoxes(®, &box, 1); RegionIntersect(®, ®, pGC->pCompositeClip); (*pGC->ops->PolyGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); @@ -2313,7 +2313,7 @@ static void vncHooksPushPixels(GCPtr pGC, PixmapPtr pBitMap, box.x2 = box.x1 + w; box.y2 = box.y1 + h; - RegionInit(®, &box, 0); + RegionInitBoxes(®, &box, 1); RegionIntersect(®, ®, pGC->pCompositeClip); (*pGC->ops->PushPixels) (pGC, pBitMap, pDrawable, w, h, x, y); -- 2.39.5