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

📄 draw.c

📁 远程桌面连接工具
💻 C
📖 第 1 页 / 共 4 页
字号:
		    rects[i].width = x2 - x1 + 1 + 2 * extra;		}		if (y1 > y2) {		    rects[i].y = y2 - extra;		    rects[i].height = y1 - y2 + 1 + 2 * extra;		} else {		    rects[i].y = y1 - extra;		    rects[i].height = y2 - y1 + 1 + 2 * extra;		}		x1 = x2;		y1 = y2;	    }	}	tmpRegion = RECTS_TO_REGION(pDrawable->pScreen, nlines, rects,CT_NONE);	REGION_INTERSECT(pDrawable->pScreen, tmpRegion, tmpRegion,			 WINDOW_CLIP_REGION((WindowPtr)pDrawable,pGC));	ADD_TO_MODIFIED_REGION(pDrawable->pScreen, tmpRegion);	REGION_DESTROY(pDrawable->pScreen, tmpRegion);	xfree((char *)rects);    }    (*pGC->ops->Polylines) (pDrawable, pGC, mode, npt, ppts);    if (npt) {	SCHEDULE_FB_UPDATE(pDrawable->pScreen, prfb);    }    GC_OP_EPILOGUE(pGC);}/* * PolySegment - take the union of bounding boxes around each segment (and * clip). */static voidrfbPolySegment(pDrawable, pGC, nseg, segs)    DrawablePtr pDrawable;    GCPtr 	pGC;    int		nseg;    xSegment	*segs;{    RegionPtr tmpRegion;    xRectangle *rects;    int i, extra, lw;    GC_OP_PROLOGUE(pDrawable, pGC);    TRC((stderr,"rfbPolySegment called\n"));    if (nseg) {	rects = (xRectangle *)xalloc(nseg*sizeof(xRectangle));	if (!rects) {	    FatalError("rfbPolySegment: xalloc failed\n");	}	lw = pGC->lineWidth;	if (lw == 0)	    lw = 1;	extra = lw / 2;	for (i = 0; i < nseg; i++)	{	    if (segs[i].x1 > segs[i].x2) {		rects[i].x = segs[i].x2 - extra + pDrawable->x;		rects[i].width = segs[i].x1 - segs[i].x2 + 1 + 2 * extra;	    } else {		rects[i].x = segs[i].x1 - extra + pDrawable->x;		rects[i].width = segs[i].x2 - segs[i].x1 + 1 + 2 * extra;	    }	    if (segs[i].y1 > segs[i].y2) {		rects[i].y = segs[i].y2 - extra + pDrawable->y;		rects[i].height = segs[i].y1 - segs[i].y2 + 1 + 2 * extra;	    } else {		rects[i].y = segs[i].y1 - extra + pDrawable->y;		rects[i].height = segs[i].y2 - segs[i].y1 + 1 + 2 * extra;	    }	}	tmpRegion = RECTS_TO_REGION(pDrawable->pScreen, nseg, rects, CT_NONE);	REGION_INTERSECT(pDrawable->pScreen, tmpRegion, tmpRegion,			 WINDOW_CLIP_REGION((WindowPtr)pDrawable,pGC));	ADD_TO_MODIFIED_REGION(pDrawable->pScreen, tmpRegion);	REGION_DESTROY(pDrawable->pScreen, tmpRegion);	xfree((char *)rects);    }    (*pGC->ops->PolySegment) (pDrawable, pGC, nseg, segs);    if (nseg) {	SCHEDULE_FB_UPDATE(pDrawable->pScreen, prfb);    }    GC_OP_EPILOGUE(pGC);}/* * PolyRectangle (rectangle outlines) - take the union of bounding boxes * around each line (and clip). */static voidrfbPolyRectangle(pDrawable, pGC, nrects, rects)    DrawablePtr	pDrawable;    GCPtr	pGC;    int		nrects;    xRectangle	*rects;{    int i, extra, lw;    RegionPtr tmpRegion;    xRectangle *regRects;    GC_OP_PROLOGUE(pDrawable, pGC);    TRC((stderr,"rfbPolyRectangle called\n"));    if (nrects) {	regRects = (xRectangle *)xalloc(nrects*4*sizeof(xRectangle));	if (!regRects) {	    FatalError("rfbPolyRectangle: xalloc failed\n");	}	lw = pGC->lineWidth;	if (lw == 0)	    lw = 1;	extra = lw / 2;	for (i = 0; i < nrects; i++)	{	    regRects[i*4].x = rects[i].x - extra + pDrawable->x;	    regRects[i*4].y = rects[i].y - extra + pDrawable->y;	    regRects[i*4].width = rects[i].width + 1 + 2 * extra;	    regRects[i*4].height = 1 + 2 * extra;	    regRects[i*4+1].x = rects[i].x - extra + pDrawable->x;	    regRects[i*4+1].y = rects[i].y - extra + pDrawable->y;	    regRects[i*4+1].width = 1 + 2 * extra;	    regRects[i*4+1].height = rects[i].height + 1 + 2 * extra;	    regRects[i*4+2].x		= rects[i].x + rects[i].width - extra + pDrawable->x;	    regRects[i*4+2].y = rects[i].y - extra + pDrawable->y;	    regRects[i*4+2].width = 1 + 2 * extra;	    regRects[i*4+2].height = rects[i].height + 1 + 2 * extra;	    regRects[i*4+3].x = rects[i].x - extra + pDrawable->x;	    regRects[i*4+3].y		= rects[i].y + rects[i].height - extra + pDrawable->y;	    regRects[i*4+3].width = rects[i].width + 1 + 2 * extra;	    regRects[i*4+3].height = 1 + 2 * extra;	}	tmpRegion = RECTS_TO_REGION(pDrawable->pScreen, nrects*4,				    regRects, CT_NONE);	REGION_INTERSECT(pDrawable->pScreen, tmpRegion, tmpRegion,			 WINDOW_CLIP_REGION((WindowPtr)pDrawable,pGC));	ADD_TO_MODIFIED_REGION(pDrawable->pScreen, tmpRegion);	REGION_DESTROY(pDrawable->pScreen, tmpRegion);	xfree((char *)regRects);    }    (*pGC->ops->PolyRectangle) (pDrawable, pGC, nrects, rects);    if (nrects) {	SCHEDULE_FB_UPDATE(pDrawable->pScreen, prfb);    }    GC_OP_EPILOGUE(pGC);}/* * PolyArc - take the union of bounding boxes around each arc (and clip). * Bounding boxes assume each is a full circle / ellipse. */static voidrfbPolyArc(pDrawable, pGC, narcs, arcs)    DrawablePtr	pDrawable;    register GCPtr	pGC;    int		narcs;    xArc	*arcs;{    int i, extra, lw;    RegionPtr tmpRegion;    xRectangle *rects;    GC_OP_PROLOGUE(pDrawable, pGC);    TRC((stderr,"rfbPolyArc called\n"));    if (narcs) {	rects = (xRectangle *)xalloc(narcs*sizeof(xRectangle));	if (!rects) {	    FatalError("rfbPolyArc: xalloc failed\n");	}	lw = pGC->lineWidth;	if (lw == 0)	    lw = 1;	extra = lw / 2;	for (i = 0; i < narcs; i++)	{	    rects[i].x = arcs[i].x - extra + pDrawable->x;	    rects[i].y = arcs[i].y - extra + pDrawable->y;	    rects[i].width = arcs[i].width + lw;	    rects[i].height = arcs[i].height + lw;	}	tmpRegion = RECTS_TO_REGION(pDrawable->pScreen, narcs, rects, CT_NONE);	REGION_INTERSECT(pDrawable->pScreen, tmpRegion, tmpRegion,			 WINDOW_CLIP_REGION((WindowPtr)pDrawable,pGC));	ADD_TO_MODIFIED_REGION(pDrawable->pScreen, tmpRegion);	REGION_DESTROY(pDrawable->pScreen, tmpRegion);	xfree((char *)rects);    }    (*pGC->ops->PolyArc) (pDrawable, pGC, narcs, arcs);    if (narcs) {	SCHEDULE_FB_UPDATE(pDrawable->pScreen, prfb);    }    GC_OP_EPILOGUE(pGC);}/* * FillPolygon - take bounding box around polygon (and clip). */static voidrfbFillPolygon(pDrawable, pGC, shape, mode, count, pts)    register DrawablePtr pDrawable;    register GCPtr	pGC;    int			shape, mode;    int			count;    DDXPointPtr		pts;{    int i;    RegionRec tmpRegion;    BoxRec box;    GC_OP_PROLOGUE(pDrawable, pGC);    TRC((stderr,"rfbFillPolygon called\n"));    if (count) {	int minX = pts[0].x, maxX = pts[0].x;	int minY = pts[0].y, maxY = pts[0].y;	if (mode == CoordModePrevious)	{	    int x = pts[0].x, y = pts[0].y;	    for (i = 1; i < count; i++) {		x += pts[i].x;		y += pts[i].y;		if (x < minX) minX = x;		if (x > maxX) maxX = x;		if (y < minY) minY = y;		if (y > maxY) maxY = y;	    }	}	else	{	    for (i = 1; i < count; i++) {		if (pts[i].x < minX) minX = pts[i].x;		if (pts[i].x > maxX) maxX = pts[i].x;		if (pts[i].y < minY) minY = pts[i].y;		if (pts[i].y > maxY) maxY = pts[i].y;	    }	}	box.x1 = minX + pDrawable->x;	box.y1 = minY + pDrawable->y;	box.x2 = maxX + 1 + pDrawable->x;	box.y2 = maxY + 1 + pDrawable->y;	SAFE_REGION_INIT(pDrawable->pScreen, &tmpRegion, &box, 0);	REGION_INTERSECT(pDrawable->pScreen, &tmpRegion, &tmpRegion,			 WINDOW_CLIP_REGION(((WindowPtr)pDrawable),pGC));	ADD_TO_MODIFIED_REGION(pDrawable->pScreen, &tmpRegion);	REGION_UNINIT(pDrawable->pScreen, &tmpRegion);    }    (*pGC->ops->FillPolygon) (pDrawable, pGC, shape, mode, count, pts);    if (count) {	SCHEDULE_FB_UPDATE(pDrawable->pScreen, prfb);    }    GC_OP_EPILOGUE(pGC);}/* * PolyFillRect - take the union of the given rectangles (and clip). */static voidrfbPolyFillRect(pDrawable, pGC, nrects, rects)    DrawablePtr pDrawable;    GCPtr	pGC;    int		nrects;    xRectangle	*rects;{    RegionPtr tmpRegion;    xRectangle *regRects;    int i;    GC_OP_PROLOGUE(pDrawable, pGC);    TRC((stderr,"rfbPolyFillRect called\n"));    if (nrects) {	regRects = (xRectangle *)xalloc(nrects*sizeof(xRectangle));	if (!regRects) {	    FatalError("rfbPolyFillRect: xalloc failed\n");	}	for (i = 0; i < nrects; i++) {	    regRects[i].x = rects[i].x + pDrawable->x;	    regRects[i].y = rects[i].y + pDrawable->y;	    regRects[i].width = rects[i].width;	    regRects[i].height = rects[i].height;	}	tmpRegion = RECTS_TO_REGION(pDrawable->pScreen, nrects, regRects,				    CT_NONE);	REGION_INTERSECT(pDrawable->pScreen, tmpRegion, tmpRegion,			 WINDOW_CLIP_REGION((WindowPtr)pDrawable,pGC));	ADD_TO_MODIFIED_REGION(pDrawable->pScreen, tmpRegion);	REGION_DESTROY(pDrawable->pScreen, tmpRegion);	xfree((char *)regRects);    }    (*pGC->ops->PolyFillRect) (pDrawable, pGC, nrects, rects);    if (nrects) {	SCHEDULE_FB_UPDATE(pDrawable->pScreen, prfb);    }    GC_OP_EPILOGUE(pGC);}/* * PolyFillArc - take the union of bounding boxes around each arc (and clip). * Bounding boxes assume each is a full circle / ellipse. */static voidrfbPolyFillArc(pDrawable, pGC, narcs, arcs)    DrawablePtr	pDrawable;    GCPtr	pGC;    int		narcs;    xArc	*arcs;{    int i, extra, lw;    RegionPtr tmpRegion;    xRectangle *rects;    GC_OP_PROLOGUE(pDrawable, pGC);    TRC((stderr,"rfbPolyFillArc called\n"));    if (narcs) {	rects = (xRectangle *)xalloc(narcs*sizeof(xRectangle));	if (!rects) {	    FatalError("rfbPolyFillArc: xalloc failed\n");	}	lw = pGC->lineWidth;	if (lw == 0)	    lw = 1;	extra = lw / 2;	for (i = 0; i < narcs; i++)	{	    rects[i].x = arcs[i].x - extra + pDrawable->x;	    rects[i].y = arcs[i].y - extra + pDrawable->y;	    rects[i].width = arcs[i].width + lw;	    rects[i].height = arcs[i].height + lw;	}	tmpRegion = RECTS_TO_REGION(pDrawable->pScreen, narcs, rects, CT_NONE);	REGION_INTERSECT(pDrawable->pScreen, tmpRegion, tmpRegion,			 WINDOW_CLIP_REGION((WindowPtr)pDrawable,pGC));	ADD_TO_MODIFIED_REGION(pDrawable->pScreen, tmpRegion);	REGION_DESTROY(pDrawable->pScreen, tmpRegion);	xfree((char *)rects);    }    (*pGC->ops->PolyFillArc) (pDrawable, pGC, narcs, arcs);    if (narcs) {	SCHEDULE_FB_UPDATE(pDrawable->pScreen, prfb);    }    GC_OP_EPILOGUE(pGC);}/* * Get a rough bounding box around n characters of the given font. */static void GetTextBoundingBox(pDrawable, font, x, y, n, pbox)    DrawablePtr pDrawable;    FontPtr font;    int x, y, n;    BoxPtr pbox;{    int maxAscent, maxDescent, maxCharWidth;    if (FONTASCENT(font) > FONTMAXBOUNDS(font,ascent))	maxAscent = FONTASCENT(font);    else	maxAscent = FONTMAXBOUNDS(font,ascent);    if (FONTDESCENT(font) > FONTMAXBOUNDS(font,descent))	maxDescent = FONTDESCENT(font);    else	maxDescent = FONTMAXBOUNDS(font,descent);    if (FONTMAXBOUNDS(font,rightSideBearing) > FONTMAXBOUNDS(font,characterWidth))	maxCharWidth = FONTMAXBOUNDS(font,rightSideBearing);    else	maxCharWidth = FONTMAXBOUNDS(font,characterWidth);    pbox->x1 = pDrawable->x + x;    pbox->y1 = pDrawable->y + y - maxAscent;    pbox->x2 = pbox->x1 + maxCharWidth * n;    pbox->y2 = pbox->y1 + maxAscent + maxDescent;    if (FONTMINBOUNDS(font,leftSideBearing) < 0) {	pbox->x1 += FONTMINBOUNDS(font,leftSideBearing);    }}/* * PolyText8 - use rough bounding box. */static intrfbPolyText8(pDrawable, pGC, x, y, count, chars)    DrawablePtr pDrawable;    GCPtr	pGC;    int		x, y;    int 	count;    char	*chars;{    int	ret;    RegionRec tmpRegion;    BoxRec box;

⌨️ 快捷键说明

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