Handle empty changes for every operation

It seems like many of the X11 operations can end up with no pixels
actually changing. So instead of discovering and adding workarounds for
each individually we'll just check very region added if it's empty.
This commit is contained in:
Pierre Ossman 2020-04-20 08:55:13 +02:00 committed by Lauri Kasanen
parent a4e0dbf7db
commit a00e40c340

View File

@ -388,6 +388,8 @@ static inline void add_changed(ScreenPtr pScreen, RegionPtr reg)
vncHooksScreenPtr vncHooksScreen = vncHooksScreenPrivate(pScreen);
if (vncHooksScreen->ignoreHooks)
return;
if (REGION_NIL(reg))
return;
vncAddChanged(pScreen->myNum,
(const struct UpdateRect*)REGION_EXTENTS(pScreen, reg),
REGION_NUM_RECTS(reg),
@ -400,6 +402,8 @@ static inline void add_copied(ScreenPtr pScreen, RegionPtr dst,
vncHooksScreenPtr vncHooksScreen = vncHooksScreenPrivate(pScreen);
if (vncHooksScreen->ignoreHooks)
return;
if (REGION_NIL(dst))
return;
vncAddCopied(pScreen->myNum,
(const struct UpdateRect*)REGION_EXTENTS(pScreen, dst),
REGION_NUM_RECTS(dst),
@ -562,8 +566,7 @@ static void vncHooksCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
(*pScreen->CopyWindow) (pWin, ptOldOrg, pOldRegion);
if (REGION_NOTEMPTY(pScreen, &copied))
add_copied(pScreen, &copied, dx, dy);
add_copied(pScreen, &copied, dx, dy);
REGION_UNINIT(pScreen, &copied);
REGION_UNINIT(pScreen, &screen_rgn);
@ -807,8 +810,7 @@ static void vncHooksComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask,
(*ps->Composite)(op, pSrc, pMask, pDst, xSrc, ySrc,
xMask, yMask, xDst, yDst, width, height);
if (REGION_NOTEMPTY(pScreen, &changed))
add_changed(pScreen, &changed);
add_changed(pScreen, &changed);
REGION_UNINIT(pScreen, &changed);
@ -896,8 +898,7 @@ static void vncHooksGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
(*ps->Glyphs)(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlists, lists, glyphs);
if (REGION_NOTEMPTY(pScreen, changed))
add_changed(pScreen, changed);
add_changed(pScreen, changed);
REGION_DESTROY(pScreen, changed);
@ -919,8 +920,7 @@ static void vncHooksCompositeRects(CARD8 op, PicturePtr pDst,
(*ps->CompositeRects)(op, pDst, color, nRect, rects);
if (REGION_NOTEMPTY(pScreen, changed))
add_changed(pScreen, changed);
add_changed(pScreen, changed);
REGION_DESTROY(pScreen, changed);
@ -987,8 +987,7 @@ static void vncHooksTrapezoids(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
(*ps->Trapezoids)(op, pSrc, pDst, maskFormat, xSrc, ySrc, ntrap, traps);
if (REGION_NOTEMPTY(pScreen, &changed))
add_changed(pScreen, &changed);
add_changed(pScreen, &changed);
REGION_UNINIT(pScreen, &changed);
@ -1053,8 +1052,7 @@ static void vncHooksTriangles(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
(*ps->Triangles)(op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris);
if (REGION_NOTEMPTY(pScreen, &changed))
add_changed(pScreen, &changed);
add_changed(pScreen, &changed);
REGION_UNINIT(pScreen, &changed);
@ -1114,8 +1112,7 @@ static void vncHooksTriStrip(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
(*ps->TriStrip)(op, pSrc, pDst, maskFormat, xSrc, ySrc, npoint, points);
if (REGION_NOTEMPTY(pScreen, &changed))
add_changed(pScreen, &changed);
add_changed(pScreen, &changed);
REGION_UNINIT(pScreen, &changed);
@ -1173,8 +1170,7 @@ static void vncHooksTriFan(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
(*ps->TriFan)(op, pSrc, pDst, maskFormat, xSrc, ySrc, npoint, points);
if (REGION_NOTEMPTY(pScreen, &changed))
add_changed(pScreen, &changed);
add_changed(pScreen, &changed);
REGION_UNINIT(pScreen, &changed);
@ -1495,13 +1491,11 @@ static RegionPtr vncHooksCopyArea(DrawablePtr pSrc, DrawablePtr pDst,
ret = (*pGC->ops->CopyArea) (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty);
if (REGION_NOTEMPTY(pScreen, &dst))
add_copied(pGC->pScreen, &dst,
dstx + pDst->x - srcx - pSrc->x,
dsty + pDst->y - srcy - pSrc->y);
add_copied(pGC->pScreen, &dst,
dstx + pDst->x - srcx - pSrc->x,
dsty + pDst->y - srcy - pSrc->y);
if (REGION_NOTEMPTY(pScreen, &changed))
add_changed(pGC->pScreen, &changed);
add_changed(pGC->pScreen, &changed);
REGION_UNINIT(pGC->pScreen, &dst);
REGION_UNINIT(pGC->pScreen, &src);