📄 sprite.c
字号:
int dstx; int dsty;{ RegionPtr rgn; GC_SETUP(pDst, pGC); /* check destination/source overlap. */ if (GC_CHECK((WindowPtr) pDst) && (ORG_OVERLAP(&pScreenPriv->saved,pDst->x,pDst->y,dstx,dsty,w,h) || ((pDst == pSrc) && ORG_OVERLAP(&pScreenPriv->saved,pSrc->x,pSrc->y,srcx,srcy,w,h)))) { rfbSpriteRemoveCursor (pDst->pScreen); } GC_OP_PROLOGUE (pGC); rgn = (*pGC->ops->CopyArea) (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty); GC_OP_EPILOGUE (pGC); return rgn;}static RegionPtrrfbSpriteCopyPlane (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty, plane) DrawablePtr pSrc; DrawablePtr pDst; register GCPtr pGC; int srcx, srcy; int w, h; int dstx, dsty; unsigned long plane;{ RegionPtr rgn; GC_SETUP(pDst, pGC); /* * check destination/source for overlap. */ if (GC_CHECK((WindowPtr) pDst) && (ORG_OVERLAP(&pScreenPriv->saved,pDst->x,pDst->y,dstx,dsty,w,h) || ((pDst == pSrc) && ORG_OVERLAP(&pScreenPriv->saved,pSrc->x,pSrc->y,srcx,srcy,w,h)))) { rfbSpriteRemoveCursor (pDst->pScreen); } GC_OP_PROLOGUE (pGC); rgn = (*pGC->ops->CopyPlane) (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty, plane); GC_OP_EPILOGUE (pGC); return rgn;}static voidrfbSpritePolyPoint (pDrawable, pGC, mode, npt, pptInit) DrawablePtr pDrawable; GCPtr pGC; int mode; /* Origin or Previous */ int npt; xPoint *pptInit;{ xPoint t; int n; BoxRec cursor; register xPoint *pts; GC_SETUP (pDrawable, pGC); if (npt && GC_CHECK((WindowPtr) pDrawable)) { cursor.x1 = pScreenPriv->saved.x1 - pDrawable->x; cursor.y1 = pScreenPriv->saved.y1 - pDrawable->y; cursor.x2 = pScreenPriv->saved.x2 - pDrawable->x; cursor.y2 = pScreenPriv->saved.y2 - pDrawable->y; if (mode == CoordModePrevious) { t.x = 0; t.y = 0; for (pts = pptInit, n = npt; n--; pts++) { t.x += pts->x; t.y += pts->y; if (cursor.x1 <= t.x && t.x <= cursor.x2 && cursor.y1 <= t.y && t.y <= cursor.y2) { rfbSpriteRemoveCursor (pDrawable->pScreen); break; } } } else { for (pts = pptInit, n = npt; n--; pts++) { if (cursor.x1 <= pts->x && pts->x <= cursor.x2 && cursor.y1 <= pts->y && pts->y <= cursor.y2) { rfbSpriteRemoveCursor (pDrawable->pScreen); break; } } } } GC_OP_PROLOGUE (pGC); (*pGC->ops->PolyPoint) (pDrawable, pGC, mode, npt, pptInit); GC_OP_EPILOGUE (pGC);}static voidrfbSpritePolylines (pDrawable, pGC, mode, npt, pptInit) DrawablePtr pDrawable; GCPtr pGC; int mode; int npt; DDXPointPtr pptInit;{ BoxPtr cursor; register DDXPointPtr pts; int n; int x, y, x1, y1, x2, y2; int lw; int extra; GC_SETUP (pDrawable, pGC); if (npt && GC_CHECK((WindowPtr) pDrawable)) { cursor = &pScreenPriv->saved; lw = pGC->lineWidth; x = pptInit->x + pDrawable->x; y = pptInit->y + pDrawable->y; if (npt == 1) { extra = lw >> 1; if (LINE_OVERLAP(cursor, x, y, x, y, extra)) rfbSpriteRemoveCursor (pDrawable->pScreen); } else { extra = lw >> 1; /* * mitered joins can project quite a way from * the line end; the 11 degree miter limit limits * this extension to 10.43 * lw / 2, rounded up * and converted to int yields 6 * lw */ if (pGC->joinStyle == JoinMiter) extra = 6 * lw; else if (pGC->capStyle == CapProjecting) extra = lw; for (pts = pptInit + 1, n = npt - 1; n--; pts++) { x1 = x; y1 = y; if (mode == CoordModeOrigin) { x2 = pDrawable->x + pts->x; y2 = pDrawable->y + pts->y; } else { x2 = x + pts->x; y2 = y + pts->y; } x = x2; y = y2; LINE_SORT(x1, y1, x2, y2); if (LINE_OVERLAP(cursor, x1, y1, x2, y2, extra)) { rfbSpriteRemoveCursor (pDrawable->pScreen); break; } } } } GC_OP_PROLOGUE (pGC); (*pGC->ops->Polylines) (pDrawable, pGC, mode, npt, pptInit); GC_OP_EPILOGUE (pGC);}static voidrfbSpritePolySegment(pDrawable, pGC, nseg, pSegs) DrawablePtr pDrawable; GCPtr pGC; int nseg; xSegment *pSegs;{ int n; register xSegment *segs; BoxPtr cursor; int x1, y1, x2, y2; int extra; GC_SETUP(pDrawable, pGC); if (nseg && GC_CHECK((WindowPtr) pDrawable)) { cursor = &pScreenPriv->saved; extra = pGC->lineWidth >> 1; if (pGC->capStyle == CapProjecting) extra = pGC->lineWidth; for (segs = pSegs, n = nseg; n--; segs++) { x1 = segs->x1 + pDrawable->x; y1 = segs->y1 + pDrawable->y; x2 = segs->x2 + pDrawable->x; y2 = segs->y2 + pDrawable->y; LINE_SORT(x1, y1, x2, y2); if (LINE_OVERLAP(cursor, x1, y1, x2, y2, extra)) { rfbSpriteRemoveCursor (pDrawable->pScreen); break; } } } GC_OP_PROLOGUE (pGC); (*pGC->ops->PolySegment) (pDrawable, pGC, nseg, pSegs); GC_OP_EPILOGUE (pGC);}static voidrfbSpritePolyRectangle(pDrawable, pGC, nrects, pRects) DrawablePtr pDrawable; GCPtr pGC; int nrects; xRectangle *pRects;{ register xRectangle *rects; BoxPtr cursor; int lw; int n; int x1, y1, x2, y2; GC_SETUP (pDrawable, pGC); if (GC_CHECK((WindowPtr) pDrawable)) { lw = pGC->lineWidth >> 1; cursor = &pScreenPriv->saved; for (rects = pRects, n = nrects; n--; rects++) { x1 = rects->x + pDrawable->x; y1 = rects->y + pDrawable->y; x2 = x1 + (int)rects->width; y2 = y1 + (int)rects->height; if (LINE_OVERLAP(cursor, x1, y1, x2, y1, lw) || LINE_OVERLAP(cursor, x2, y1, x2, y2, lw) || LINE_OVERLAP(cursor, x1, y2, x2, y2, lw) || LINE_OVERLAP(cursor, x1, y1, x1, y2, lw)) { rfbSpriteRemoveCursor (pDrawable->pScreen); break; } } } GC_OP_PROLOGUE (pGC); (*pGC->ops->PolyRectangle) (pDrawable, pGC, nrects, pRects); GC_OP_EPILOGUE (pGC);}static voidrfbSpritePolyArc(pDrawable, pGC, narcs, parcs) DrawablePtr pDrawable; register GCPtr pGC; int narcs; xArc *parcs;{ BoxPtr cursor; int lw; int n; register xArc *arcs; GC_SETUP (pDrawable, pGC); if (GC_CHECK((WindowPtr) pDrawable)) { lw = pGC->lineWidth >> 1; cursor = &pScreenPriv->saved; for (arcs = parcs, n = narcs; n--; arcs++) { if (ORG_OVERLAP (cursor, pDrawable->x, pDrawable->y, arcs->x - lw, arcs->y - lw, (int) arcs->width + pGC->lineWidth, (int) arcs->height + pGC->lineWidth)) { rfbSpriteRemoveCursor (pDrawable->pScreen); break; } } } GC_OP_PROLOGUE (pGC); (*pGC->ops->PolyArc) (pDrawable, pGC, narcs, parcs); GC_OP_EPILOGUE (pGC);}static voidrfbSpriteFillPolygon(pDrawable, pGC, shape, mode, count, pPts) register DrawablePtr pDrawable; register GCPtr pGC; int shape, mode; int count; DDXPointPtr pPts;{ int x, y, minx, miny, maxx, maxy; register DDXPointPtr pts; int n; GC_SETUP (pDrawable, pGC); if (count && GC_CHECK((WindowPtr) pDrawable)) { x = pDrawable->x; y = pDrawable->y; pts = pPts; minx = maxx = pts->x; miny = maxy = pts->y; pts++; n = count - 1; if (mode == CoordModeOrigin) { for (; n--; pts++) { if (pts->x < minx) minx = pts->x; else if (pts->x > maxx) maxx = pts->x; if (pts->y < miny) miny = pts->y; else if (pts->y > maxy) maxy = pts->y; } minx += x; miny += y; maxx += x; maxy += y; } else { x += minx; y += miny; minx = maxx = x; miny = maxy = y; for (; n--; pts++) { x += pts->x; y += pts->y; if (x < minx) minx = x; else if (x > maxx) maxx = x; if (y < miny) miny = y; else if (y > maxy) maxy = y; } } if (BOX_OVERLAP(&pScreenPriv->saved,minx,miny,maxx,maxy)) rfbSpriteRemoveCursor (pDrawable->pScreen); } GC_OP_PROLOGUE (pGC); (*pGC->ops->FillPolygon) (pDrawable, pGC, shape, mode, count, pPts); GC_OP_EPILOGUE (pGC);}static voidrfbSpritePolyFillRect(pDrawable, pGC, nrectFill, prectInit) DrawablePtr pDrawable; GCPtr pGC; int nrectFill; /* number of rectangles to fill */ xRectangle *prectInit; /* Pointer to first rectangle to fill */{ GC_SETUP(pDrawable, pGC); if (GC_CHECK((WindowPtr) pDrawable)) { register int nRect; register xRectangle *pRect; register int xorg, yorg; xorg = pDrawable->x; yorg = pDrawable->y; for (nRect = nrectFill, pRect = prectInit; nRect--; pRect++) { if (ORGRECT_OVERLAP(&pScreenPriv->saved,xorg,yorg,pRect)){ rfbSpriteRemoveCursor(pDrawable->pScreen); break; } } } GC_OP_PROLOGUE (pGC); (*pGC->ops->PolyFillRect) (pDrawable, pGC, nrectFill, prectInit); GC_OP_EPILOGUE (pGC);}static voidrfbSpritePolyFillArc(pDrawable, pGC, narcs, parcs) DrawablePtr pDrawable; GCPtr pGC; int narcs; xArc *parcs;{ GC_SETUP(pDrawable, pGC); if (GC_CHECK((WindowPtr) pDrawable)) { register int n; BoxPtr cursor; register xArc *arcs; cursor = &pScreenPriv->saved; for (arcs = parcs, n = narcs; n--; arcs++) { if (ORG_OVERLAP(cursor, pDrawable->x, pDrawable->y, arcs->x, arcs->y, (int) arcs->width, (int) arcs->height)) { rfbSpriteRemoveCursor (pDrawable->pScreen); break; } } } GC_OP_PROLOGUE (pGC); (*pGC->ops->PolyFillArc) (pDrawable, pGC, narcs, parcs); GC_OP_EPILOGUE (pGC);}/* * general Poly/Image text function. Extract glyph information, * compute bounding box and remove cursor if it is overlapped. */static BoolrfbSpriteTextOverlap (pDraw, font, x, y, n, charinfo, imageblt, w, cursorBox) DrawablePtr pDraw; FontPtr font; int x, y; unsigned int n; CharInfoPtr *charinfo; Bool imageblt; unsigned int w; BoxPtr cursorBox;{ ExtentInfoRec extents; x += pDraw->x; y += pDraw->y; if (FONTMINBOUNDS(font,characterWidth) >= 0) { /* compute an approximate (but covering) bounding box */ if (!imageblt || (charinfo[0]->metrics.leftSideBearing < 0)) extents.overallLeft = charinfo[0]->metrics.leftSideBearing; else extents.overallLeft = 0; if (w) extents.overallRight = w - charinfo[n-1]->metrics.characterWidth; else extents.overallRight = FONTMAXBOUNDS(font,characterWidth) * (n - 1); if (imageblt && (charinfo[n-1]->metrics.characterWidth > charinfo[n-1]->metrics.rightSideBearing)) extents.overallRight += charinfo[n-1]->metrics.characterWidth; else extents.overallRight += charinfo[n-1]->metrics.rightSideBearing; if (imageblt && FONTASCENT(font) > FONTMAXBOUNDS(font,ascent)) extents.overallAscent = FONTASCENT(font); else extents.overallAscent = FONTMAXBOUNDS(font, ascent); if (imageblt && FONTDESCENT(font) > FONTMAXBOUNDS(font,descent)) extents.overallDescent = FONTDESCENT(font); else extents.overallDescent = FONTMAXBOUNDS(font,descent); if (!BOX_OVERLAP(cursorBox, x + extents.overallLeft, y - extents.overallAscent, x + extents.overallRight, y + extents.overallDescent)) return FALSE; else if (imageblt && w) return TRUE; /* if it does overlap, fall through and compute exactly, because * taking down the cursor is expensive enough to make this worth it */ } QueryGlyphExtents(font, charinfo, n, &extents);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -