diff options
author | Ulrich Sibiller <uli42@gmx.de> | 2019-10-22 22:15:42 +0200 |
---|---|---|
committer | Ulrich Sibiller <uli42@gmx.de> | 2020-01-05 22:37:35 +0100 |
commit | 53f4386b974faa0ffbf9727fa036fd78b4ef4625 (patch) | |
tree | 1f31b07b0ef7cb7957d8d80a7011f449dcfde149 /nx-X11 | |
parent | 95940104a1695f3f334328bcca66da3c37d04ddf (diff) | |
download | nx-libs-53f4386b974faa0ffbf9727fa036fd78b4ef4625.tar.gz nx-libs-53f4386b974faa0ffbf9727fa036fd78b4ef4625.tar.bz2 nx-libs-53f4386b974faa0ffbf9727fa036fd78b4ef4625.zip |
GC.c: scope improvements
Diffstat (limited to 'nx-X11')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/GC.c | 76 |
1 files changed, 24 insertions, 52 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/GC.c b/nx-X11/programs/Xserver/hw/nxagent/GC.c index b53428f96..2c2613419 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GC.c +++ b/nx-X11/programs/Xserver/hw/nxagent/GC.c @@ -142,8 +142,6 @@ static GCOps nxagentOps = Bool nxagentCreateGC(GCPtr pGC) { - FbGCPrivPtr pPriv; - pGC->clientClipType = CT_NONE; pGC->clientClip = NULL; @@ -178,7 +176,7 @@ Bool nxagentCreateGC(GCPtr pGC) fprintf(stderr, "nxagentCreateGC: GC [%p]\n", (void *) pGC); #endif - pPriv = (pGC)->devPrivates[fbGCPrivateIndex].ptr; + FbGCPrivPtr pPriv = (pGC)->devPrivates[fbGCPrivateIndex].ptr; fbGetRotatedPixmap(pGC) = 0; fbGetExpose(pGC) = 1; @@ -214,8 +212,6 @@ Bool nxagentCreateGC(GCPtr pGC) void nxagentValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable) { - PixmapPtr lastTile, lastStipple; - DrawablePtr pVirtual = (pDrawable -> type == DRAWABLE_PIXMAP) ? nxagentVirtualDrawable(pDrawable) : pDrawable; @@ -233,9 +229,9 @@ void nxagentValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable) pGC -> tile.pixmap = nxagentVirtualPixmap(pGC -> tile.pixmap); } - lastTile = pGC -> tile.pixmap; + PixmapPtr lastTile = pGC -> tile.pixmap; - lastStipple = pGC->stipple; + PixmapPtr lastStipple = pGC->stipple; if (lastStipple) { @@ -510,9 +506,6 @@ void nxagentDestroyGC(GCPtr pGC) void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects) { - int i, size; - BoxPtr pBox; - XRectangle *pRects; int clipsMatch = 0; #ifdef TEST @@ -577,12 +570,13 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects) { if (clipsMatch == 0 && nxagentGCTrap == 0) { + XRectangle *pRects; nRects = RegionNumRects((RegionPtr)pValue); - size = nRects * sizeof(*pRects); + int size = nRects * sizeof(*pRects); pRects = (XRectangle *) malloc(size); - pBox = RegionRects((RegionPtr)pValue); + BoxPtr pBox = RegionRects((RegionPtr)pValue); - for (i = nRects; i-- > 0;) + for (int i = nRects; i-- > 0;) { pRects[i].x = pBox[i].x1; pRects[i].y = pBox[i].y1; @@ -742,8 +736,6 @@ void nxagentDestroyClipHelper(GCPtr pGC) void nxagentCopyClip(GCPtr pGCDst, GCPtr pGCSrc) { - RegionPtr pRgn; - #ifdef TEST fprintf(stderr, "nxagentCopyClip: Going to copy clip from GC [%p] to GC [%p]\n", (void *) pGCDst, (void *) pGCSrc); @@ -754,7 +746,7 @@ void nxagentCopyClip(GCPtr pGCDst, GCPtr pGCSrc) case CT_REGION: if (nxagentGCPriv(pGCSrc)->pPixmap == NULL) { - pRgn = RegionCreate(NULL, 1); + RegionPtr pRgn = RegionCreate(NULL, 1); RegionCopy(pRgn, pGCSrc->clientClip); nxagentChangeClip(pGCDst, CT_REGION, pRgn, 0); } @@ -1029,7 +1021,6 @@ static void nxagentReconnectGC(void *param0, XID param1, void * param2) Bool nxagentReconnectAllGCs(void *p0) { - int cid; Bool GCSuccess = True; #ifdef DEBUG @@ -1044,7 +1035,7 @@ Bool nxagentReconnectAllGCs(void *p0) FindClientResourcesByType(clients[serverClient -> index], RT_NX_GC, nxagentReconnectGC, &GCSuccess); - for (cid = 0; (cid < MAXCLIENTS) && GCSuccess; cid++) + for (int cid = 0; (cid < MAXCLIENTS) && GCSuccess; cid++) { if (clients[cid]) { @@ -1090,7 +1081,6 @@ void nxagentDisconnectGC(void * p0, XID x1, void * p2) Bool nxagentDisconnectAllGCs(void) { - int cid; Bool success = True; #ifdef DEBUG @@ -1106,7 +1096,7 @@ Bool nxagentDisconnectAllGCs(void) FindClientResourcesByType(clients[serverClient -> index], RT_NX_GC, (FindResType) nxagentDisconnectGC, &success); - for (cid = 0; (cid < MAXCLIENTS) && success; cid++) + for (int cid = 0; (cid < MAXCLIENTS) && success; cid++) { if (clients[cid]) { @@ -1132,10 +1122,6 @@ Bool nxagentDisconnectAllGCs(void) static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects) { - int i, size; - BoxPtr pBox; - XRectangle *pRects; - #ifdef TEST fprintf(stderr, "nxagentReconnectClip: going to change clip on GC [%p]\n", (void *) pGC); @@ -1156,11 +1142,12 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects) case CT_REGION: if (nxagentGCPriv(pGC)->pPixmap == NULL) { + XRectangle *pRects; nRects = RegionNumRects((RegionPtr)pValue); - size = nRects * sizeof(*pRects); + int size = nRects * sizeof(*pRects); pRects = (XRectangle *) malloc(size); - pBox = RegionRects((RegionPtr)pValue); - for (i = nRects; i-- > 0;) { + BoxPtr pBox = RegionRects((RegionPtr)pValue); + for (int i = nRects; i-- > 0;) { pRects[i].x = pBox[i].x1; pRects[i].y = pBox[i].y1; pRects[i].width = pBox[i].x2 - pBox[i].x1; @@ -1262,8 +1249,6 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects) static int nxagentCompareRegions(RegionPtr r1, RegionPtr r2) { - int i; - /* * It returns 1 if regions are equal, 0 otherwise */ @@ -1292,7 +1277,7 @@ static int nxagentCompareRegions(RegionPtr r1, RegionPtr r2) else if ((*RegionExtents(r1)).y2 != (*RegionExtents(r2)).y2) return 0; else { - for (i = 0; i < RegionNumRects(r1); i++) + for (int i = 0; i < RegionNumRects(r1); i++) { if (RegionRects(r1)[i].x1 != RegionRects(r2)[i].x1) return 0; else if (RegionRects(r1)[i].x2 != RegionRects(r2)[i].x2) return 0; @@ -1394,10 +1379,7 @@ void nxagentFreeScratchGC(GCPtr pGC) GCPtr nxagentGetGraphicContext(DrawablePtr pDrawable) { - int i; - int result; - - for (i = 0; i < nxagentGraphicContextsSize; i++) + for (int i = 0; i < nxagentGraphicContextsSize; i++) { if (pDrawable -> depth == nxagentGraphicContexts[i].depth) { @@ -1416,7 +1398,7 @@ GCPtr nxagentGetGraphicContext(DrawablePtr pDrawable) fprintf(stderr, "nxagentGetGraphicContext: Going to reconnect the GC.\n"); #endif - result = 1; + int result = 1; nxagentReconnectGC(nxagentGraphicContexts[i].pGC, (XID) 0, &result); @@ -1441,18 +1423,12 @@ GCPtr nxagentGetGraphicContext(DrawablePtr pDrawable) GCPtr nxagentCreateGraphicContext(int depth) { - GCPtr pGC; - - nxagentGraphicContextsPtr nxagentGCs; - - XID attributes[2]; - /* * We have not found a GC, so we have * to spread the list and add a new GC. */ - nxagentGCs = realloc(nxagentGraphicContexts, (nxagentGraphicContextsSize + 1) * sizeof(nxagentGraphicContextsRec)); + nxagentGraphicContextsPtr nxagentGCs = realloc(nxagentGraphicContexts, (nxagentGraphicContextsSize + 1) * sizeof(nxagentGraphicContextsRec)); if (nxagentGCs == NULL) { @@ -1465,7 +1441,7 @@ GCPtr nxagentCreateGraphicContext(int depth) nxagentGraphicContexts = nxagentGCs; - pGC = CreateScratchGC(nxagentDefaultScreen, depth); + GCPtr pGC = CreateScratchGC(nxagentDefaultScreen, depth); if (pGC == NULL) { @@ -1477,6 +1453,8 @@ GCPtr nxagentCreateGraphicContext(int depth) return NULL; } + XID attributes[2]; + /* * Color used in nxagentFillRemoteRegion(). */ @@ -1520,13 +1498,9 @@ GCPtr nxagentCreateGraphicContext(int depth) void nxagentAllocateGraphicContexts(void) { - int *depths; - - int i; + int *depths = nxagentDepths; - depths = nxagentDepths; - - for (i = 0; i < nxagentNumDepths; i++) + for (int i = 0; i < nxagentNumDepths; i++) { nxagentCreateGraphicContext(*depths); @@ -1536,9 +1510,7 @@ void nxagentAllocateGraphicContexts(void) void nxagentDisconnectGraphicContexts(void) { - int i; - - for (i = 0; i < nxagentGraphicContextsSize; i++) + for (int i = 0; i < nxagentGraphicContextsSize; i++) { nxagentGraphicContexts[i].dirty = 1; } |