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

📄 icimage.c

📁 按照官方的说法:Cairo is a vector graphics library with cross-device output support. 翻译过来
💻 C
📖 第 1 页 / 共 2 页
字号:
voidpixman_image_destroy (pixman_image_t *image){    pixman_image_destroyClip (image);    if (image->freeCompClip) {	pixman_region_destroy (image->pCompositeClip);	image->pCompositeClip = NULL;    }    if (image->freeSourceClip) {	pixman_region_destroy (image->pSourceClip);	image->pSourceClip = NULL;    }    if (image->owns_pixels) {	FbPixelsDestroy (image->pixels);	image->pixels = NULL;    }    if (image->transform) {	free (image->transform);	image->transform = NULL;    }    if (image->pSourcePict) {	free (image->pSourcePict);	image->pSourcePict = NULL;    }    free (image);}slim_hidden_def(pixman_image_destroy);voidpixman_image_destroyClip (pixman_image_t *image){    switch (image->clientClipType) {    case CT_NONE:	return;    case CT_PIXMAP:	pixman_image_destroy (image->clientClip);	break;    default:	pixman_region_destroy (image->clientClip);	break;    }    image->clientClip = NULL;    image->clientClipType = CT_NONE;}intpixman_image_set_clip_region (pixman_image_t	*image,			      pixman_region16_t	*region){    pixman_image_destroyClip (image);    if (region) {	image->clientClip = pixman_region_create ();	pixman_region_copy (image->clientClip, region);	image->clientClipType = CT_REGION;    }    image->stateChanges |= CPClipMask;    if (image->pSourcePict)	return 0;    if (image->freeCompClip)	pixman_region_destroy (image->pCompositeClip);    image->pCompositeClip = pixman_region_create();    pixman_region_union_rect (image->pCompositeClip, image->pCompositeClip,			      0, 0, image->pixels->width, image->pixels->height);    image->freeCompClip = 1;    if (region) {	pixman_region_translate (image->pCompositeClip,				 - image->clipOrigin.x,				 - image->clipOrigin.y);	pixman_region_intersect (image->pCompositeClip,				 image->pCompositeClip,				 region);	pixman_region_translate (image->pCompositeClip,				 image->clipOrigin.x,				 image->clipOrigin.y);    }    return 0;}#define BOUND(v)	(int16_t) ((v) < MINSHORT ? MINSHORT : (v) > MAXSHORT ? MAXSHORT : (v))static __inline intFbClipImageReg (pixman_region16_t	*region,		pixman_region16_t	*clip,		int		dx,		int		dy){    if (pixman_region_num_rects (region) == 1 &&	pixman_region_num_rects (clip) == 1)    {	pixman_box16_t *pRbox = pixman_region_rects (region);	pixman_box16_t *pCbox = pixman_region_rects (clip);	int	v;	if (pRbox->x1 < (v = pCbox->x1 + dx))	    pRbox->x1 = BOUND(v);	if (pRbox->x2 > (v = pCbox->x2 + dx))	    pRbox->x2 = BOUND(v);	if (pRbox->y1 < (v = pCbox->y1 + dy))	    pRbox->y1 = BOUND(v);	if (pRbox->y2 > (v = pCbox->y2 + dy))	    pRbox->y2 = BOUND(v);	if (pRbox->x1 >= pRbox->x2 ||	    pRbox->y1 >= pRbox->y2)	{	    pixman_region_empty (region);	}    }    else    {	pixman_region_translate (region, dx, dy);	pixman_region_intersect (region, clip, region);	pixman_region_translate (region, -dx, -dy);    }    return 1;}static __inline intFbClipImageSrc (pixman_region16_t	*region,		pixman_image_t		*image,		int		dx,		int		dy){    /* XXX what to do with clipping from transformed pictures? */    if (image->transform)	return 1;    /* XXX davidr hates this, wants to never use source-based clipping */    if (image->repeat != PIXMAN_REPEAT_NONE || image->pSourcePict)    {	/* XXX no source clipping */	if (image->compositeClipSource &&	    image->clientClipType != CT_NONE)	{	    pixman_region_translate (region,			   dx - image->clipOrigin.x,			   dy - image->clipOrigin.y);	    pixman_region_intersect (region, image->clientClip, region);	    pixman_region_translate (region,			   - (dx - image->clipOrigin.x),			   - (dy - image->clipOrigin.y));	}	return 1;    }    else    {	pixman_region16_t   *clip;	if (image->compositeClipSource)	    clip = image->pCompositeClip;	else	    clip = image->pSourceClip;	return FbClipImageReg (region,			       clip,			       dx,			       dy);    }    return 1;}/* XXX: Need to decide what to do with this#define NEXT_VAL(_type) (vlist ? (_type) *vlist++ : (_type) ulist++->val)#define NEXT_PTR(_type) ((_type) ulist++->ptr)intpixman_image_change (pixman_image_t		*image,	       Mask		vmask,	       unsigned int	*vlist,	       DevUnion		*ulist,	       int		*error_value){    BITS32		index2;    int			error = 0;    BITS32		maskQ;    maskQ = vmask;    while (vmask && !error)    {	index2 = (BITS32) lowbit (vmask);	vmask &= ~index2;	image->stateChanges |= index2;	switch (index2)	{	case CPRepeat:	    {		unsigned int	newr;		newr = NEXT_VAL(unsigned int);		if (newr <= xTrue)		    image->repeat = newr;		else		{		    *error_value = newr;		    error = BadValue;		}	    }	    break;	case CPAlphaMap:	    {		pixman_image_t *iAlpha;		iAlpha = NEXT_PTR(pixman_image_t *);		if (iAlpha)		    iAlpha->refcnt++;		if (image->alphaMap)		    pixman_image_destroy ((void *) image->alphaMap);		image->alphaMap = iAlpha;	    }	    break;	case CPAlphaXOrigin:	    image->alphaOrigin.x = NEXT_VAL(int16_t);	    break;	case CPAlphaYOrigin:	    image->alphaOrigin.y = NEXT_VAL(int16_t);	    break;	case CPClipXOrigin:	    image->clipOrigin.x = NEXT_VAL(int16_t);	    break;	case CPClipYOrigin:	    image->clipOrigin.y = NEXT_VAL(int16_t);	    break;	case CPClipMask:	    {		pixman_image_t	    *mask;		int	    clipType;		mask = NEXT_PTR(pixman_image_t *);		if (mask) {		    clipType = CT_PIXMAP;		    mask->refcnt++;		} else {		    clipType = CT_NONE;		}		error = pixman_image_change_clip (image, clipType,					   (void *)mask, 0);		break;	    }	case CPGraphicsExposure:	    {		unsigned int	newe;		newe = NEXT_VAL(unsigned int);		if (newe <= xTrue)		    image->graphicsExposures = newe;		else		{		    *error_value = newe;		    error = BadValue;		}	    }	    break;	case CPSubwindowMode:	    {		unsigned int	news;		news = NEXT_VAL(unsigned int);		if (news == ClipByChildren || news == IncludeInferiors)		    image->subWindowMode = news;		else		{		    *error_value = news;		    error = BadValue;		}	    }	    break;	case CPPolyEdge:	    {		unsigned int	newe;		newe = NEXT_VAL(unsigned int);		if (newe == PolyEdgeSharp || newe == PolyEdgeSmooth)		    image->polyEdge = newe;		else		{		    *error_value = newe;		    error = BadValue;		}	    }	    break;	case CPPolyMode:	    {		unsigned int	newm;		newm = NEXT_VAL(unsigned int);		if (newm == PolyModePrecise || newm == PolyModeImprecise)		    image->polyMode = newm;		else		{		    *error_value = newm;		    error = BadValue;		}	    }	    break;	case CPDither:	    image->dither = NEXT_VAL(unsigned long);	    break;	case CPComponentAlpha:	    {		unsigned int	newca;		newca = NEXT_VAL (unsigned int);		if (newca <= xTrue)		    image->componentAlpha = newca;		else		{		    *error_value = newca;		    error = BadValue;		}	    }	    break;	default:	    *error_value = maskQ;	    error = BadValue;	    break;	}    }    return error;}*//* XXX: Do we need this?intSetPictureClipRects (PicturePtr	pPicture,		     int	xOrigin,		     int	yOrigin,		     int	nRect,		     xRectangle	*rects){    ScreenPtr		pScreen = pPicture->pDrawable->pScreen;    PictureScreenPtr	ps = GetPictureScreen(pScreen);    pixman_region16_t		*clientClip;    int			result;    clientClip = RECTS_TO_REGION(pScreen,				 nRect, rects, CT_UNSORTED);    if (!clientClip)	return 1;    result =(*ps->ChangePictureClip) (pPicture, CT_REGION,				      (void *) clientClip, 0);    if (result == 0)    {	pPicture->clipOrigin.x = xOrigin;	pPicture->clipOrigin.y = yOrigin;	pPicture->stateChanges |= CPClipXOrigin|CPClipYOrigin|CPClipMask;	pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;    }    return result;}*/intFbComputeCompositeRegion (pixman_region16_t	*region,			  pixman_image_t	*iSrc,			  pixman_image_t	*iMask,			  pixman_image_t	*iDst,			  int16_t		xSrc,			  int16_t		ySrc,			  int16_t		xMask,			  int16_t		yMask,			  int16_t		xDst,			  int16_t		yDst,			  uint16_t	width,			  uint16_t	height){    int		v;    int x1, y1, x2, y2;    /* XXX: This code previously directly set the extents of the       region here. I need to decide whether removing that has broken       this. Also, it might be necessary to just make the pixman_region16_t       data structure transparent anyway in which case I can just put       the code back. */    x1 = xDst;    v = xDst + width;    x2 = BOUND(v);    y1 = yDst;    v = yDst + height;    y2 = BOUND(v);    /* Check for empty operation */    if (x1 >= x2 ||	y1 >= y2)    {	pixman_region_empty (region);	return 1;    }    /* clip against src */    if (!FbClipImageSrc (region, iSrc, xDst - xSrc, yDst - ySrc))    {	pixman_region_destroy (region);	return 0;    }    if (iSrc->alphaMap)    {	if (!FbClipImageSrc (region, iSrc->alphaMap,			     xDst - (xSrc + iSrc->alphaOrigin.x),			     yDst - (ySrc + iSrc->alphaOrigin.y)))	{	    pixman_region_destroy (region);	    return 0;	}    }    /* clip against mask */    if (iMask)    {	if (!FbClipImageSrc (region, iMask, xDst - xMask, yDst - yMask))	{	    pixman_region_destroy (region);	    return 0;	}	if (iMask->alphaMap)	{	    if (!FbClipImageSrc (region, iMask->alphaMap,				 xDst - (xMask + iMask->alphaOrigin.x),				 yDst - (yMask + iMask->alphaOrigin.y)))	    {		pixman_region_destroy (region);		return 0;	    }	}    }    if (!FbClipImageReg (region, iDst->pCompositeClip, 0, 0))    {	pixman_region_destroy (region);	return 0;    }    if (iDst->alphaMap)    {	if (!FbClipImageReg (region, iDst->alphaMap->pCompositeClip,			     -iDst->alphaOrigin.x,			     -iDst->alphaOrigin.y))	{	    pixman_region_destroy (region);	    return 0;	}    }    return 1;}intmiIsSolidAlpha (pixman_image_t *src){    char	line[1];    /* Alpha-only */    if (PICT_FORMAT_TYPE (src->format_code) != PICT_TYPE_A)	return 0;    /* repeat */    if (!src->repeat)	return 0;    /* 1x1 */    if (src->pixels->width != 1 || src->pixels->height != 1)	return 0;    line[0] = 1;    /* XXX: For the next line, fb has:	(*pScreen->GetImage) (src->pixels, 0, 0, 1, 1, ZPixmap, ~0L, line);       Is the following simple assignment sufficient?    */    line[0] = src->pixels->data[0];    switch (src->pixels->bpp) {    case 1:	return (uint8_t) line[0] == 1 || (uint8_t) line[0] == 0x80;    case 4:	return (uint8_t) line[0] == 0xf || (uint8_t) line[0] == 0xf0;    case 8:	return (uint8_t) line[0] == 0xff;    default:	return 0;    }}

⌨️ 快捷键说明

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