⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gc.c

📁 远程桌面连接工具
💻 C
📖 第 1 页 / 共 3 页
字号:
		    (*pGC->funcs->ChangeClip)(pGC, clipType,					      (pointer)pPixmap, 0);		}		break;	    }	    case GCDashOffset:		NEXTVAL(INT16, pGC->dashOffset);		break;	    case GCDashList:	    {		CARD8 newdash;		NEXTVAL(CARD8, newdash);		if (newdash == 4)		{		    if (pGC->dash != DefaultDash)		    {			xfree(pGC->dash);			pGC->numInDashList = 2;			pGC->dash = DefaultDash;		    }		}		else if (newdash != 0) 		{		    unsigned char *dash;		    dash = (unsigned char *)xalloc(2 * sizeof(unsigned char));		    if (dash)		    {			if (pGC->dash != DefaultDash)			    xfree(pGC->dash);			pGC->numInDashList = 2;			pGC->dash = dash;			dash[0] = newdash;			dash[1] = newdash;		    }		    else			error = BadAlloc;		} 		else		{		   clientErrorValue = newdash;		   error = BadValue;		}		break;	    }	    case GCArcMode:	    {		unsigned int newarcmode;		NEXTVAL(unsigned int, newarcmode);		if (newarcmode <= ArcPieSlice)		    pGC->arcMode = newarcmode;		else		{		    clientErrorValue = newarcmode;		    error = BadValue;		}		break;	    }	    default:		clientErrorValue = maskQ;		error = BadValue;		break;	}    } /* end while mask && !error */    if (pGC->fillStyle == FillTiled && pGC->tileIsPixel)    {	if (!CreateDefaultTile (pGC))	{	    pGC->fillStyle = FillSolid;	    error = BadAlloc;	}    }    (*pGC->funcs->ChangeGC)(pGC, maskQ);    return error;}#undef NEXTVAL#undef NEXT_PTR/* Publically defined entry to ChangeGC.  Just calls dixChangeGC and tells * it that all of the entries are constants or IDs */intChangeGC(pGC, mask, pval)    register GC 	*pGC;    register BITS32	mask;    XID			*pval;{    return (dixChangeGC(NullClient, pGC, mask, pval, NULL));}/* DoChangeGC(pGC, mask, pval, fPointer)   mask is a set of bits indicating which values to change.   pval contains an appropriate value for each mask.   fPointer is true if the values for tiles, stipples, fonts or clipmasks   are pointers instead of IDs.  Note: if you are passing pointers you   MUST declare the array of values as type pointer!  Other data types   may not be large enough to hold pointers on some machines.  Yes,   this means you have to cast to (XID *) when you pass the array to   DoChangeGC.  Similarly, if you are not passing pointers (fPointer = 0) you   MUST declare the array as type XID (not unsigned long!), or again the wrong   size data type may be used.  To avoid this cruftiness, use dixChangeGC   above.   if there is an error, the value is marked as changed    anyway, which is probably wrong, but infrequent.NOTE:	all values sent over the protocol for ChangeGC requests are32 bits long*/intDoChangeGC(pGC, mask, pval, fPointer)    register GC 	*pGC;    register BITS32	mask;    XID			*pval;    int			fPointer;{    int r;    if (fPointer)    /* XXX might be a problem on 64 bit big-endian servers */	r = dixChangeGC(NullClient, pGC, mask, NULL, (ChangeGCValPtr)pval);    else	r = dixChangeGC(NullClient, pGC, mask, pval, NULL);    return r;}/* 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 pStatusBUG:   should check for failure to create default tile*/static GCPtr#if NeedFunctionPrototypesAllocateGC(ScreenPtr pScreen)#elseAllocateGC(pScreen)    ScreenPtr pScreen;#endif{    GCPtr pGC;    register char *ptr;    register DevUnion *ppriv;    register unsigned *sizes;    register unsigned size;    register int i;    pGC = (GCPtr)xalloc(pScreen->totalGCSize);    if (pGC)    {	ppriv = (DevUnion *)(pGC + 1);	pGC->devPrivates = ppriv;	sizes = pScreen->GCPrivateSizes;	ptr = (char *)(ppriv + pScreen->GCPrivateLen);	for (i = pScreen->GCPrivateLen; --i >= 0; ppriv++, sizes++)	{	    if ( (size = *sizes) )	    {		ppriv->ptr = (pointer)ptr;		ptr += size;	    }	    else		ppriv->ptr = (pointer)NULL;	}    }    return pGC;}GCPtrCreateGC(pDrawable, mask, pval, pStatus)    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);}static BoolCreateDefaultTile (pGC)    GCPtr   pGC;{    XID		tmpval[3];    PixmapPtr 	pTile;    GCPtr	pgcScratch;    xRectangle	rect;    CARD16	w, h;    w = 1;    h = 1;    (*pGC->pScreen->QueryBestSize)(TileShape, &w, &h, pGC->pScreen);    pTile = (PixmapPtr)	    (*pGC->pScreen->CreatePixmap)(pGC->pScreen,					  w, h, pGC->depth);    pgcScratch = GetScratchGC(pGC->depth, pGC->pScreen);    if (!pTile || !pgcScratch)    {	if (pTile)	    (*pTile->drawable.pScreen->DestroyPixmap)(pTile);	if (pgcScratch)	    FreeScratchGC(pgcScratch);	return FALSE;    }    tmpval[0] = GXcopy;    tmpval[1] = pGC->tile.pixel;    tmpval[2] = FillSolid;    (void)ChangeGC(pgcScratch, GCFunction | GCForeground | GCFillStyle, 		   tmpval);    ValidateGC((DrawablePtr)pTile, pgcScratch);    rect.x = 0;    rect.y = 0;    rect.width = w;    rect.height = h;    (*pgcScratch->ops->PolyFillRect)((DrawablePtr)pTile, pgcScratch, 1, &rect);    /* Always remember to free the scratch graphics context after use. */    FreeScratchGC(pgcScratch);    pGC->tileIsPixel = FALSE;    pGC->tile.pixmap = pTile;    return TRUE;}intCopyGC(pgcSrc, pgcDst, mask)    register GC		*pgcSrc;    register GC		*pgcDst;    register BITS32	mask;{    register BITS32	index2;    BITS32		maskQ;    int 		error = 0;    if (pgcSrc == pgcDst)	return Success;    pgcDst->serialNumber |= GC_CHANGE_SERIAL_BIT;    pgcDst->stateChanges |= mask;    maskQ = mask;    while (mask)    {	index2 = (BITS32) lowbit (mask);	mask &= ~index2;	switch (index2)	{	    case GCFunction:		pgcDst->alu = pgcSrc->alu;		break;	    case GCPlaneMask:		pgcDst->planemask = pgcSrc->planemask;		break;	    case GCForeground:		pgcDst->fgPixel = pgcSrc->fgPixel;		break;	    case GCBackground:		pgcDst->bgPixel = pgcSrc->bgPixel;		break;	    case GCLineWidth:		pgcDst->lineWidth = pgcSrc->lineWidth;		break;	    case GCLineStyle:		pgcDst->lineStyle = pgcSrc->lineStyle;		break;	    case GCCapStyle:		pgcDst->capStyle = pgcSrc->capStyle;		break;	    case GCJoinStyle:		pgcDst->joinStyle = pgcSrc->joinStyle;		break;	    case GCFillStyle:		pgcDst->fillStyle = pgcSrc->fillStyle;		break;	    case GCFillRule:		pgcDst->fillRule = pgcSrc->fillRule;		break;	    case GCTile:		{		    if (EqualPixUnion(pgcDst->tileIsPixel,				      pgcDst->tile,				      pgcSrc->tileIsPixel,				      pgcSrc->tile))		    {			break;		    }		    if (!pgcDst->tileIsPixel)			(* pgcDst->pScreen->DestroyPixmap)(pgcDst->tile.pixmap);		    pgcDst->tileIsPixel = pgcSrc->tileIsPixel;		    pgcDst->tile = pgcSrc->tile;		    if (!pgcDst->tileIsPixel)		       pgcDst->tile.pixmap->refcnt++;		    break;		}	    case GCStipple:		{		    if (pgcDst->stipple == pgcSrc->stipple)			break;		    if (pgcDst->stipple)			(* pgcDst->pScreen->DestroyPixmap)(pgcDst->stipple);		    pgcDst->stipple = pgcSrc->stipple;		    if (pgcDst->stipple)			pgcDst->stipple->refcnt ++;		    break;		}	    case GCTileStipXOrigin:		pgcDst->patOrg.x = pgcSrc->patOrg.x;		break;	    case GCTileStipYOrigin:		pgcDst->patOrg.y = pgcSrc->patOrg.y;		break;	    case GCFont:		if (pgcDst->font == pgcSrc->font)		    break;		if (pgcDst->font)		    CloseFont(pgcDst->font, (Font)0);		if ((pgcDst->font = pgcSrc->font) != NullFont)		    (pgcDst->font)->refcnt++;		break;	    case GCSubwindowMode:		pgcDst->subWindowMode = pgcSrc->subWindowMode;		break;	    case GCGraphicsExposures:		pgcDst->graphicsExposures = pgcSrc->graphicsExposures;		break;	    case GCClipXOrigin:		pgcDst->clipOrg.x = pgcSrc->clipOrg.x;		break;	    case GCClipYOrigin:		pgcDst->clipOrg.y = pgcSrc->clipOrg.y;		break;	    case GCClipMask:		(* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);		break;	    case GCDashOffset:		pgcDst->dashOffset = pgcSrc->dashOffset;		break;	    case GCDashList:		if (pgcSrc->dash == DefaultDash)		{		    if (pgcDst->dash != DefaultDash)		    {			xfree(pgcDst->dash);			pgcDst->numInDashList = pgcSrc->numInDashList;			pgcDst->dash = pgcSrc->dash;		    }		}		else		{		    unsigned char *dash;		    unsigned int i;		    dash = (unsigned char *)xalloc(pgcSrc->numInDashList *						   sizeof(unsigned char));		    if (dash)		    {			if (pgcDst->dash != DefaultDash)			    xfree(pgcDst->dash);			pgcDst->numInDashList = pgcSrc->numInDashList;			pgcDst->dash = dash;			for (i=0; i<pgcSrc->numInDashList; i++)			    dash[i] = pgcSrc->dash[i];		    }		    else			error = BadAlloc;		}		break;	    case GCArcMode:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -