📄 hpsprite.c
字号:
(*pGC->ops->PolySegment) (pDrawable, pGC, nseg, pSegs); GC_OP_EPILOGUE (pGC);}static voidhpSpritePolyRectangle(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)) { (*pScreenPriv->CursorOff) (pDrawable->pScreen); break; } } } GC_OP_PROLOGUE (pGC); (*pGC->ops->PolyRectangle) (pDrawable, pGC, nrects, pRects); GC_OP_EPILOGUE (pGC);}static voidhpSpritePolyArc(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)) { (*pScreenPriv->CursorOff) (pDrawable->pScreen); break; } } } GC_OP_PROLOGUE (pGC); (*pGC->ops->PolyArc) (pDrawable, pGC, narcs, parcs); GC_OP_EPILOGUE (pGC);}static voidhpSpriteFillPolygon(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)) (*pScreenPriv->CursorOff) (pDrawable->pScreen); } GC_OP_PROLOGUE (pGC); (*pGC->ops->FillPolygon) (pDrawable, pGC, shape, mode, count, pPts); GC_OP_EPILOGUE (pGC);}static voidhpSpritePolyFillRect(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)){ (*pScreenPriv->CursorOff) (pDrawable->pScreen); break; } } } GC_OP_PROLOGUE (pGC); (*pGC->ops->PolyFillRect) (pDrawable, pGC, nrectFill, prectInit); GC_OP_EPILOGUE (pGC);}static voidhpSpritePolyFillArc(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)) { (*pScreenPriv->CursorOff) (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 BoolhpSpriteTextOverlap (pDraw, font, x, y, n, charinfo, imageblt, w, cursorBox) DrawablePtr pDraw; FontPtr font; int x, y; unsigned long 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); if (imageblt) { if (extents.overallWidth > extents.overallRight) extents.overallRight = extents.overallWidth; if (extents.overallWidth < extents.overallLeft) extents.overallLeft = extents.overallWidth; if (extents.overallLeft > 0) extents.overallLeft = 0; if (extents.fontAscent > extents.overallAscent) extents.overallAscent = extents.fontAscent; if (extents.fontDescent > extents.overallDescent) extents.overallDescent = extents.fontDescent; } return (BOX_OVERLAP(cursorBox, x + extents.overallLeft, y - extents.overallAscent, x + extents.overallRight, y + extents.overallDescent));}/* * values for textType: */#define TT_POLY8 0#define TT_IMAGE8 1#define TT_POLY16 2#define TT_IMAGE16 3static int hpSpriteText (pDraw, pGC, x, y, count, chars, fontEncoding, textType, cursorBox) DrawablePtr pDraw; GCPtr pGC; int x, y; unsigned long count; char *chars; FontEncoding fontEncoding; Bool textType; BoxPtr cursorBox;{ CharInfoPtr *charinfo; register CharInfoPtr *info; unsigned long n, i; unsigned int w; void (*drawFunc)(); Bool imageblt; imageblt = (textType == TT_IMAGE8) || (textType == TT_IMAGE16); charinfo = (CharInfoPtr *) ALLOCATE_LOCAL(count * sizeof(CharInfoPtr)); if (!charinfo) return x; GetGlyphs(pGC->font, count, (unsigned char *)chars, fontEncoding, &n, charinfo); w = 0; if (!imageblt) for (info = charinfo, i = n; i--; info++) w += (*info)->metrics.characterWidth; if (n != 0) { if (hpSpriteTextOverlap(pDraw, pGC->font, x, y, n, charinfo, imageblt, w, cursorBox)) (*getPrivScreenPtr(pDraw->pScreen)->CursorOff) (pDraw->pScreen);#define AVOID_GLYPHBLT#ifdef AVOID_GLYPHBLT /* * On displays like Apollos, which do not optimize the GlyphBlt functions because they * convert fonts to their internal form in RealizeFont and optimize text directly, we * want to invoke the text functions here, not the GlyphBlt functions. */ switch (textType) { case TT_POLY8: drawFunc = pGC->ops->PolyText8; break; case TT_IMAGE8: drawFunc = pGC->ops->ImageText8; break; case TT_POLY16: drawFunc = pGC->ops->PolyText16; break; case TT_IMAGE16: drawFunc = pGC->ops->ImageText16; break; } (*drawFunc) (pDraw, pGC, x, y, (int) count, chars);#else /* don't AVOID_GLYPHBLT */ /* * On the other hand, if the device does use GlyphBlt ultimately to do text, we * don't want to slow it down by invoking the text functions and having them call * GetGlyphs all over again, so we go directly to the GlyphBlt functions here. */ drawFunc = imageblt ? pGC->ops->ImageGlyphBlt : pGC->ops->PolyGlyphBlt; (*drawFunc) (pDraw, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font));#endif /* AVOID_GLYPHBLT */ } DEALLOCATE_LOCAL(charinfo); return x + w;}static inthpSpritePolyText8(pDrawable, pGC, x, y, count, chars) DrawablePtr pDrawable; GCPtr pGC; int x, y; int count; char *chars;{ int ret; GC_SETUP (pDrawable, pGC); GC_OP_PROLOGUE (pGC); if (GC_CHECK((WindowPtr) pDrawable)) ret = hpSpriteText (pDrawable, pGC, x, y, (unsigned long)count, chars, Linear8Bit, TT_POLY8, &pScreenPriv->saved); else ret = (*pGC->ops->PolyText8) (pDrawable, pGC, x, y, count, chars); GC_OP_EPILOGUE (pGC); return ret;}static inthpSpritePolyText16(pDrawable, pGC, x, y, count, chars) DrawablePtr pDrawable; GCPtr pGC; int x, y; int count; unsigned short *chars;{ int ret; GC_SETUP(pDrawable, pGC); GC_OP_PROLOGUE (pGC); if (GC_CHECK((WindowPtr) pDrawable)) ret = hpSpriteText (pDrawable, pGC, x, y, (unsigned long)count, (char *)chars, FONTLASTROW(pGC->font) == 0 ? Linear16Bit : TwoD16Bit, TT_POLY16, &pScreenPriv->saved); else ret = (*pGC->ops->PolyText16) (pDrawable, pGC, x, y, count, chars); GC_OP_EPILOGUE (pGC); return ret;}static voidhpSpriteImageText8(pDrawable, pGC, x, y, count, chars) DrawablePtr pDrawable; GCPtr pGC; int x, y; int count; char *chars;{ GC_SETUP(pDrawable, pGC); GC_OP_PROLOGUE (pGC); if (GC_CHECK((WindowPtr) pDrawable)) (void) hpSpriteText (pDrawable, pGC, x, y, (unsigned long)count, chars, Linear8Bit, TT_IMAGE8, &pScreenPriv->saved); else (*pGC->ops->ImageText8) (pDrawable, pGC, x, y, count, chars); GC_OP_EPILOGUE (pGC);}static voidhpSpriteImageText16(pDrawable, pGC, x, y, count, chars) DrawablePtr pDrawable; GCPtr pGC; int x, y; int count; unsigned short *chars;{ GC_SETUP(pDrawable, pGC); GC_OP_PROLOGUE (pGC); if (GC_CHECK((WindowPtr) pDrawable)) (void) hpSpriteText (pDrawable, pGC, x, y, (unsigned long)count, (char *)chars, FONTLASTROW(pGC->font) == 0 ? Linear16Bit : TwoD16Bit, TT_IMAGE16, &pScreenPriv->saved); else (*pGC->ops->ImageText16) (pDrawable, pGC, x, y, count, chars); GC_OP_EPILOGUE (pGC);}static voidhpSpriteImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) DrawablePtr pDrawable; GC *pGC; int x, y; unsigned long nglyph; CharInfoPtr *ppci; /* array of character info */ pointer pglyphBase; /* start of array of glyphs */{ GC_SETUP(pDrawable, pGC); GC_OP_PROLOGUE (pGC); if (GC_CHECK((WindowPtr) pDrawable) && hpSpriteTextOverlap (pDrawable, pGC->font, x, y, nglyph, ppci, TRUE, 0, &pScreenPriv->saved)) { (*pScreenPriv->CursorOff) (pDrawable->pScreen); } (*pGC->ops->ImageGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); GC_OP_EPILOGUE (pGC);}static voidhpSpritePolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) DrawablePtr pDrawable; GCPtr pGC; int x, y; unsigned long nglyph; CharInfoPtr *ppci; /* array of character info */ char *pglyphBase; /* start of array of glyphs */{ GC_SETUP (pDrawable, pGC); GC_OP_PROLOGUE (pGC); if (GC_CHECK((WindowPtr) pDrawable) && hpSpriteTextOverlap (pDrawable, pGC->font, x, y, nglyph, ppci, FALSE, 0, &pScreenPriv->saved)) { (*pScreenPriv->CursorOff) (pDrawable->pScreen); } (*pGC->ops->PolyGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); GC_OP_EPILOGUE (pGC);}static voidhpSpritePushPixels(pGC, pBitMap, pDrawable, w, h, x, y) GCPtr pGC; PixmapPtr pBitMap; DrawablePtr pDrawable; int w, h, x, y;{ GC_SETUP(pDrawable, pGC); if (GC_CHECK((WindowPtr) pDrawable) && ORG_OVERLAP(&pScreenPriv->saved,pDrawable->x,pDrawable->y,x,y,w,h)) { (*pScreenPriv->CursorOff) (pDrawable->pScreen); } GC_OP_PROLOGUE (pGC); (*pGC->ops->PushPixels) (pGC, pBitMap, pDrawable, w, h, x, y); GC_OP_EPILOGUE (pGC);}/* * I don't expect this routine will ever be called, as the GC * will have been unwrapped for the line drawing */static voidhpSpriteLineHelper(){ FatalError("hpSpriteLineHelper called\n");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -