Unverified Commit 1664e105 authored by Mike Gabriel's avatar Mike Gabriel

Merge branch 'uli42-pr/simplify_pixmap' into 3.6.x

parents db74c07e bc42d11f
...@@ -99,11 +99,6 @@ struct nxagentPixmapPair ...@@ -99,11 +99,6 @@ struct nxagentPixmapPair
PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height,
int depth, unsigned usage_hint) int depth, unsigned usage_hint)
{ {
nxagentPrivPixmapPtr pPixmapPriv, pVirtualPriv;
PixmapPtr pPixmap;
PixmapPtr pVirtual;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "nxagentCreatePixmap: Creating pixmap with width [%d] " fprintf(stderr, "nxagentCreatePixmap: Creating pixmap with width [%d] "
"height [%d] depth [%d] and allocation hint [%d].\n", "height [%d] depth [%d] and allocation hint [%d].\n",
...@@ -111,11 +106,11 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, ...@@ -111,11 +106,11 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height,
#endif #endif
/* /*
* Create the pixmap structure but do * Create the pixmap structure but do not allocate memory for the
* not allocate memory for the data. * data.
*/ */
pPixmap = AllocatePixmap(pScreen, 0); PixmapPtr pPixmap = AllocatePixmap(pScreen, 0);
if (!pPixmap) if (!pPixmap)
{ {
...@@ -152,7 +147,7 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, ...@@ -152,7 +147,7 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height,
* Initialize the privates of the real picture. * Initialize the privates of the real picture.
*/ */
pPixmapPriv = nxagentPixmapPriv(pPixmap); nxagentPrivPixmapPtr pPixmapPriv = nxagentPixmapPriv(pPixmap);
pPixmapPriv -> isVirtual = False; pPixmapPriv -> isVirtual = False;
pPixmapPriv -> isShared = nxagentShmPixmapTrap; pPixmapPriv -> isShared = nxagentShmPixmapTrap;
...@@ -164,12 +159,7 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, ...@@ -164,12 +159,7 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height,
if (pPixmapPriv -> isShared == 1) if (pPixmapPriv -> isShared == 1)
{ {
BoxRec box; BoxRec box = { .x1 = 0, .y1 = 0, .x2 = width, .y2 = height };
box.x1 = 0;
box.y1 = 0;
box.x2 = width;
box.y2 = height;
pPixmapPriv -> corruptedRegion = RegionCreate(&box, 1); pPixmapPriv -> corruptedRegion = RegionCreate(&box, 1);
} }
...@@ -184,16 +174,13 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, ...@@ -184,16 +174,13 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height,
pPixmapPriv -> containTrapezoids = 0; pPixmapPriv -> containTrapezoids = 0;
/* /*
* The lazy encoding policy generally does * The lazy encoding policy generally does not send on remote X
* not send on remote X server the off-screen * server the off-screen images, by preferring to synchronize the
* images, by preferring to synchronize the * windows content. Anyway this behaviour may be inadvisable if a
* windows content. Anyway this behaviour may * pixmap is used, for example, for multiple copy areas on screen.
* be inadvisable if a pixmap is used, for * This counter serves the purpose, taking into account the number
* example, for multiple copy areas on screen. * of times the pixmap has been used as source for a deferred
* This counter serves the purpose, taking in- * operation.
* to account the number of times the pixmap
* has been used as source for a deferred
* operation.
*/ */
pPixmapPriv -> usageCounter = 0; pPixmapPriv -> usageCounter = 0;
...@@ -210,11 +197,10 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, ...@@ -210,11 +197,10 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height,
pPixmapPriv -> isBackingPixmap = 0; pPixmapPriv -> isBackingPixmap = 0;
/* /*
* Create the pixmap based on the default * Create the pixmap based on the default windows. The proxy knows
* windows. The proxy knows this and uses * this and uses this information to optimize encode the create
* this information to optimize encode the * pixmap message by including the id of the drawable in the
* create pixmap message by including the * checksum.
* id of the drawable in the checksum.
*/ */
if (width != 0 && height != 0 && nxagentGCTrap == 0) if (width != 0 && height != 0 && nxagentGCTrap == 0)
...@@ -245,7 +231,7 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, ...@@ -245,7 +231,7 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height,
* Create the pixmap in the virtual framebuffer. * Create the pixmap in the virtual framebuffer.
*/ */
pVirtual = fbCreatePixmap(pScreen, width, height, depth, usage_hint); PixmapPtr pVirtual = fbCreatePixmap(pScreen, width, height, depth, usage_hint);
if (pVirtual == NULL) if (pVirtual == NULL)
{ {
...@@ -261,7 +247,7 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, ...@@ -261,7 +247,7 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height,
} }
#ifdef TEST #ifdef TEST
fprintf(stderr,"nxagentCreatePixmap: Allocated memory for the Virtual %sPixmap %p of real Pixmap %p (%dx%d),", fprintf(stderr, "nxagentCreatePixmap: Allocated memory for the Virtual %sPixmap %p of real Pixmap %p (%dx%d),",
"allocation hint [%d].\n", "allocation hint [%d].\n",
nxagentShmPixmapTrap ? "Shm " : "", (void *) pVirtual, (void *) pPixmap, width, height, usage_hint); nxagentShmPixmapTrap ? "Shm " : "", (void *) pVirtual, (void *) pPixmap, width, height, usage_hint);
#endif #endif
...@@ -269,15 +255,14 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, ...@@ -269,15 +255,14 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height,
pPixmapPriv -> pVirtualPixmap = pVirtual; pPixmapPriv -> pVirtualPixmap = pVirtual;
/* /*
* Initialize the privates of the virtual picture. We * Initialize the privates of the virtual picture. We could avoid to
* could avoid to use a flag and just check the pointer * use a flag and just check the pointer to the virtual pixmap that,
* to the virtual pixmap that, if the pixmap is actually * if the pixmap is actually virtual, will be NULL. Unfortunately
* virtual, will be NULL. Unfortunately the flag can be * the flag can be changed in nxagentValidateGC(). That code should
* changed in nxagentValidateGC(). That code should be * be removed in future.
* removed in future.
*/ */
pVirtualPriv = nxagentPixmapPriv(pVirtual); nxagentPrivPixmapPtr pVirtualPriv = nxagentPixmapPriv(pVirtual);
pVirtualPriv -> isVirtual = True; pVirtualPriv -> isVirtual = True;
pVirtualPriv -> isShared = nxagentShmPixmapTrap; pVirtualPriv -> isShared = nxagentShmPixmapTrap;
...@@ -301,19 +286,17 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, ...@@ -301,19 +286,17 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height,
pVirtualPriv -> splitResource = NULL; pVirtualPriv -> splitResource = NULL;
/* /*
* We might distinguish real and virtual pixmaps by * We might distinguish real and virtual pixmaps by checking the
* checking the pointers to pVirtualPixmap. We should * pointers to pVirtualPixmap. We should also remove the copy of id
* also remove the copy of id and use the one of the * and use the one of the real pixmap.
* real pixmap.
*/ */
pVirtualPriv -> id = pPixmapPriv -> id; pVirtualPriv -> id = pPixmapPriv -> id;
pVirtualPriv -> mid = 0; pVirtualPriv -> mid = 0;
/* /*
* Storing a pointer back to the real pixmap is * Storing a pointer back to the real pixmap is silly. Unfortunately
* silly. Unfortunately this is the way it has * this is the way it has been originally implemented. See also the
* been originally implemented. See also the
* comment in destroy of the pixmap. * comment in destroy of the pixmap.
*/ */
...@@ -332,10 +315,6 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, ...@@ -332,10 +315,6 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height,
Bool nxagentDestroyPixmap(PixmapPtr pPixmap) Bool nxagentDestroyPixmap(PixmapPtr pPixmap)
{ {
PixmapPtr pVirtual;
nxagentPrivPixmapPtr pPixmapPriv;
if (!pPixmap) if (!pPixmap)
{ {
#ifdef PANIC #ifdef PANIC
...@@ -346,9 +325,9 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap) ...@@ -346,9 +325,9 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap)
return False; return False;
} }
pPixmapPriv = nxagentPixmapPriv(pPixmap); nxagentPrivPixmapPtr pPixmapPriv = nxagentPixmapPriv(pPixmap);
pVirtual = pPixmapPriv -> pVirtualPixmap; PixmapPtr pVirtual = pPixmapPriv -> pVirtualPixmap;
#ifdef TEST #ifdef TEST
fprintf(stderr, "nxagentDestroyPixmap: Destroying pixmap at [%p] with virtual at [%p].\n", fprintf(stderr, "nxagentDestroyPixmap: Destroying pixmap at [%p] with virtual at [%p].\n",
...@@ -357,16 +336,13 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap) ...@@ -357,16 +336,13 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap)
if (pPixmapPriv -> isVirtual) if (pPixmapPriv -> isVirtual)
{ {
int refcnt;
/* /*
* For some pixmaps we receive the destroy only for the * For some pixmaps we receive the destroy only for the
* virtual. Infact to draw in the framebuffer we can use * virtual. Infact to draw in the framebuffer we can use the
* the virtual pixmap instead of the pointer to the real * virtual pixmap instead of the pointer to the real one. As the
* one. As the virtual pixmap can collect references, we * virtual pixmap can collect references, we must transfer those
* must transfer those references to the real pixmap so * references to the real pixmap so we can continue as the destroy
* we can continue as the destroy had been requested for * had been requested for it.
* it.
*/ */
pVirtual = pPixmap; pVirtual = pPixmap;
...@@ -375,11 +351,11 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap) ...@@ -375,11 +351,11 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap)
pPixmapPriv = nxagentPixmapPriv(pPixmap); pPixmapPriv = nxagentPixmapPriv(pPixmap);
/* /*
* Move the references accumulated by the virtual * Move the references accumulated by the virtual pixmap into the
* pixmap into the references of the real one. * references of the real one.
*/ */
refcnt = pVirtual -> refcnt - 1; int refcnt = pVirtual -> refcnt - 1;
#ifdef TEST #ifdef TEST
fprintf(stderr, "nxagentDestroyPixmap: Adding [%d] references to pixmap at [%p].\n", fprintf(stderr, "nxagentDestroyPixmap: Adding [%d] references to pixmap at [%p].\n",
...@@ -412,7 +388,6 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap) ...@@ -412,7 +388,6 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap)
} }
#ifdef TEST #ifdef TEST
fprintf(stderr, "nxagentDestroyPixmap: Managing to destroy the pixmap at [%p]\n", fprintf(stderr, "nxagentDestroyPixmap: Managing to destroy the pixmap at [%p]\n",
(void *) pPixmap); (void *) pPixmap);
#endif #endif
...@@ -473,10 +448,7 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap) ...@@ -473,10 +448,7 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap)
Bool nxagentDestroyVirtualPixmap(PixmapPtr pPixmap) Bool nxagentDestroyVirtualPixmap(PixmapPtr pPixmap)
{ {
PixmapPtr pVirtual; PixmapPtr pVirtual = nxagentPixmapPriv(pPixmap) -> pVirtualPixmap;
nxagentPrivPixmapPtr pVirtualPriv;
pVirtual = nxagentPixmapPriv(pPixmap) -> pVirtualPixmap;
/* /*
* Force the routine to get rid of the virtual * Force the routine to get rid of the virtual
...@@ -487,7 +459,7 @@ Bool nxagentDestroyVirtualPixmap(PixmapPtr pPixmap) ...@@ -487,7 +459,7 @@ Bool nxagentDestroyVirtualPixmap(PixmapPtr pPixmap)
{ {
pVirtual -> refcnt = 1; pVirtual -> refcnt = 1;
pVirtualPriv = nxagentPixmapPriv(pVirtual); nxagentPrivPixmapPtr pVirtualPriv = nxagentPixmapPriv(pVirtual);
if (pVirtualPriv -> corruptedRegion != NullRegion) if (pVirtualPriv -> corruptedRegion != NullRegion)
{ {
...@@ -515,13 +487,10 @@ RegionPtr nxagentPixmapToRegion(PixmapPtr pPixmap) ...@@ -515,13 +487,10 @@ RegionPtr nxagentPixmapToRegion(PixmapPtr pPixmap)
Bool nxagentModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth, Bool nxagentModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth,
int bitsPerPixel, int devKind, void * pPixData) int bitsPerPixel, int devKind, void * pPixData)
{ {
PixmapPtr pVirtualPixmap;
/* /*
* See miModifyPixmapHeader() in miscrinit.c. This * See miModifyPixmapHeader() in miscrinit.c. This function is used
* function is used to recycle the scratch pixmap * to recycle the scratch pixmap for this screen. We let it refer to
* for this screen. We let it refer to the virtual * the virtual pixmap.
* pixmap.
*/ */
if (!pPixmap) if (!pPixmap)
...@@ -539,7 +508,7 @@ Bool nxagentModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int dep ...@@ -539,7 +508,7 @@ Bool nxagentModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int dep
FatalError("nxagentModifyPixmapHeader: PANIC! Pixmap is virtual."); FatalError("nxagentModifyPixmapHeader: PANIC! Pixmap is virtual.");
} }
pVirtualPixmap = nxagentVirtualPixmap(pPixmap); PixmapPtr pVirtualPixmap = nxagentVirtualPixmap(pPixmap);
#ifdef TEST #ifdef TEST
fprintf(stderr, "nxagentModifyPixmapHeader: Pixmap at [%p] Virtual at [%p].\n", fprintf(stderr, "nxagentModifyPixmapHeader: Pixmap at [%p] Virtual at [%p].\n",
...@@ -555,89 +524,18 @@ Bool nxagentModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int dep ...@@ -555,89 +524,18 @@ Bool nxagentModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int dep
bitsPerPixel, devKind, (void *) pPixData); bitsPerPixel, devKind, (void *) pPixData);
#endif #endif
if ((width > 0) && (height > 0) && (depth > 0) && /*
(bitsPerPixel > 0) && (devKind > 0) && pPixData) * ignore return code, because the only case where this will return
{ * FALSE is pPixmap == NULL, which we have already caught above.
pPixmap->drawable.depth = depth; */
pPixmap->drawable.bitsPerPixel = bitsPerPixel; miModifyPixmapHeader(pPixmap, width, height, depth, bitsPerPixel, devKind, pPixData);
pPixmap->drawable.id = 0; miModifyPixmapHeader(pVirtualPixmap, width, height, depth, bitsPerPixel, devKind, pPixData);
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pPixmap->drawable.x = 0;
pPixmap->drawable.y = 0;
pPixmap->drawable.width = width;
pPixmap->drawable.height = height;
pPixmap->devKind = devKind;
pPixmap->refcnt = 1;
pPixmap->devPrivate.ptr = pPixData;
pVirtualPixmap->drawable.depth = depth;
pVirtualPixmap->drawable.bitsPerPixel = bitsPerPixel;
pVirtualPixmap->drawable.id = 0;
pVirtualPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pVirtualPixmap->drawable.x = 0;
pVirtualPixmap->drawable.y = 0;
pVirtualPixmap->drawable.width = width;
pVirtualPixmap->drawable.height = height;
pVirtualPixmap->devKind = devKind;
pVirtualPixmap->refcnt = 1;
pVirtualPixmap->devPrivate.ptr = pPixData;
}
else
{
if (width > 0)
pPixmap->drawable.width = width;
if (height > 0)
pPixmap->drawable.height = height;
if (depth > 0)
pPixmap->drawable.depth = depth;
if (bitsPerPixel > 0)
pPixmap->drawable.bitsPerPixel = bitsPerPixel;
else if ((bitsPerPixel < 0) && (depth > 0))
pPixmap->drawable.bitsPerPixel = BitsPerPixel(depth);
if (devKind > 0)
pPixmap->devKind = devKind;
else if ((devKind < 0) && ((width > 0) || (depth > 0)))
pPixmap->devKind = PixmapBytePad(pPixmap->drawable.width,
pPixmap->drawable.depth);
if (pPixData)
pPixmap->devPrivate.ptr = pPixData;
/*
* XXX This was the previous assignment:
*
* pVirtualPixmap->devPrivate.ptr = pPixData;
*/
if (width > 0)
pVirtualPixmap->drawable.width = width;
if (height > 0)
pVirtualPixmap->drawable.height = height;
if (depth > 0)
pVirtualPixmap->drawable.depth = depth;
if (bitsPerPixel > 0)
pVirtualPixmap->drawable.bitsPerPixel = bitsPerPixel;
else if ((bitsPerPixel < 0) && (depth > 0))
pVirtualPixmap->drawable.bitsPerPixel = BitsPerPixel(depth);
if (devKind > 0)
pVirtualPixmap->devKind = devKind;
else if ((devKind < 0) && ((width > 0) || (depth > 0)))
pVirtualPixmap->devKind = PixmapBytePad(pVirtualPixmap->drawable.width,
pVirtualPixmap->drawable.depth);
if (pPixData) #ifdef PANIC
pVirtualPixmap->devPrivate.ptr = pPixData;
#ifdef PANIC
if (!((width > 0) && (height > 0) && (depth > 0) && (bitsPerPixel > 0) &&
(devKind > 0) && pPixData))
{
if (pPixmap->drawable.x != 0 || pPixmap->drawable.y != 0) if (pPixmap->drawable.x != 0 || pPixmap->drawable.y != 0)
{ {
fprintf(stderr, "nxagentModifyPixmapHeader: PANIC! Pixmap at [%p] has x [%d] and y [%d].\n", fprintf(stderr, "nxagentModifyPixmapHeader: PANIC! Pixmap at [%p] has x [%d] and y [%d].\n",
...@@ -645,9 +543,8 @@ Bool nxagentModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int dep ...@@ -645,9 +543,8 @@ Bool nxagentModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int dep
FatalError("nxagentModifyPixmapHeader: PANIC! Pixmap has x or y greater than zero."); FatalError("nxagentModifyPixmapHeader: PANIC! Pixmap has x or y greater than zero.");
} }
#endif
} }
#endif
return True; return True;
} }
...@@ -665,15 +562,15 @@ static void nxagentPixmapMatchID(void *p0, XID x1, void *p2) ...@@ -665,15 +562,15 @@ static void nxagentPixmapMatchID(void *p0, XID x1, void *p2)
PixmapPtr nxagentPixmapPtr(Pixmap pixmap) PixmapPtr nxagentPixmapPtr(Pixmap pixmap)
{ {
struct nxagentPixmapPair pair;
if (pixmap == None) if (pixmap == None)
{ {
return NULL; return NULL;
} }
pair.pixmap = pixmap; struct nxagentPixmapPair pair = {
pair.pMap = NULL; .pixmap = pixmap,
.pMap = NULL
};
FindClientResourcesByType(clients[serverClient -> index], RT_NX_PIXMAP, FindClientResourcesByType(clients[serverClient -> index], RT_NX_PIXMAP,
nxagentPixmapMatchID, &pair); nxagentPixmapMatchID, &pair);
...@@ -731,9 +628,7 @@ void nxagentDisconnectPixmap(void *p0, XID x1, void *p2) ...@@ -731,9 +628,7 @@ void nxagentDisconnectPixmap(void *p0, XID x1, void *p2)
PixmapPtr pPixmap = (PixmapPtr) p0; PixmapPtr pPixmap = (PixmapPtr) p0;
#ifdef TEST #ifdef TEST
Bool *pBool; Bool *pBool = (Bool*) p2;
pBool = (Bool*) p2;
fprintf(stderr, "nxagentDisconnectPixmap: Called with bool [%d] and pixmap at [%p].\n", fprintf(stderr, "nxagentDisconnectPixmap: Called with bool [%d] and pixmap at [%p].\n",
*pBool, (void *) pPixmap); *pBool, (void *) pPixmap);
...@@ -754,7 +649,6 @@ void nxagentDisconnectPixmap(void *p0, XID x1, void *p2) ...@@ -754,7 +649,6 @@ void nxagentDisconnectPixmap(void *p0, XID x1, void *p2)
Bool nxagentDisconnectAllPixmaps(void) Bool nxagentDisconnectAllPixmaps(void)
{ {
int i;
int r = 1; int r = 1;
#ifdef TEST #ifdef TEST
...@@ -762,15 +656,16 @@ Bool nxagentDisconnectAllPixmaps(void) ...@@ -762,15 +656,16 @@ Bool nxagentDisconnectAllPixmaps(void)
#endif #endif
/* /*
* The RT_NX_PIXMAP resource type is allocated * The RT_NX_PIXMAP resource type is allocated only on the server
* only on the server client, so we don't need * client, so we don't need to find it through the other clients
* to find it through the other clients too. * too.
*/ */
FindClientResourcesByType(clients[serverClient -> index], RT_NX_PIXMAP, nxagentDisconnectPixmap, &r); FindClientResourcesByType(clients[serverClient -> index], RT_NX_PIXMAP, nxagentDisconnectPixmap, &r);
#ifdef WARNING #ifdef WARNING
/* Note: nxagentDisconnectPixmap() does not modify r - so this check can never succeed */
if (r == 0) if (r == 0)
{ {
fprintf(stderr, "nxagentDisconnectAllPixmaps: WARNING! Failed to disconnect " fprintf(stderr, "nxagentDisconnectAllPixmaps: WARNING! Failed to disconnect "
...@@ -779,7 +674,7 @@ Bool nxagentDisconnectAllPixmaps(void) ...@@ -779,7 +674,7 @@ Bool nxagentDisconnectAllPixmaps(void)
#endif #endif
for (i = 0, r = 1; i < MAXCLIENTS; r = 1, i++) for (int i = 0, r = 1; i < MAXCLIENTS; r = 1, i++)
{ {
if (clients[i]) if (clients[i])
{ {
...@@ -791,6 +686,7 @@ Bool nxagentDisconnectAllPixmaps(void) ...@@ -791,6 +686,7 @@ Bool nxagentDisconnectAllPixmaps(void)
#ifdef WARNING #ifdef WARNING
/* Note: nxagentDisconnectPixmap() does not modify r - so this check can never succeed */
if (r == 0) if (r == 0)
{ {
fprintf(stderr, "nxagentDisconnectAllPixmaps: WARNING! Failed to disconnect " fprintf(stderr, "nxagentDisconnectAllPixmaps: WARNING! Failed to disconnect "
...@@ -801,16 +697,6 @@ Bool nxagentDisconnectAllPixmaps(void) ...@@ -801,16 +697,6 @@ Bool nxagentDisconnectAllPixmaps(void)
} }
} }
#ifdef WARNING
if (r == 0)
{
fprintf(stderr, "nxagentDisconnectAllPixmaps: WARNING! Failed to disconnect "
"pixmap for client [%d].\n", i);
}
#endif
#ifdef TEST #ifdef TEST
fprintf(stderr, "nxagentDisconnectAllPixmaps: Pixmaps disconnection completed.\n"); fprintf(stderr, "nxagentDisconnectAllPixmaps: Pixmaps disconnection completed.\n");
#endif #endif
...@@ -822,7 +708,6 @@ void nxagentReconnectPixmap(void *p0, XID x1, void *p2) ...@@ -822,7 +708,6 @@ void nxagentReconnectPixmap(void *p0, XID x1, void *p2)
{ {
PixmapPtr pPixmap = (PixmapPtr) p0; PixmapPtr pPixmap = (PixmapPtr) p0;
Bool *pBool = (Bool*) p2; Bool *pBool = (Bool*) p2;
nxagentPrivPixmapPtr pPixmapPriv;
if (!*pBool || pPixmap == NULL || if (!*pBool || pPixmap == NULL ||
NXDisplayError(nxagentDisplay) == 1) NXDisplayError(nxagentDisplay) == 1)
...@@ -839,9 +724,8 @@ void nxagentReconnectPixmap(void *p0, XID x1, void *p2) ...@@ -839,9 +724,8 @@ void nxagentReconnectPixmap(void *p0, XID x1, void *p2)
else if (pPixmap == nxagentDefaultScreen -> pScratchPixmap) else if (pPixmap == nxagentDefaultScreen -> pScratchPixmap)
{ {
/* /*
* Every time the scratch pixmap is used its * Every time the scratch pixmap is used its data is changed, so
* data is changed, so we don't need to recon- * we don't need to reconnect it.
* nect it.
*/ */
#ifdef TEST #ifdef TEST
...@@ -861,7 +745,7 @@ void nxagentReconnectPixmap(void *p0, XID x1, void *p2) ...@@ -861,7 +745,7 @@ void nxagentReconnectPixmap(void *p0, XID x1, void *p2)
(void *) nxagentPixmapPriv(pPixmap) -> pPicture); (void *) nxagentPixmapPriv(pPixmap) -> pPicture);
#endif #endif
pPixmapPriv = nxagentPixmapPriv(pPixmap); nxagentPrivPixmapPtr pPixmapPriv = nxagentPixmapPriv(pPixmap);
if (pPixmap -> drawable.width && pPixmap -> drawable.height) if (pPixmap -> drawable.width && pPixmap -> drawable.height)
{ {
...@@ -936,9 +820,9 @@ Bool nxagentReconnectAllPixmaps(void *p0) ...@@ -936,9 +820,9 @@ Bool nxagentReconnectAllPixmaps(void *p0)
nxagentResetAlphaCache(); nxagentResetAlphaCache();
/* /*
* The RT_NX_PIXMAP resource type is allocated * The RT_NX_PIXMAP resource type is allocated only on the server
* only on the server client, so we don't need * client, so we don't need to find it through the other clients
* to find it through the other clients too. * too.
*/ */
FindClientResourcesByType(clients[serverClient -> index], RT_NX_PIXMAP, nxagentReconnectPixmap, &result); FindClientResourcesByType(clients[serverClient -> index], RT_NX_PIXMAP, nxagentReconnectPixmap, &result);
...@@ -962,11 +846,10 @@ Bool nxagentReconnectAllPixmaps(void *p0) ...@@ -962,11 +846,10 @@ Bool nxagentReconnectAllPixmaps(void *p0)
#endif #endif
/* /*
* Let the pixmap be reconnected as it was an * Let the pixmap be reconnected as it was an image request
* image request issued by the client owning * issued by the client owning the resource. The client index is
* the resource. The client index is used as * used as a subscript by the image routines to cache the data
* a subscript by the image routines to cache * per-client.
* the data per-client.
*/ */
FindClientResourcesByType(clients[i], RT_PIXMAP, nxagentReconnectPixmap, &result); FindClientResourcesByType(clients[i], RT_PIXMAP, nxagentReconnectPixmap, &result);
...@@ -1028,30 +911,26 @@ static void nxagentCheckOnePixmapIntegrity(void *p0, XID x1, void *p2) ...@@ -1028,30 +911,26 @@ static void nxagentCheckOnePixmapIntegrity(void *p0, XID x1, void *p2)
Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap) Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap)
{ {
Bool integrity = True; Bool integrity = True;
XImage *image;
char *data;
int format;
unsigned long plane_mask = AllPlanes; unsigned long plane_mask = AllPlanes;
unsigned int width, height, length, depth;
PixmapPtr pVirtual = nxagentVirtualPixmap(pPixmap); PixmapPtr pVirtual = nxagentVirtualPixmap(pPixmap);
width = pPixmap -> drawable.width; unsigned int width = pPixmap -> drawable.width;
height = pPixmap -> drawable.height; unsigned int height = pPixmap -> drawable.height;
depth = pPixmap -> drawable.depth; unsigned int depth = pPixmap -> drawable.depth;
format = (depth == 1) ? XYPixmap : ZPixmap; int format = (depth == 1) ? XYPixmap : ZPixmap;
if (width && height) if (width && height)
{ {
length = nxagentImageLength(width, height, format, 0, depth); unsigned int length = nxagentImageLength(width, height, format, 0, depth);
data = malloc(length); char *data = malloc(length);
if (data == NULL) if (data == NULL)
{ {
FatalError("nxagentCheckPixmapIntegrity: Failed to allocate a buffer of size %d.\n", length); FatalError("nxagentCheckPixmapIntegrity: Failed to allocate a buffer of size %d.\n", length);
} }
image = XGetImage(nxagentDisplay, nxagentPixmap(pPixmap), 0, 0, XImage *image = XGetImage(nxagentDisplay, nxagentPixmap(pPixmap), 0, 0,
width, height, plane_mask, format); width, height, plane_mask, format);
if (image == NULL) if (image == NULL)
{ {
...@@ -1099,10 +978,10 @@ Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap) ...@@ -1099,10 +978,10 @@ Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap)
if (!integrity) if (!integrity)
{ {
char *p = image -> data;
char *q = data;
char *p, *q; for (int i = 0; i < length; i++)
for (int i = 0, p = image -> data, q = data; i < length; i++)
{ {
if (p[i] != q[i]) if (p[i] != q[i])
{ {
...@@ -1179,14 +1058,6 @@ Bool nxagentCheckAllPixmapIntegrity(void) ...@@ -1179,14 +1058,6 @@ Bool nxagentCheckAllPixmapIntegrity(void)
void nxagentSynchronizeShmPixmap(DrawablePtr pDrawable, int xPict, int yPict, void nxagentSynchronizeShmPixmap(DrawablePtr pDrawable, int xPict, int yPict,
int wPict, int hPict) int wPict, int hPict)
{ {
GCPtr pGC;
char *data;
int width, height;
int depth, length, format;
CARD32 attributes[3];
int saveTrap;
if (pDrawable -> type == DRAWABLE_PIXMAP && if (pDrawable -> type == DRAWABLE_PIXMAP &&
nxagentIsShmPixmap((PixmapPtr) pDrawable) == 1) nxagentIsShmPixmap((PixmapPtr) pDrawable) == 1)
{ {
...@@ -1195,7 +1066,9 @@ void nxagentSynchronizeShmPixmap(DrawablePtr pDrawable, int xPict, int yPict, ...@@ -1195,7 +1066,9 @@ void nxagentSynchronizeShmPixmap(DrawablePtr pDrawable, int xPict, int yPict,
(void *) pDrawable); (void *) pDrawable);
#endif #endif
pGC = nxagentGetScratchGC(pDrawable -> depth, pDrawable -> pScreen); GCPtr pGC = nxagentGetScratchGC(pDrawable -> depth, pDrawable -> pScreen);
CARD32 attributes[3];
attributes[0] = 0x228b22; attributes[0] = 0x228b22;
attributes[1] = 0xffffff; attributes[1] = 0xffffff;
...@@ -1205,16 +1078,16 @@ void nxagentSynchronizeShmPixmap(DrawablePtr pDrawable, int xPict, int yPict, ...@@ -1205,16 +1078,16 @@ void nxagentSynchronizeShmPixmap(DrawablePtr pDrawable, int xPict, int yPict,
ValidateGC(pDrawable, pGC); ValidateGC(pDrawable, pGC);
width = (wPict != 0 && wPict <= pDrawable -> width) ? wPict : pDrawable -> width; int width = (wPict != 0 && wPict <= pDrawable -> width) ? wPict : pDrawable -> width;
height = (hPict != 0 && hPict <= pDrawable -> height) ? hPict : pDrawable -> height; int height = (hPict != 0 && hPict <= pDrawable -> height) ? hPict : pDrawable -> height;
depth = pDrawable -> depth; int depth = pDrawable -> depth;
format = (depth == 1) ? XYPixmap : ZPixmap; int format = (depth == 1) ? XYPixmap : ZPixmap;
length = nxagentImageLength(width, height, format, 0, depth); int length = nxagentImageLength(width, height, format, 0, depth);
saveTrap = nxagentGCTrap; int saveTrap = nxagentGCTrap;
nxagentGCTrap = 0; nxagentGCTrap = 0;
...@@ -1222,7 +1095,9 @@ void nxagentSynchronizeShmPixmap(DrawablePtr pDrawable, int xPict, int yPict, ...@@ -1222,7 +1095,9 @@ void nxagentSynchronizeShmPixmap(DrawablePtr pDrawable, int xPict, int yPict,
nxagentFBTrap = 1; nxagentFBTrap = 1;
if ((data = malloc(length)) != NULL) char *data = malloc(length);
if (data)
{ {
fbGetImage(nxagentVirtualDrawable(pDrawable), xPict, yPict, fbGetImage(nxagentVirtualDrawable(pDrawable), xPict, yPict,
width, height, format, 0xffffffff, data); width, height, format, 0xffffffff, data);
...@@ -1270,13 +1145,6 @@ Bool nxagentPixmapOnShadowDisplay(PixmapPtr pMap) ...@@ -1270,13 +1145,6 @@ Bool nxagentPixmapOnShadowDisplay(PixmapPtr pMap)
static int length; static int length;
static unsigned int format; static unsigned int format;
XlibGC gc;
XGCValues value;
XImage *image;
Visual *pVisual;
char *data = NULL;
if (init) if (init)
{ {
if (pMap == NULL) if (pMap == NULL)
...@@ -1344,7 +1212,9 @@ FIXME: If the pixmap has a different depth from the window, the ...@@ -1344,7 +1212,9 @@ FIXME: If the pixmap has a different depth from the window, the
length = nxagentImageLength(width, height, format, 0, depth); length = nxagentImageLength(width, height, format, 0, depth);
if ((data = malloc(length)) == NULL) char * data = malloc(length);
if (data == NULL)
{ {
#ifdef WARNING #ifdef WARNING
fprintf(stderr, "nxagentPixmapOnShadowDisplay: WARNING! Failed to allocate memory for the operation.\n"); fprintf(stderr, "nxagentPixmapOnShadowDisplay: WARNING! Failed to allocate memory for the operation.\n");
...@@ -1356,7 +1226,7 @@ FIXME: If the pixmap has a different depth from the window, the ...@@ -1356,7 +1226,7 @@ FIXME: If the pixmap has a different depth from the window, the
fbGetImage((DrawablePtr) nxagentVirtualPixmap(pPixmap), 0, 0, fbGetImage((DrawablePtr) nxagentVirtualPixmap(pPixmap), 0, 0,
width, height, format, AllPlanes, data); width, height, format, AllPlanes, data);
pVisual = nxagentImageVisual((DrawablePtr) pPixmap, depth); Visual *pVisual = nxagentImageVisual((DrawablePtr) pPixmap, depth);
if (pVisual == NULL) if (pVisual == NULL)
{ {
...@@ -1367,10 +1237,10 @@ FIXME: If the pixmap has a different depth from the window, the ...@@ -1367,10 +1237,10 @@ FIXME: If the pixmap has a different depth from the window, the
pVisual = nxagentVisuals[nxagentDefaultVisualIndex].visual; pVisual = nxagentVisuals[nxagentDefaultVisualIndex].visual;
} }
image = XCreateImage(nxagentDisplay, pVisual, XImage *image = XCreateImage(nxagentDisplay, pVisual,
depth, format, 0, (char *) data, depth, format, 0, (char *) data,
width, height, BitmapPad(nxagentDisplay), width, height, BitmapPad(nxagentDisplay),
nxagentImagePad(width, format, 0, depth)); nxagentImagePad(width, format, 0, depth));
if (image == NULL) if (image == NULL)
{ {
...@@ -1383,13 +1253,15 @@ FIXME: If the pixmap has a different depth from the window, the ...@@ -1383,13 +1253,15 @@ FIXME: If the pixmap has a different depth from the window, the
return False; return False;
} }
value.foreground = 0xff0000; XGCValues value = {
value.background = 0x000000; .foreground = 0xff0000,
value.plane_mask = 0xffffff; .background = 0x000000,
value.fill_style = FillSolid; .plane_mask = 0xffffff,
.fill_style = FillSolid
};
gc = XCreateGC(shadow, win, GCBackground | XlibGC gc = XCreateGC(shadow, win, GCBackground |
GCForeground | GCFillStyle | GCPlaneMask, &value); GCForeground | GCFillStyle | GCPlaneMask, &value);
NXCleanImage(image); NXCleanImage(image);
...@@ -1413,15 +1285,7 @@ Bool nxagentFbOnShadowDisplay(void) ...@@ -1413,15 +1285,7 @@ Bool nxagentFbOnShadowDisplay(void)
static int showTime; static int showTime;
static int prevWidth, prevHeight; static int prevWidth, prevHeight;
XlibGC gc;
XGCValues value;
XImage *image;
Visual *pVisual;
WindowPtr pWin = screenInfo.screens[0]->root; WindowPtr pWin = screenInfo.screens[0]->root;
unsigned int format;
int depth, width, height, length;
char *data = NULL;
if (pWin == NULL) if (pWin == NULL)
{ {
...@@ -1432,10 +1296,10 @@ Bool nxagentFbOnShadowDisplay(void) ...@@ -1432,10 +1296,10 @@ Bool nxagentFbOnShadowDisplay(void)
return False; return False;
} }
depth = pWin -> drawable.depth; int depth = pWin -> drawable.depth;
width = pWin -> drawable.width; int width = pWin -> drawable.width;
height = pWin -> drawable.height; int height = pWin -> drawable.height;
format = (depth == 1) ? XYPixmap : ZPixmap; unsigned int format = (depth == 1) ? XYPixmap : ZPixmap;
if (init) if (init)
{ {
...@@ -1491,19 +1355,22 @@ Bool nxagentFbOnShadowDisplay(void) ...@@ -1491,19 +1355,22 @@ Bool nxagentFbOnShadowDisplay(void)
if (prevWidth != width || prevHeight != height) if (prevWidth != width || prevHeight != height)
{ {
XWindowChanges values;
prevWidth = width; prevWidth = width;
prevHeight = height; prevHeight = height;
values.width = width; XWindowChanges values = {
values.height = height; .width = width,
.height = height
};
XConfigureWindow(shadow, win, CWWidth | CWHeight, &values); XConfigureWindow(shadow, win, CWWidth | CWHeight, &values);
} }
length = nxagentImageLength(width, height, format, 0, depth); int length = nxagentImageLength(width, height, format, 0, depth);
if ((data = malloc(length)) == NULL) char *data = malloc(length);
if (data == NULL)
{ {
#ifdef WARNING #ifdef WARNING
fprintf(stderr, "nxagentFbOnShadowDisplay: WARNING! Failed to allocate memory for the operation.\n"); fprintf(stderr, "nxagentFbOnShadowDisplay: WARNING! Failed to allocate memory for the operation.\n");
...@@ -1515,7 +1382,7 @@ Bool nxagentFbOnShadowDisplay(void) ...@@ -1515,7 +1382,7 @@ Bool nxagentFbOnShadowDisplay(void)
fbGetImage((DrawablePtr)pWin, 0, 0, fbGetImage((DrawablePtr)pWin, 0, 0,
width, height, format, AllPlanes, data); width, height, format, AllPlanes, data);
pVisual = nxagentImageVisual((DrawablePtr) pWin, depth); Visual *pVisual = nxagentImageVisual((DrawablePtr) pWin, depth);
if (pVisual == NULL) if (pVisual == NULL)
{ {
...@@ -1526,10 +1393,10 @@ Bool nxagentFbOnShadowDisplay(void) ...@@ -1526,10 +1393,10 @@ Bool nxagentFbOnShadowDisplay(void)
pVisual = nxagentVisuals[nxagentDefaultVisualIndex].visual; pVisual = nxagentVisuals[nxagentDefaultVisualIndex].visual;
} }
image = XCreateImage(nxagentDisplay, pVisual, XImage *image = XCreateImage(nxagentDisplay, pVisual,
depth, format, 0, (char *) data, depth, format, 0, (char *) data,
width, height, BitmapPad(nxagentDisplay), width, height, BitmapPad(nxagentDisplay),
nxagentImagePad(width, format, 0, depth)); nxagentImagePad(width, format, 0, depth));
if (image == NULL) if (image == NULL)
{ {
...@@ -1542,13 +1409,15 @@ Bool nxagentFbOnShadowDisplay(void) ...@@ -1542,13 +1409,15 @@ Bool nxagentFbOnShadowDisplay(void)
return False; return False;
} }
value.foreground = 0xff0000; XGCValues value = {
value.background = 0x000000; .foreground = 0xff0000,
value.plane_mask = 0xffffff; .background = 0x000000,
value.fill_style = FillSolid; .plane_mask = 0xffffff,
.fill_style = FillSolid
};
gc = XCreateGC(shadow, win, GCBackground | XlibGC gc = XCreateGC(shadow, win, GCBackground |
GCForeground | GCFillStyle | GCPlaneMask, &value); GCForeground | GCFillStyle | GCPlaneMask, &value);
NXCleanImage(image); NXCleanImage(image);
...@@ -1589,14 +1458,14 @@ void nxagentPrintResourcePredicate(void *value, XID id, XID type, void *cdata) ...@@ -1589,14 +1458,14 @@ void nxagentPrintResourcePredicate(void *value, XID id, XID type, void *cdata)
void nxagentPrintResources(void) void nxagentPrintResources(void)
{ {
Bool result;
nxagentPrintResourceTypes(); nxagentPrintResourceTypes();
for (int i = 0; i < MAXCLIENTS; i++) for (int i = 0; i < MAXCLIENTS; i++)
{ {
if (clients[i]) if (clients[i])
{ {
Bool result;
fprintf(stderr, "nxagentPrintResources: Printing resources for client [%d]:\n", fprintf(stderr, "nxagentPrintResources: Printing resources for client [%d]:\n",
i); i);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment