void miDCDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen) { miDCBufferPtr pBuffer; int i; if (DevHasCursor(pDev)) { for (i = 0; i < screenInfo.numScreens; i++) { pScreen = screenInfo.screens[i]; pBuffer = miGetDCDevice(pDev, pScreen); if (pBuffer) { if (pBuffer->pSourceGC) FreeGC(pBuffer->pSourceGC, (GContext) 0); if (pBuffer->pMaskGC) FreeGC(pBuffer->pMaskGC, (GContext) 0); if (pBuffer->pSaveGC) FreeGC(pBuffer->pSaveGC, (GContext) 0); if (pBuffer->pRestoreGC) FreeGC(pBuffer->pRestoreGC, (GContext) 0); #ifdef ARGB_CURSOR /* If a pRootPicture was allocated for a root window, it * is freed when that root window is destroyed, so don't * free it again here. */ #endif if (pBuffer->pSave) (*pScreen->DestroyPixmap)(pBuffer->pSave); free(pBuffer); dixSetScreenPrivate(&pDev->devPrivates, miDCDeviceKey, pScreen, NULL); } } } }
Bool CreateGCperDepth(int screenNum) { register int i; register ScreenPtr pScreen; DepthPtr pDepth; GCPtr *ppGC; pScreen = screenInfo.screens[screenNum]; pScreen->rgf = 0; ppGC = pScreen->GCperDepth; /* do depth 1 separately because it's not included in list */ if (!(ppGC[0] = CreateScratchGC(pScreen, 1))) return FALSE; ppGC[0]->graphicsExposures = FALSE; /* Make sure we don't overflow GCperDepth[] */ if( pScreen->numDepths > MAXFORMATS ) return FALSE; pDepth = pScreen->allowedDepths; for (i=0; i<pScreen->numDepths; i++, pDepth++) { if (!(ppGC[i+1] = CreateScratchGC(pScreen, pDepth->depth))) { for (; i >= 0; i--) (void)FreeGC(ppGC[i], (XID)0); return FALSE; } ppGC[i+1]->graphicsExposures = FALSE; } return TRUE; }
/* if the gc to free is in the table of pre-existing ones, mark it as available. if not, free it for real */ void FreeScratchGC(GCPtr pGC) { if (pGC->scratch_inuse) pGC->scratch_inuse = FALSE; else FreeGC(pGC, (GContext) 0); }
static void cwDestroyBackingGC(GCPtr pGC) { cwGCPtr pPriv; pPriv = (cwGCPtr) getCwGC (pGC); if (pPriv->pBackingGC) { FreeGC(pPriv->pBackingGC, (XID)0); pPriv->pBackingGC = NULL; } }
_X_EXPORT GCPtr CreateScratchGC(ScreenPtr pScreen, unsigned depth) { register GCPtr pGC; pGC = AllocateGC(pScreen); if (!pGC) return (GCPtr)NULL; pGC->pScreen = pScreen; pGC->depth = depth; pGC->alu = GXcopy; /* dst <- src */ pGC->planemask = ~0; pGC->serialNumber = 0; pGC->fgPixel = 0; pGC->bgPixel = 1; pGC->lineWidth = 0; pGC->lineStyle = LineSolid; pGC->capStyle = CapButt; pGC->joinStyle = JoinMiter; pGC->fillStyle = FillSolid; pGC->fillRule = EvenOddRule; pGC->arcMode = ArcPieSlice; pGC->font = defaultFont; if ( pGC->font) /* necessary, because open of default font could fail */ pGC->font->refcnt++; pGC->tileIsPixel = TRUE; pGC->tile.pixel = 0; pGC->stipple = NullPixmap; pGC->patOrg.x = 0; pGC->patOrg.y = 0; pGC->subWindowMode = ClipByChildren; pGC->graphicsExposures = TRUE; pGC->clipOrg.x = 0; pGC->clipOrg.y = 0; pGC->clientClipType = CT_NONE; pGC->dashOffset = 0; pGC->numInDashList = 2; pGC->dash = DefaultDash; pGC->lastWinOrg.x = 0; pGC->lastWinOrg.y = 0; pGC->stateChanges = (1 << (GCLastBit+1)) - 1; if (!(*pScreen->CreateGC)(pGC)) { FreeGC(pGC, (XID)0); pGC = (GCPtr)NULL; } return pGC; }
void FreeGCperDepth(int screenNum) { register int i; register ScreenPtr pScreen; GCPtr *ppGC; pScreen = screenInfo.screens[screenNum]; ppGC = pScreen->GCperDepth; for (i = 0; i <= pScreen->numDepths; i++) (void)FreeGC(ppGC[i], (XID)0); pScreen->rgf = ~0L; }
void FreeGCperDepth(int screenNum) { int i; ScreenPtr pScreen; GCPtr *ppGC; pScreen = screenInfo.screens[screenNum]; ppGC = pScreen->GCperDepth; for (i = 0; i <= pScreen->numDepths; i++) { (void) FreeGC(ppGC[i], (XID) 0); ppGC[i] = NULL; } }
/* CreateGC(pDrawable, mask, pval, pStatus) creates a default GC for the given drawable, using mask to fill in any non-default values. Returns a pointer to the new GC on success, NULL otherwise. returns status of non-default fields in pStatus BUG: should check for failure to create default tile */ GCPtr CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus, XID gcid, ClientPtr client) { GCPtr pGC; pGC = NewGCObject(pDrawable->pScreen, pDrawable->depth); if (!pGC) { *pStatus = BadAlloc; return (GCPtr) NULL; } pGC->serialNumber = GC_CHANGE_SERIAL_BIT; if (mask & GCForeground) { /* * magic special case -- ChangeGC checks for this condition * and snags the Foreground value to create a pseudo default-tile */ pGC->tileIsPixel = FALSE; } else { pGC->tileIsPixel = TRUE; } /* security creation/labeling check */ *pStatus = XaceHook(XACE_RESOURCE_ACCESS, client, gcid, RT_GC, pGC, RT_NONE, NULL, DixCreateAccess | DixSetAttrAccess); if (*pStatus != Success) goto out; pGC->stateChanges = GCAllBits; if (!(*pGC->pScreen->CreateGC) (pGC)) *pStatus = BadAlloc; else if (mask) *pStatus = ChangeGCXIDs(client, pGC, mask, pval); else *pStatus = Success; out: if (*pStatus != Success) { if (!pGC->tileIsPixel && !pGC->tile.pixmap) pGC->tileIsPixel = TRUE; /* undo special case */ FreeGC(pGC, (XID) 0); pGC = (GCPtr) NULL; } return pGC; }
/* if the gc to free is in the table of pre-existing ones, mark it as available. if not, free it for real */ _X_EXPORT void FreeScratchGC(register GCPtr pGC) { register ScreenPtr pScreen = pGC->pScreen; register int i; for (i=0; i<=pScreen->numDepths; i++) { if ( pScreen->GCperDepth[i] == pGC) { pScreen->rgf &= ~(1L << (i+1)); return; } } (void)FreeGC(pGC, (GContext)0); }
static GCPtr CreateScratchGC(ScreenPtr pScreen, unsigned depth) { GCPtr pGC; pGC = NewGCObject(pScreen, depth); if (!pGC) return (GCPtr) NULL; pGC->stateChanges = GCAllBits; if (!(*pScreen->CreateGC) (pGC)) { FreeGC(pGC, (XID) 0); pGC = (GCPtr) NULL; } pGC->graphicsExposures = FALSE; return pGC; }
_X_EXPORT GCPtr CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus) { register GCPtr pGC; pGC = AllocateGC(pDrawable->pScreen); if (!pGC) { *pStatus = BadAlloc; return (GCPtr)NULL; } pGC->pScreen = pDrawable->pScreen; pGC->depth = pDrawable->depth; pGC->alu = GXcopy; /* dst <- src */ pGC->planemask = ~0; pGC->serialNumber = GC_CHANGE_SERIAL_BIT; pGC->funcs = 0; pGC->fgPixel = 0; pGC->bgPixel = 1; pGC->lineWidth = 0; pGC->lineStyle = LineSolid; pGC->capStyle = CapButt; pGC->joinStyle = JoinMiter; pGC->fillStyle = FillSolid; pGC->fillRule = EvenOddRule; pGC->arcMode = ArcPieSlice; if (mask & GCForeground) { /* * magic special case -- ChangeGC checks for this condition * and snags the Foreground value to create a pseudo default-tile */ pGC->tileIsPixel = FALSE; pGC->tile.pixmap = NullPixmap; } else { pGC->tileIsPixel = TRUE; pGC->tile.pixel = 0; } pGC->patOrg.x = 0; pGC->patOrg.y = 0; pGC->subWindowMode = ClipByChildren; pGC->graphicsExposures = TRUE; pGC->clipOrg.x = 0; pGC->clipOrg.y = 0; pGC->clientClipType = CT_NONE; pGC->clientClip = (pointer)NULL; pGC->numInDashList = 2; pGC->dash = DefaultDash; pGC->dashOffset = 0; pGC->lastWinOrg.x = 0; pGC->lastWinOrg.y = 0; /* use the default font and stipple */ pGC->font = defaultFont; defaultFont->refcnt++; pGC->stipple = pGC->pScreen->PixmapPerDepth[0]; pGC->stipple->refcnt++; pGC->stateChanges = (1 << (GCLastBit+1)) - 1; if (!(*pGC->pScreen->CreateGC)(pGC)) *pStatus = BadAlloc; else if (mask) *pStatus = ChangeGC(pGC, mask, pval); else *pStatus = Success; if (*pStatus != Success) { if (!pGC->tileIsPixel && !pGC->tile.pixmap) pGC->tileIsPixel = TRUE; /* undo special case */ FreeGC(pGC, (XID)0); pGC = (GCPtr)NULL; } return (pGC); }