diff options
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Drawable.c')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Drawable.c | 98 |
1 files changed, 58 insertions, 40 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Drawable.c b/nx-X11/programs/Xserver/hw/nxagent/Drawable.c index 2c1b07fa5..75057097a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Drawable.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Drawable.c @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ /* */ /* NXAGENT, NX protocol compression and NX extensions to this software */ /* are copyright of NoMachine. Redistribution and use of the present */ @@ -9,7 +9,7 @@ /* */ /* Check http://www.nomachine.com/licensing.html for applicability. */ /* */ -/* NX and NoMachine are trademarks of NoMachine S.r.l. */ +/* NX and NoMachine are trademarks of Medialogic S.p.A. */ /* */ /* All rights reserved. */ /* */ @@ -32,6 +32,7 @@ #include "Handlers.h" #include "Pixels.h" #include "Reconnect.h" +#include "GCOps.h" #include "NXlib.h" @@ -418,13 +419,14 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned if (useStoredBitmap != 0) { #ifdef TEST - fprintf(stderr, "nxagentSynchronizeRegion: Drawable [%s] at [%p] has a synchronization bitmap " + fprintf(stderr, "nxagentSynchronizeRegion: Drawable [%s] at [%p] has a synchronization bitmap at [%p] " "[%d,%d,%d,%d] with [%ld] rects.\n", nxagentDrawableType(pDrawable), - (void *) pDrawable, nxagentCorruptedRegion((DrawablePtr) nxagentDrawableBitmap(pDrawable)) -> extents.x1, - nxagentCorruptedRegion((DrawablePtr) nxagentDrawableBitmap(pDrawable)) -> extents.y1, - nxagentCorruptedRegion((DrawablePtr) nxagentDrawableBitmap(pDrawable)) -> extents.x2, - nxagentCorruptedRegion((DrawablePtr) nxagentDrawableBitmap(pDrawable)) -> extents.y2, - REGION_NUM_RECTS(nxagentCorruptedRegion((DrawablePtr) nxagentDrawableBitmap(pDrawable)))); + (void *) pDrawable, (void *) nxagentDrawableBitmap(pDrawable), + nxagentCorruptedRegion((DrawablePtr) nxagentDrawableBitmap(pDrawable)) -> extents.x1, + nxagentCorruptedRegion((DrawablePtr) nxagentDrawableBitmap(pDrawable)) -> extents.y1, + nxagentCorruptedRegion((DrawablePtr) nxagentDrawableBitmap(pDrawable)) -> extents.x2, + nxagentCorruptedRegion((DrawablePtr) nxagentDrawableBitmap(pDrawable)) -> extents.y2, + REGION_NUM_RECTS(nxagentCorruptedRegion((DrawablePtr) nxagentDrawableBitmap(pDrawable)))); #endif clipRegion = nxagentCreateRegion(pDrawable, NULL, 0, 0, pDrawable -> width, pDrawable -> height); @@ -581,8 +583,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned #ifdef TEST fprintf(stderr, "nxagentSynchronizeRegion: Going to synchronize [%ld] rects of [%s] at [%p].\n", - REGION_NUM_RECTS(clipRegion), (pDrawable -> type == DRAWABLE_PIXMAP ? "Pixmap" : "Window"), - (void *) pDrawable); + REGION_NUM_RECTS(clipRegion), nxagentDrawableType(pDrawable), (void *) pDrawable); fprintf(stderr, "nxagentSynchronizeRegion: Extents geometry [%d,%d,%d,%d].\n", clipRegion -> extents.x1, clipRegion -> extents.y1, clipRegion -> extents.x2, clipRegion -> extents.y2); @@ -615,7 +616,22 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned if (data == NULL) { #ifdef WARNING + fprintf(stderr, "nxagentSynchronizeRegion: WARNING! Failed to allocate memory for synchronization.\n"); + + /* + * Print detailed informations if the + * image length is zero. + */ + + if (length == 0) + { + fprintf(stderr, "nxagentSynchronizeRegion: Drawable [%s] at [%p] with region geometry [%ld][%d,%d,%d,%d].\n", + nxagentDrawableType(pDrawable), (void *) pDrawable, REGION_NUM_RECTS(clipRegion), + clipRegion -> extents.x1, clipRegion -> extents.y1, + clipRegion -> extents.x2, clipRegion -> extents.y2); + } + #endif goto nxagentSynchronizeRegionFree; @@ -670,10 +686,14 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned if (nxagentDrawableStatus(pDrawable) == Synchronized) { #ifdef WARNING + if (pDrawable -> type == DRAWABLE_WINDOW && pSrcDrawable != pDrawable) + { fprintf(stderr, "nxagentSynchronizeRegion: WARNING! Trying to synchronize " "the clean drawable type [%d] at [%p] with source at [%p].\n", pDrawable -> type, (void *) pDrawable, (void *) pSrcDrawable); + } + #endif goto nxagentSynchronizeRegionStop; @@ -748,9 +768,6 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned nxagentGetImage(pSrcDrawable, x, y, w, h, format, AllPlanes, data); - nxagentRealizeImage(pDrawable, pGC, pDrawable -> depth, - x, y, w, h, leftPad, format, data); - /* * Going to unmark the synchronized * region. @@ -805,6 +822,13 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned nxagentUnmarkCorruptedRegion(pDrawable, &tileRegion); } + #ifdef TEST + else + { + fprintf(stderr, "nxagentSynchronizeRegion: Tile [%d,%d,%d,%d] on drawable [%p] doesn't match.\n", + x, y, x + w, y + h, (void *) pDrawable); + } + #endif } else { @@ -835,6 +859,14 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned } } + /* + * Realize the image after comparing the + * source data with the bitmap data. + */ + + nxagentRealizeImage(pDrawable, pGC, pDrawable -> depth, + x, y, w, h, leftPad, format, data); + REGION_UNINIT(pDrawable -> pScreen, &tileRegion); #if !defined(COLLECTED_UPDATES) @@ -2555,16 +2587,13 @@ void nxagentCreateDrawableBitmap(DrawablePtr pDrawable) GCPtr pGC = NULL; RegionPtr pClipRegion = NullRegion; - char *data = NULL; - int x, y; int w, h; - int length, format; int saveTrap; #ifdef TEST - fprintf(stderr, "nxagentCreateDrawableBitmap: Creating synchronization bitmap for drawable at [%p].\n", - (void *) pDrawable); + fprintf(stderr, "nxagentCreateDrawableBitmap: Creating synchronization bitmap for [%s] at [%p].\n", + nxagentDrawableType(pDrawable), (void *) pDrawable); #endif /* @@ -2652,24 +2681,8 @@ void nxagentCreateDrawableBitmap(DrawablePtr pDrawable) w = pClipRegion -> extents.x2 - pClipRegion -> extents.x1; h = pClipRegion -> extents.y2 - pClipRegion -> extents.y1; - data = nxagentAllocateImageData(w, h, pDrawable -> depth, &length, &format); - - if (data == NULL) - { - #ifdef WARNING - fprintf(stderr, "nxagentCreateDrawableBitmap: Cannot allocate memory for the bitmap data.\n"); - #endif - - nxagentDestroyPixmap(pBitmap); + nxagentCopyArea(pDrawable, (DrawablePtr) pBitmap, pGC, x, y, w, h, x, y); - goto nxagentCreateDrawableBitmapEnd; - } - - nxagentGetImage(pDrawable, x, y, w, h, format, AllPlanes, data); - - nxagentPutImage((DrawablePtr) pBitmap, pGC, pBitmap -> drawable.depth, x, y, w, h, - 0, format, data); - REGION_UNION(pDrawable -> pScreen, nxagentCorruptedRegion((DrawablePtr) pBitmap), nxagentCorruptedRegion((DrawablePtr) pBitmap), pClipRegion); @@ -2711,11 +2724,6 @@ nxagentCreateDrawableBitmapEnd: nxagentFreeRegion(pDrawable, pClipRegion); } - if (data != NULL) - { - xfree(data); - } - if (pGC != NULL) { FreeScratchGC(pGC); @@ -3091,6 +3099,16 @@ void nxagentSendBackgroundExpose(WindowPtr pWin, PixmapPtr pBackground, RegionPt REGION_INTERSECT(pWin -> pScreen, &expose, &expose, &pWin -> clipList); + /* + * Reduce the overall region to expose. + */ + + REGION_TRANSLATE(pWin -> pScreen, &expose, -pWin -> drawable.x, -pWin -> drawable.y); + + REGION_SUBTRACT(pWin -> pScreen, pExpose, pExpose, &expose); + + REGION_TRANSLATE(pWin -> pScreen, &expose, pWin -> drawable.x, pWin -> drawable.y); + miWindowExposures(pWin, &expose, &expose); nxagentSendBackgroundExposeEnd: |