From 0535c49cac55d931c9d5b4178db050e6f6e543cf Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 11 Jun 2019 23:46:20 +0200 Subject: Pixmap.c: call miModifyPixmapHeader twice instead of duplicating code --- nx-X11/programs/Xserver/hw/nxagent/Pixmap.c | 94 ++++------------------------- 1 file changed, 11 insertions(+), 83 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c index f8241d4d7..371678d0e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c @@ -555,89 +555,18 @@ Bool nxagentModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int dep bitsPerPixel, devKind, (void *) pPixData); #endif - if ((width > 0) && (height > 0) && (depth > 0) && - (bitsPerPixel > 0) && (devKind > 0) && pPixData) - { - pPixmap->drawable.depth = depth; - pPixmap->drawable.bitsPerPixel = bitsPerPixel; - pPixmap->drawable.id = 0; - 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); + /* + * ignore return code, because the only case where this will return + * FALSE is pPixmap == NULL, which we have already caught above. + */ + miModifyPixmapHeader(pPixmap, width, height, depth, bitsPerPixel, devKind, pPixData); + miModifyPixmapHeader(pVirtualPixmap, width, height, depth, bitsPerPixel, devKind, pPixData); - if (pPixData) - pVirtualPixmap->devPrivate.ptr = pPixData; - - #ifdef PANIC + #ifdef PANIC + if (!((width > 0) && (height > 0) && (depth > 0) && (bitsPerPixel > 0) && + (devKind > 0) && pPixData)) + { if (pPixmap->drawable.x != 0 || pPixmap->drawable.y != 0) { fprintf(stderr, "nxagentModifyPixmapHeader: PANIC! Pixmap at [%p] has x [%d] and y [%d].\n", @@ -645,9 +574,8 @@ Bool nxagentModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int dep FatalError("nxagentModifyPixmapHeader: PANIC! Pixmap has x or y greater than zero."); } - - #endif } + #endif return True; } -- cgit v1.2.3 From 6c44480deab3380bb7278a74319bbc8c6d0e6359 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 29 Oct 2019 01:13:34 +0100 Subject: Pixmap.c: drop code that does not make sense This check has already been done before we reach here. Also add some comments about a condition that will never occur... --- nx-X11/programs/Xserver/hw/nxagent/Pixmap.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c index 371678d0e..5358bd37e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c @@ -699,6 +699,7 @@ Bool nxagentDisconnectAllPixmaps(void) #ifdef WARNING + /* Note: nxagentDisconnectPixmap() does not modify r - so this check can never succeed */ if (r == 0) { fprintf(stderr, "nxagentDisconnectAllPixmaps: WARNING! Failed to disconnect " @@ -719,6 +720,7 @@ Bool nxagentDisconnectAllPixmaps(void) #ifdef WARNING + /* Note: nxagentDisconnectPixmap() does not modify r - so this check can never succeed */ if (r == 0) { fprintf(stderr, "nxagentDisconnectAllPixmaps: WARNING! Failed to disconnect " @@ -729,16 +731,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 fprintf(stderr, "nxagentDisconnectAllPixmaps: Pixmaps disconnection completed.\n"); #endif -- cgit v1.2.3 From ec1aac45ee55458bf243e305aefe1d0ba3f3b258 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 29 Oct 2019 01:12:01 +0100 Subject: Pixmap.c: scope improvements --- nx-X11/programs/Xserver/hw/nxagent/Pixmap.c | 211 ++++++++++++---------------- 1 file changed, 86 insertions(+), 125 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c index 5358bd37e..b3f8572e8 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c @@ -99,11 +99,6 @@ struct nxagentPixmapPair PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, int depth, unsigned usage_hint) { - nxagentPrivPixmapPtr pPixmapPriv, pVirtualPriv; - - PixmapPtr pPixmap; - PixmapPtr pVirtual; - #ifdef DEBUG fprintf(stderr, "nxagentCreatePixmap: Creating pixmap with width [%d] " "height [%d] depth [%d] and allocation hint [%d].\n", @@ -115,7 +110,7 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, * not allocate memory for the data. */ - pPixmap = AllocatePixmap(pScreen, 0); + PixmapPtr pPixmap = AllocatePixmap(pScreen, 0); if (!pPixmap) { @@ -152,7 +147,7 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, * Initialize the privates of the real picture. */ - pPixmapPriv = nxagentPixmapPriv(pPixmap); + nxagentPrivPixmapPtr pPixmapPriv = nxagentPixmapPriv(pPixmap); pPixmapPriv -> isVirtual = False; pPixmapPriv -> isShared = nxagentShmPixmapTrap; @@ -164,12 +159,7 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, if (pPixmapPriv -> isShared == 1) { - BoxRec box; - - box.x1 = 0; - box.y1 = 0; - box.x2 = width; - box.y2 = height; + BoxRec box = { .x1 = 0, .y1 = 0, .x2 = width, .y2 = height }; pPixmapPriv -> corruptedRegion = RegionCreate(&box, 1); } @@ -245,7 +235,7 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, * 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) { @@ -277,7 +267,7 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, * removed in future. */ - pVirtualPriv = nxagentPixmapPriv(pVirtual); + nxagentPrivPixmapPtr pVirtualPriv = nxagentPixmapPriv(pVirtual); pVirtualPriv -> isVirtual = True; pVirtualPriv -> isShared = nxagentShmPixmapTrap; @@ -332,10 +322,6 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, Bool nxagentDestroyPixmap(PixmapPtr pPixmap) { - PixmapPtr pVirtual; - - nxagentPrivPixmapPtr pPixmapPriv; - if (!pPixmap) { #ifdef PANIC @@ -346,9 +332,9 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap) return False; } - pPixmapPriv = nxagentPixmapPriv(pPixmap); + nxagentPrivPixmapPtr pPixmapPriv = nxagentPixmapPriv(pPixmap); - pVirtual = pPixmapPriv -> pVirtualPixmap; + PixmapPtr pVirtual = pPixmapPriv -> pVirtualPixmap; #ifdef TEST fprintf(stderr, "nxagentDestroyPixmap: Destroying pixmap at [%p] with virtual at [%p].\n", @@ -357,8 +343,6 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap) if (pPixmapPriv -> isVirtual) { - int refcnt; - /* * For some pixmaps we receive the destroy only for the * virtual. Infact to draw in the framebuffer we can use @@ -375,11 +359,11 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap) pPixmapPriv = nxagentPixmapPriv(pPixmap); /* - * Move the references accumulated by the virtual - * pixmap into the references of the real one. + * Move the references accumulated by the virtual pixmap into the + * references of the real one. */ - refcnt = pVirtual -> refcnt - 1; + int refcnt = pVirtual -> refcnt - 1; #ifdef TEST fprintf(stderr, "nxagentDestroyPixmap: Adding [%d] references to pixmap at [%p].\n", @@ -473,10 +457,7 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap) Bool nxagentDestroyVirtualPixmap(PixmapPtr pPixmap) { - PixmapPtr pVirtual; - nxagentPrivPixmapPtr pVirtualPriv; - - pVirtual = nxagentPixmapPriv(pPixmap) -> pVirtualPixmap; + PixmapPtr pVirtual = nxagentPixmapPriv(pPixmap) -> pVirtualPixmap; /* * Force the routine to get rid of the virtual @@ -487,7 +468,7 @@ Bool nxagentDestroyVirtualPixmap(PixmapPtr pPixmap) { pVirtual -> refcnt = 1; - pVirtualPriv = nxagentPixmapPriv(pVirtual); + nxagentPrivPixmapPtr pVirtualPriv = nxagentPixmapPriv(pVirtual); if (pVirtualPriv -> corruptedRegion != NullRegion) { @@ -515,8 +496,6 @@ RegionPtr nxagentPixmapToRegion(PixmapPtr pPixmap) Bool nxagentModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth, int bitsPerPixel, int devKind, void * pPixData) { - PixmapPtr pVirtualPixmap; - /* * See miModifyPixmapHeader() in miscrinit.c. This * function is used to recycle the scratch pixmap @@ -539,7 +518,7 @@ Bool nxagentModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int dep FatalError("nxagentModifyPixmapHeader: PANIC! Pixmap is virtual."); } - pVirtualPixmap = nxagentVirtualPixmap(pPixmap); + PixmapPtr pVirtualPixmap = nxagentVirtualPixmap(pPixmap); #ifdef TEST fprintf(stderr, "nxagentModifyPixmapHeader: Pixmap at [%p] Virtual at [%p].\n", @@ -593,15 +572,15 @@ static void nxagentPixmapMatchID(void *p0, XID x1, void *p2) PixmapPtr nxagentPixmapPtr(Pixmap pixmap) { - struct nxagentPixmapPair pair; - if (pixmap == None) { return NULL; } - pair.pixmap = pixmap; - pair.pMap = NULL; + struct nxagentPixmapPair pair = { + .pixmap = pixmap, + .pMap = NULL + }; FindClientResourcesByType(clients[serverClient -> index], RT_NX_PIXMAP, nxagentPixmapMatchID, &pair); @@ -659,9 +638,7 @@ void nxagentDisconnectPixmap(void *p0, XID x1, void *p2) PixmapPtr pPixmap = (PixmapPtr) p0; #ifdef TEST - Bool *pBool; - - pBool = (Bool*) p2; + Bool *pBool = (Bool*) p2; fprintf(stderr, "nxagentDisconnectPixmap: Called with bool [%d] and pixmap at [%p].\n", *pBool, (void *) pPixmap); @@ -682,7 +659,6 @@ void nxagentDisconnectPixmap(void *p0, XID x1, void *p2) Bool nxagentDisconnectAllPixmaps(void) { - int i; int r = 1; #ifdef TEST @@ -708,7 +684,7 @@ Bool nxagentDisconnectAllPixmaps(void) #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]) { @@ -742,7 +718,6 @@ void nxagentReconnectPixmap(void *p0, XID x1, void *p2) { PixmapPtr pPixmap = (PixmapPtr) p0; Bool *pBool = (Bool*) p2; - nxagentPrivPixmapPtr pPixmapPriv; if (!*pBool || pPixmap == NULL || NXDisplayError(nxagentDisplay) == 1) @@ -781,7 +756,7 @@ void nxagentReconnectPixmap(void *p0, XID x1, void *p2) (void *) nxagentPixmapPriv(pPixmap) -> pPicture); #endif - pPixmapPriv = nxagentPixmapPriv(pPixmap); + nxagentPrivPixmapPtr pPixmapPriv = nxagentPixmapPriv(pPixmap); if (pPixmap -> drawable.width && pPixmap -> drawable.height) { @@ -948,30 +923,26 @@ static void nxagentCheckOnePixmapIntegrity(void *p0, XID x1, void *p2) Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap) { Bool integrity = True; - XImage *image; - char *data; - int format; unsigned long plane_mask = AllPlanes; - unsigned int width, height, length, depth; PixmapPtr pVirtual = nxagentVirtualPixmap(pPixmap); - width = pPixmap -> drawable.width; - height = pPixmap -> drawable.height; - depth = pPixmap -> drawable.depth; - format = (depth == 1) ? XYPixmap : ZPixmap; + unsigned int width = pPixmap -> drawable.width; + unsigned int height = pPixmap -> drawable.height; + unsigned int depth = pPixmap -> drawable.depth; + int format = (depth == 1) ? XYPixmap : ZPixmap; 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) { 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); if (image == NULL) { @@ -1019,10 +990,10 @@ Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap) if (!integrity) { + char *p = image -> data; + char *q = data; - char *p, *q; - - for (int i = 0, p = image -> data, q = data; i < length; i++) + for (int i = 0; i < length; i++) { if (p[i] != q[i]) { @@ -1099,14 +1070,6 @@ Bool nxagentCheckAllPixmapIntegrity(void) void nxagentSynchronizeShmPixmap(DrawablePtr pDrawable, int xPict, int yPict, 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 && nxagentIsShmPixmap((PixmapPtr) pDrawable) == 1) { @@ -1115,7 +1078,9 @@ void nxagentSynchronizeShmPixmap(DrawablePtr pDrawable, int xPict, int yPict, (void *) pDrawable); #endif - pGC = nxagentGetScratchGC(pDrawable -> depth, pDrawable -> pScreen); + GCPtr pGC = nxagentGetScratchGC(pDrawable -> depth, pDrawable -> pScreen); + + CARD32 attributes[3]; attributes[0] = 0x228b22; attributes[1] = 0xffffff; @@ -1125,16 +1090,16 @@ void nxagentSynchronizeShmPixmap(DrawablePtr pDrawable, int xPict, int yPict, ValidateGC(pDrawable, pGC); - width = (wPict != 0 && wPict <= pDrawable -> width) ? wPict : pDrawable -> width; - height = (hPict != 0 && hPict <= pDrawable -> height) ? hPict : pDrawable -> height; + int width = (wPict != 0 && wPict <= pDrawable -> width) ? wPict : pDrawable -> width; + 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; @@ -1142,7 +1107,9 @@ void nxagentSynchronizeShmPixmap(DrawablePtr pDrawable, int xPict, int yPict, nxagentFBTrap = 1; - if ((data = malloc(length)) != NULL) + char *data = malloc(length); + + if (data) { fbGetImage(nxagentVirtualDrawable(pDrawable), xPict, yPict, width, height, format, 0xffffffff, data); @@ -1190,13 +1157,6 @@ Bool nxagentPixmapOnShadowDisplay(PixmapPtr pMap) static int length; static unsigned int format; - XlibGC gc; - XGCValues value; - XImage *image; - Visual *pVisual; - char *data = NULL; - - if (init) { if (pMap == NULL) @@ -1264,7 +1224,9 @@ FIXME: If the pixmap has a different depth from the window, the length = nxagentImageLength(width, height, format, 0, depth); - if ((data = malloc(length)) == NULL) + char * data = malloc(length); + + if (data == NULL) { #ifdef WARNING fprintf(stderr, "nxagentPixmapOnShadowDisplay: WARNING! Failed to allocate memory for the operation.\n"); @@ -1276,7 +1238,7 @@ FIXME: If the pixmap has a different depth from the window, the fbGetImage((DrawablePtr) nxagentVirtualPixmap(pPixmap), 0, 0, width, height, format, AllPlanes, data); - pVisual = nxagentImageVisual((DrawablePtr) pPixmap, depth); + Visual *pVisual = nxagentImageVisual((DrawablePtr) pPixmap, depth); if (pVisual == NULL) { @@ -1287,10 +1249,10 @@ FIXME: If the pixmap has a different depth from the window, the pVisual = nxagentVisuals[nxagentDefaultVisualIndex].visual; } - image = XCreateImage(nxagentDisplay, pVisual, - depth, format, 0, (char *) data, - width, height, BitmapPad(nxagentDisplay), - nxagentImagePad(width, format, 0, depth)); + XImage *image = XCreateImage(nxagentDisplay, pVisual, + depth, format, 0, (char *) data, + width, height, BitmapPad(nxagentDisplay), + nxagentImagePad(width, format, 0, depth)); if (image == NULL) { @@ -1303,13 +1265,15 @@ FIXME: If the pixmap has a different depth from the window, the return False; } - value.foreground = 0xff0000; - value.background = 0x000000; - value.plane_mask = 0xffffff; - value.fill_style = FillSolid; + XGCValues value = { + .foreground = 0xff0000, + .background = 0x000000, + .plane_mask = 0xffffff, + .fill_style = FillSolid + }; - gc = XCreateGC(shadow, win, GCBackground | - GCForeground | GCFillStyle | GCPlaneMask, &value); + XlibGC gc = XCreateGC(shadow, win, GCBackground | + GCForeground | GCFillStyle | GCPlaneMask, &value); NXCleanImage(image); @@ -1333,15 +1297,7 @@ Bool nxagentFbOnShadowDisplay(void) static int showTime; static int prevWidth, prevHeight; - XlibGC gc; - XGCValues value; - XImage *image; - Visual *pVisual; WindowPtr pWin = screenInfo.screens[0]->root; - unsigned int format; - int depth, width, height, length; - char *data = NULL; - if (pWin == NULL) { @@ -1352,10 +1308,10 @@ Bool nxagentFbOnShadowDisplay(void) return False; } - depth = pWin -> drawable.depth; - width = pWin -> drawable.width; - height = pWin -> drawable.height; - format = (depth == 1) ? XYPixmap : ZPixmap; + int depth = pWin -> drawable.depth; + int width = pWin -> drawable.width; + int height = pWin -> drawable.height; + unsigned int format = (depth == 1) ? XYPixmap : ZPixmap; if (init) { @@ -1411,19 +1367,22 @@ Bool nxagentFbOnShadowDisplay(void) if (prevWidth != width || prevHeight != height) { - XWindowChanges values; - prevWidth = width; prevHeight = height; - values.width = width; - values.height = height; + XWindowChanges values = { + .width = width, + .height = height + }; + 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 fprintf(stderr, "nxagentFbOnShadowDisplay: WARNING! Failed to allocate memory for the operation.\n"); @@ -1435,7 +1394,7 @@ Bool nxagentFbOnShadowDisplay(void) fbGetImage((DrawablePtr)pWin, 0, 0, width, height, format, AllPlanes, data); - pVisual = nxagentImageVisual((DrawablePtr) pWin, depth); + Visual *pVisual = nxagentImageVisual((DrawablePtr) pWin, depth); if (pVisual == NULL) { @@ -1446,10 +1405,10 @@ Bool nxagentFbOnShadowDisplay(void) pVisual = nxagentVisuals[nxagentDefaultVisualIndex].visual; } - image = XCreateImage(nxagentDisplay, pVisual, - depth, format, 0, (char *) data, - width, height, BitmapPad(nxagentDisplay), - nxagentImagePad(width, format, 0, depth)); + XImage *image = XCreateImage(nxagentDisplay, pVisual, + depth, format, 0, (char *) data, + width, height, BitmapPad(nxagentDisplay), + nxagentImagePad(width, format, 0, depth)); if (image == NULL) { @@ -1462,13 +1421,15 @@ Bool nxagentFbOnShadowDisplay(void) return False; } - value.foreground = 0xff0000; - value.background = 0x000000; - value.plane_mask = 0xffffff; - value.fill_style = FillSolid; + XGCValues value = { + .foreground = 0xff0000, + .background = 0x000000, + .plane_mask = 0xffffff, + .fill_style = FillSolid + }; - gc = XCreateGC(shadow, win, GCBackground | - GCForeground | GCFillStyle | GCPlaneMask, &value); + XlibGC gc = XCreateGC(shadow, win, GCBackground | + GCForeground | GCFillStyle | GCPlaneMask, &value); NXCleanImage(image); @@ -1509,14 +1470,14 @@ void nxagentPrintResourcePredicate(void *value, XID id, XID type, void *cdata) void nxagentPrintResources(void) { - Bool result; - nxagentPrintResourceTypes(); for (int i = 0; i < MAXCLIENTS; i++) { if (clients[i]) { + Bool result; + fprintf(stderr, "nxagentPrintResources: Printing resources for client [%d]:\n", i); -- cgit v1.2.3 From bc42d11f9eb8ca83d7d0c9b8b9e218c2c7f8ac41 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 29 Oct 2019 01:12:59 +0100 Subject: Pixmap.c: reformat comments plus some minor formatting fixes --- nx-X11/programs/Xserver/hw/nxagent/Pixmap.c | 100 ++++++++++++---------------- 1 file changed, 44 insertions(+), 56 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c index b3f8572e8..695d14618 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c @@ -106,8 +106,8 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, #endif /* - * Create the pixmap structure but do - * not allocate memory for the data. + * Create the pixmap structure but do not allocate memory for the + * data. */ PixmapPtr pPixmap = AllocatePixmap(pScreen, 0); @@ -174,16 +174,13 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, pPixmapPriv -> containTrapezoids = 0; /* - * The lazy encoding policy generally does - * not send on remote X server the off-screen - * images, by preferring to synchronize the - * windows content. Anyway this behaviour may - * be inadvisable if a pixmap is used, for - * example, for multiple copy areas on screen. - * This counter serves the purpose, taking in- - * to account the number of times the pixmap - * has been used as source for a deferred - * operation. + * The lazy encoding policy generally does not send on remote X + * server the off-screen images, by preferring to synchronize the + * windows content. Anyway this behaviour may be inadvisable if a + * pixmap is used, for example, for multiple copy areas on screen. + * This counter serves the purpose, taking into account the number + * of times the pixmap has been used as source for a deferred + * operation. */ pPixmapPriv -> usageCounter = 0; @@ -200,11 +197,10 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, pPixmapPriv -> isBackingPixmap = 0; /* - * Create the pixmap based on the default - * windows. The proxy knows this and uses - * this information to optimize encode the - * create pixmap message by including the - * id of the drawable in the checksum. + * Create the pixmap based on the default windows. The proxy knows + * this and uses this information to optimize encode the create + * pixmap message by including the id of the drawable in the + * checksum. */ if (width != 0 && height != 0 && nxagentGCTrap == 0) @@ -251,7 +247,7 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, } #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", nxagentShmPixmapTrap ? "Shm " : "", (void *) pVirtual, (void *) pPixmap, width, height, usage_hint); #endif @@ -259,12 +255,11 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, pPixmapPriv -> pVirtualPixmap = pVirtual; /* - * Initialize the privates of the virtual picture. We - * could avoid to use a flag and just check the pointer - * to the virtual pixmap that, if the pixmap is actually - * virtual, will be NULL. Unfortunately the flag can be - * changed in nxagentValidateGC(). That code should be - * removed in future. + * Initialize the privates of the virtual picture. We could avoid to + * use a flag and just check the pointer to the virtual pixmap that, + * if the pixmap is actually virtual, will be NULL. Unfortunately + * the flag can be changed in nxagentValidateGC(). That code should + * be removed in future. */ nxagentPrivPixmapPtr pVirtualPriv = nxagentPixmapPriv(pVirtual); @@ -291,19 +286,17 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, pVirtualPriv -> splitResource = NULL; /* - * We might distinguish real and virtual pixmaps by - * checking the pointers to pVirtualPixmap. We should - * also remove the copy of id and use the one of the - * real pixmap. + * We might distinguish real and virtual pixmaps by checking the + * pointers to pVirtualPixmap. We should also remove the copy of id + * and use the one of the real pixmap. */ pVirtualPriv -> id = pPixmapPriv -> id; pVirtualPriv -> mid = 0; /* - * Storing a pointer back to the real pixmap is - * silly. Unfortunately this is the way it has - * been originally implemented. See also the + * Storing a pointer back to the real pixmap is silly. Unfortunately + * this is the way it has been originally implemented. See also the * comment in destroy of the pixmap. */ @@ -345,12 +338,11 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap) { /* * For some pixmaps we receive the destroy only for the - * virtual. Infact to draw in the framebuffer we can use - * the virtual pixmap instead of the pointer to the real - * one. As the virtual pixmap can collect references, we - * must transfer those references to the real pixmap so - * we can continue as the destroy had been requested for - * it. + * virtual. Infact to draw in the framebuffer we can use the + * virtual pixmap instead of the pointer to the real one. As the + * virtual pixmap can collect references, we must transfer those + * references to the real pixmap so we can continue as the destroy + * had been requested for it. */ pVirtual = pPixmap; @@ -396,7 +388,6 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap) } #ifdef TEST - fprintf(stderr, "nxagentDestroyPixmap: Managing to destroy the pixmap at [%p]\n", (void *) pPixmap); #endif @@ -497,10 +488,9 @@ Bool nxagentModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int dep int bitsPerPixel, int devKind, void * pPixData) { /* - * See miModifyPixmapHeader() in miscrinit.c. This - * function is used to recycle the scratch pixmap - * for this screen. We let it refer to the virtual - * pixmap. + * See miModifyPixmapHeader() in miscrinit.c. This function is used + * to recycle the scratch pixmap for this screen. We let it refer to + * the virtual pixmap. */ if (!pPixmap) @@ -666,9 +656,9 @@ Bool nxagentDisconnectAllPixmaps(void) #endif /* - * The RT_NX_PIXMAP resource type is allocated - * only on the server client, so we don't need - * to find it through the other clients too. + * The RT_NX_PIXMAP resource type is allocated only on the server + * client, so we don't need to find it through the other clients + * too. */ FindClientResourcesByType(clients[serverClient -> index], RT_NX_PIXMAP, nxagentDisconnectPixmap, &r); @@ -734,9 +724,8 @@ void nxagentReconnectPixmap(void *p0, XID x1, void *p2) else if (pPixmap == nxagentDefaultScreen -> pScratchPixmap) { /* - * Every time the scratch pixmap is used its - * data is changed, so we don't need to recon- - * nect it. + * Every time the scratch pixmap is used its data is changed, so + * we don't need to reconnect it. */ #ifdef TEST @@ -831,9 +820,9 @@ Bool nxagentReconnectAllPixmaps(void *p0) nxagentResetAlphaCache(); /* - * The RT_NX_PIXMAP resource type is allocated - * only on the server client, so we don't need - * to find it through the other clients too. + * The RT_NX_PIXMAP resource type is allocated only on the server + * client, so we don't need to find it through the other clients + * too. */ FindClientResourcesByType(clients[serverClient -> index], RT_NX_PIXMAP, nxagentReconnectPixmap, &result); @@ -857,11 +846,10 @@ Bool nxagentReconnectAllPixmaps(void *p0) #endif /* - * Let the pixmap be reconnected as it was an - * image request issued by the client owning - * the resource. The client index is used as - * a subscript by the image routines to cache - * the data per-client. + * Let the pixmap be reconnected as it was an image request + * issued by the client owning the resource. The client index is + * used as a subscript by the image routines to cache the data + * per-client. */ FindClientResourcesByType(clients[i], RT_PIXMAP, nxagentReconnectPixmap, &result); -- cgit v1.2.3