Commit 53f4386b authored by Ulrich Sibiller's avatar Ulrich Sibiller

GC.c: scope improvements

parent 95940104
...@@ -142,8 +142,6 @@ static GCOps nxagentOps = ...@@ -142,8 +142,6 @@ static GCOps nxagentOps =
Bool nxagentCreateGC(GCPtr pGC) Bool nxagentCreateGC(GCPtr pGC)
{ {
FbGCPrivPtr pPriv;
pGC->clientClipType = CT_NONE; pGC->clientClipType = CT_NONE;
pGC->clientClip = NULL; pGC->clientClip = NULL;
...@@ -178,7 +176,7 @@ Bool nxagentCreateGC(GCPtr pGC) ...@@ -178,7 +176,7 @@ Bool nxagentCreateGC(GCPtr pGC)
fprintf(stderr, "nxagentCreateGC: GC [%p]\n", (void *) pGC); fprintf(stderr, "nxagentCreateGC: GC [%p]\n", (void *) pGC);
#endif #endif
pPriv = (pGC)->devPrivates[fbGCPrivateIndex].ptr; FbGCPrivPtr pPriv = (pGC)->devPrivates[fbGCPrivateIndex].ptr;
fbGetRotatedPixmap(pGC) = 0; fbGetRotatedPixmap(pGC) = 0;
fbGetExpose(pGC) = 1; fbGetExpose(pGC) = 1;
...@@ -214,8 +212,6 @@ Bool nxagentCreateGC(GCPtr pGC) ...@@ -214,8 +212,6 @@ Bool nxagentCreateGC(GCPtr pGC)
void nxagentValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable) void nxagentValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
{ {
PixmapPtr lastTile, lastStipple;
DrawablePtr pVirtual = (pDrawable -> type == DRAWABLE_PIXMAP) ? DrawablePtr pVirtual = (pDrawable -> type == DRAWABLE_PIXMAP) ?
nxagentVirtualDrawable(pDrawable) : nxagentVirtualDrawable(pDrawable) :
pDrawable; pDrawable;
...@@ -233,9 +229,9 @@ void nxagentValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable) ...@@ -233,9 +229,9 @@ void nxagentValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
pGC -> tile.pixmap = nxagentVirtualPixmap(pGC -> tile.pixmap); 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) if (lastStipple)
{ {
...@@ -510,9 +506,6 @@ void nxagentDestroyGC(GCPtr pGC) ...@@ -510,9 +506,6 @@ void nxagentDestroyGC(GCPtr pGC)
void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects) void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects)
{ {
int i, size;
BoxPtr pBox;
XRectangle *pRects;
int clipsMatch = 0; int clipsMatch = 0;
#ifdef TEST #ifdef TEST
...@@ -577,12 +570,13 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects) ...@@ -577,12 +570,13 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects)
{ {
if (clipsMatch == 0 && nxagentGCTrap == 0) if (clipsMatch == 0 && nxagentGCTrap == 0)
{ {
XRectangle *pRects;
nRects = RegionNumRects((RegionPtr)pValue); nRects = RegionNumRects((RegionPtr)pValue);
size = nRects * sizeof(*pRects); int size = nRects * sizeof(*pRects);
pRects = (XRectangle *) malloc(size); 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].x = pBox[i].x1;
pRects[i].y = pBox[i].y1; pRects[i].y = pBox[i].y1;
...@@ -742,8 +736,6 @@ void nxagentDestroyClipHelper(GCPtr pGC) ...@@ -742,8 +736,6 @@ void nxagentDestroyClipHelper(GCPtr pGC)
void nxagentCopyClip(GCPtr pGCDst, GCPtr pGCSrc) void nxagentCopyClip(GCPtr pGCDst, GCPtr pGCSrc)
{ {
RegionPtr pRgn;
#ifdef TEST #ifdef TEST
fprintf(stderr, "nxagentCopyClip: Going to copy clip from GC [%p] to GC [%p]\n", fprintf(stderr, "nxagentCopyClip: Going to copy clip from GC [%p] to GC [%p]\n",
(void *) pGCDst, (void *) pGCSrc); (void *) pGCDst, (void *) pGCSrc);
...@@ -754,7 +746,7 @@ void nxagentCopyClip(GCPtr pGCDst, GCPtr pGCSrc) ...@@ -754,7 +746,7 @@ void nxagentCopyClip(GCPtr pGCDst, GCPtr pGCSrc)
case CT_REGION: case CT_REGION:
if (nxagentGCPriv(pGCSrc)->pPixmap == NULL) if (nxagentGCPriv(pGCSrc)->pPixmap == NULL)
{ {
pRgn = RegionCreate(NULL, 1); RegionPtr pRgn = RegionCreate(NULL, 1);
RegionCopy(pRgn, pGCSrc->clientClip); RegionCopy(pRgn, pGCSrc->clientClip);
nxagentChangeClip(pGCDst, CT_REGION, pRgn, 0); nxagentChangeClip(pGCDst, CT_REGION, pRgn, 0);
} }
...@@ -1029,7 +1021,6 @@ static void nxagentReconnectGC(void *param0, XID param1, void * param2) ...@@ -1029,7 +1021,6 @@ static void nxagentReconnectGC(void *param0, XID param1, void * param2)
Bool nxagentReconnectAllGCs(void *p0) Bool nxagentReconnectAllGCs(void *p0)
{ {
int cid;
Bool GCSuccess = True; Bool GCSuccess = True;
#ifdef DEBUG #ifdef DEBUG
...@@ -1044,7 +1035,7 @@ Bool nxagentReconnectAllGCs(void *p0) ...@@ -1044,7 +1035,7 @@ Bool nxagentReconnectAllGCs(void *p0)
FindClientResourcesByType(clients[serverClient -> index], RT_NX_GC, nxagentReconnectGC, &GCSuccess); 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]) if (clients[cid])
{ {
...@@ -1090,7 +1081,6 @@ void nxagentDisconnectGC(void * p0, XID x1, void * p2) ...@@ -1090,7 +1081,6 @@ void nxagentDisconnectGC(void * p0, XID x1, void * p2)
Bool nxagentDisconnectAllGCs(void) Bool nxagentDisconnectAllGCs(void)
{ {
int cid;
Bool success = True; Bool success = True;
#ifdef DEBUG #ifdef DEBUG
...@@ -1106,7 +1096,7 @@ Bool nxagentDisconnectAllGCs(void) ...@@ -1106,7 +1096,7 @@ Bool nxagentDisconnectAllGCs(void)
FindClientResourcesByType(clients[serverClient -> index], RT_NX_GC, FindClientResourcesByType(clients[serverClient -> index], RT_NX_GC,
(FindResType) nxagentDisconnectGC, &success); (FindResType) nxagentDisconnectGC, &success);
for (cid = 0; (cid < MAXCLIENTS) && success; cid++) for (int cid = 0; (cid < MAXCLIENTS) && success; cid++)
{ {
if (clients[cid]) if (clients[cid])
{ {
...@@ -1132,10 +1122,6 @@ Bool nxagentDisconnectAllGCs(void) ...@@ -1132,10 +1122,6 @@ Bool nxagentDisconnectAllGCs(void)
static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects) static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects)
{ {
int i, size;
BoxPtr pBox;
XRectangle *pRects;
#ifdef TEST #ifdef TEST
fprintf(stderr, "nxagentReconnectClip: going to change clip on GC [%p]\n", fprintf(stderr, "nxagentReconnectClip: going to change clip on GC [%p]\n",
(void *) pGC); (void *) pGC);
...@@ -1156,11 +1142,12 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects) ...@@ -1156,11 +1142,12 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects)
case CT_REGION: case CT_REGION:
if (nxagentGCPriv(pGC)->pPixmap == NULL) if (nxagentGCPriv(pGC)->pPixmap == NULL)
{ {
XRectangle *pRects;
nRects = RegionNumRects((RegionPtr)pValue); nRects = RegionNumRects((RegionPtr)pValue);
size = nRects * sizeof(*pRects); int size = nRects * sizeof(*pRects);
pRects = (XRectangle *) malloc(size); 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].x = pBox[i].x1;
pRects[i].y = pBox[i].y1; pRects[i].y = pBox[i].y1;
pRects[i].width = pBox[i].x2 - pBox[i].x1; pRects[i].width = pBox[i].x2 - pBox[i].x1;
...@@ -1262,8 +1249,6 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects) ...@@ -1262,8 +1249,6 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects)
static int nxagentCompareRegions(RegionPtr r1, RegionPtr r2) static int nxagentCompareRegions(RegionPtr r1, RegionPtr r2)
{ {
int i;
/* /*
* It returns 1 if regions are equal, 0 otherwise * It returns 1 if regions are equal, 0 otherwise
*/ */
...@@ -1292,7 +1277,7 @@ static int nxagentCompareRegions(RegionPtr r1, RegionPtr r2) ...@@ -1292,7 +1277,7 @@ static int nxagentCompareRegions(RegionPtr r1, RegionPtr r2)
else if ((*RegionExtents(r1)).y2 != (*RegionExtents(r2)).y2) return 0; else if ((*RegionExtents(r1)).y2 != (*RegionExtents(r2)).y2) return 0;
else 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; if (RegionRects(r1)[i].x1 != RegionRects(r2)[i].x1) return 0;
else if (RegionRects(r1)[i].x2 != RegionRects(r2)[i].x2) return 0; else if (RegionRects(r1)[i].x2 != RegionRects(r2)[i].x2) return 0;
...@@ -1394,10 +1379,7 @@ void nxagentFreeScratchGC(GCPtr pGC) ...@@ -1394,10 +1379,7 @@ void nxagentFreeScratchGC(GCPtr pGC)
GCPtr nxagentGetGraphicContext(DrawablePtr pDrawable) GCPtr nxagentGetGraphicContext(DrawablePtr pDrawable)
{ {
int i; for (int i = 0; i < nxagentGraphicContextsSize; i++)
int result;
for (i = 0; i < nxagentGraphicContextsSize; i++)
{ {
if (pDrawable -> depth == nxagentGraphicContexts[i].depth) if (pDrawable -> depth == nxagentGraphicContexts[i].depth)
{ {
...@@ -1416,7 +1398,7 @@ GCPtr nxagentGetGraphicContext(DrawablePtr pDrawable) ...@@ -1416,7 +1398,7 @@ GCPtr nxagentGetGraphicContext(DrawablePtr pDrawable)
fprintf(stderr, "nxagentGetGraphicContext: Going to reconnect the GC.\n"); fprintf(stderr, "nxagentGetGraphicContext: Going to reconnect the GC.\n");
#endif #endif
result = 1; int result = 1;
nxagentReconnectGC(nxagentGraphicContexts[i].pGC, (XID) 0, &result); nxagentReconnectGC(nxagentGraphicContexts[i].pGC, (XID) 0, &result);
...@@ -1441,18 +1423,12 @@ GCPtr nxagentGetGraphicContext(DrawablePtr pDrawable) ...@@ -1441,18 +1423,12 @@ GCPtr nxagentGetGraphicContext(DrawablePtr pDrawable)
GCPtr nxagentCreateGraphicContext(int depth) GCPtr nxagentCreateGraphicContext(int depth)
{ {
GCPtr pGC;
nxagentGraphicContextsPtr nxagentGCs;
XID attributes[2];
/* /*
* We have not found a GC, so we have * We have not found a GC, so we have
* to spread the list and add a new GC. * 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) if (nxagentGCs == NULL)
{ {
...@@ -1465,7 +1441,7 @@ GCPtr nxagentCreateGraphicContext(int depth) ...@@ -1465,7 +1441,7 @@ GCPtr nxagentCreateGraphicContext(int depth)
nxagentGraphicContexts = nxagentGCs; nxagentGraphicContexts = nxagentGCs;
pGC = CreateScratchGC(nxagentDefaultScreen, depth); GCPtr pGC = CreateScratchGC(nxagentDefaultScreen, depth);
if (pGC == NULL) if (pGC == NULL)
{ {
...@@ -1477,6 +1453,8 @@ GCPtr nxagentCreateGraphicContext(int depth) ...@@ -1477,6 +1453,8 @@ GCPtr nxagentCreateGraphicContext(int depth)
return NULL; return NULL;
} }
XID attributes[2];
/* /*
* Color used in nxagentFillRemoteRegion(). * Color used in nxagentFillRemoteRegion().
*/ */
...@@ -1520,13 +1498,9 @@ GCPtr nxagentCreateGraphicContext(int depth) ...@@ -1520,13 +1498,9 @@ GCPtr nxagentCreateGraphicContext(int depth)
void nxagentAllocateGraphicContexts(void) void nxagentAllocateGraphicContexts(void)
{ {
int *depths; int *depths = nxagentDepths;
int i;
depths = nxagentDepths; for (int i = 0; i < nxagentNumDepths; i++)
for (i = 0; i < nxagentNumDepths; i++)
{ {
nxagentCreateGraphicContext(*depths); nxagentCreateGraphicContext(*depths);
...@@ -1536,9 +1510,7 @@ void nxagentAllocateGraphicContexts(void) ...@@ -1536,9 +1510,7 @@ void nxagentAllocateGraphicContexts(void)
void nxagentDisconnectGraphicContexts(void) void nxagentDisconnectGraphicContexts(void)
{ {
int i; for (int i = 0; i < nxagentGraphicContextsSize; i++)
for (i = 0; i < nxagentGraphicContextsSize; i++)
{ {
nxagentGraphicContexts[i].dirty = 1; nxagentGraphicContexts[i].dirty = 1;
} }
......
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