📄 tcglyph.c
字号:
hardware->pixel_write_replacement_rule = XHP_NewRule[GXcopy][4]; hardware->write_enable = zmask & ~pGC->fgPixel; hardware->pixel_write_replacement_rule = XHP_NewRule[GXcopy][5]; hardware->frame_buf_write_enable = zmask; for (; slen--; pci = *ppci++) { int gwidth = GLYPHWIDTHPIXELS(pci); int gheight = GLYPHHEIGHTPIXELS(pci); int rowBytes = GLYPHWIDTHBYTESPADDED(pci); int height = gheight; int glyphy = dsty - pci->metrics.ascent; if (glyphy < pBox->y1) { dy = pBox->y1 - glyphy; height -= dy; glyphy = pBox->y1; if (height <= 0) { charx += pci->metrics.characterWidth; dx = 0; if (charx >= pBox->x2) break; continue; } } else dy = 0; if (glyphy+height > pBox->y2) { height = pBox->y2 - glyphy; if (height <= 0) { charx += pci->metrics.characterWidth; dx = 0; if (charx >= pBox->x2) break; continue; } } /* get address of first glyph row in the clip rect */ pGlyph = pGlyphBase + pci->byteOffset + dy * rowBytes; base = (u_char *) DispAddr(pDraw->pScreen, charx + pci->metrics.leftSideBearing + dx, glyphy); /* * clip to right edge */ if ((charx+gwidth+pci->metrics.leftSideBearing) > pBox->x2) { gwidth = pBox->x2 - (charx+pci->metrics.leftSideBearing); if (gwidth <= 0) break; } if (gwidth > dx) { int wholeBytes; unsigned char srcbyte; char *pNextByte; if ((!XHP_QUADALIGN || ((unsigned int)base & 0x01)) && !dx && (wholeBytes = gwidth / 8)) { int trailingBits = gwidth - (wholeBytes << 3); unsigned char srcbyte; for (;height--; pGlyph += rowBytes, base += stride) { register unsigned int *pdstInt = (unsigned int *) base; srcbyte = *(pNextByte = pGlyph); pNextByte++; for (i = wholeBytes; i--; srcbyte = *pNextByte++) { *pdstInt++ = XHP_pmap[srcbyte][0]; *pdstInt++ = XHP_pmap[srcbyte][1]; } if (trailingBits) { dest = (u_char *) pdstInt; for (i = 0; i < trailingBits; i++) { if (srcbyte & trailMasks[i]) *dest++ = 0xff; else dest++; } } } } else { while (height--) { register j; srcbyte = *(pNextByte = pGlyph + (dx / 8)) << (dx % 8); pNextByte++; pGlyph += rowBytes; dest = base; base += stride; i = dx & 7; j = gwidth - dx; while(j--) { if (i++ == 8) { srcbyte = *pNextByte++; i = 1; } if (srcbyte & 128) *dest++ = 0xff; else dest++; srcbyte <<= 1; } } } } charx += pci->metrics.characterWidth; dx = 0; if (charx >= pBox->x2) slen = 0; /* kind of slimey break from loop */ } } } hardware->frame_buf_write_enable = 0xff;#endif}voidtcImageGlyphBlt(pDraw, pGC, dstx, dsty, nglyph, ppCI, pGlyphBase) DrawablePtr pDraw; register GC *pGC; unsigned int dstx, dsty; unsigned int nglyph; CharInfoPtr *ppCI; char *pGlyphBase;{#if 0 xRectangle backrect; RegionPtr pRegion = ((cfbPrivGC *) pGC->devPrivates[cfbGCPrivateIndex].ptr)->pCompositeClip; register BoxPtr pBox; int nbox; TOPCAT *hardware = getTcHardware(pDraw->pScreen); unsigned long screenPlanes = getPlanesMask(pDraw->pScreen); unsigned long zmask = pGC->planemask & screenPlanes; u_char *dest, *base; int stride = ((hpPrivScreen *)(pDraw->pScreen->devPrivate))->stride; register int i, x, y, dx, dy, h, w, dyBytes; int fontAscent = FONTASCENT(pGC->font); int glyphWidth, gwidth, height; int rowBytes = GLYPHWIDTHBYTESPADDED((*ppCI)); if (!nglyph) return; if (!TERMINALFONT(pGC->font)) { /* * if the font isn't a terminal font, then call the routine that * knows how to deal with variable-width fonts */ tcImageVarGlyph(pDraw, pGC, dstx, dsty, nglyph, ppCI, pGlyphBase); return; } if (pGC->miTranslate) { /* absolutize the coordinates */ dstx += pDraw->x; dsty += pDraw->y; } backrect.x = dstx; backrect.y = dsty - fontAscent; backrect.width = nglyph * (glyphWidth = (FONTMAXBOUNDS(pGC->font,rightSideBearing) - FONTMINBOUNDS(pGC->font,leftSideBearing))); backrect.height = fontAscent + FONTDESCENT(pGC->font); waitbusy(screenPlanes, hardware); /* wait for all planes to quiet */ /* * set registers to get proper foreground/background colors */ if (pGC->bgPixel == -1) { /* * handle special case of PolyText, so PolyText can be fast if * it uses a solid fill */ hardware->write_enable = zmask & pGC->fgPixel; hardware->pixel_write_replacement_rule = XHP_NewRule[pGC->alu][4]; hardware->write_enable = zmask & ~pGC->fgPixel; hardware->pixel_write_replacement_rule = XHP_NewRule[pGC->alu][5]; } else { /* * Set registers for normal ImageText case. Note that pGC->alu * is ignored, and GXcopy is forced. */ hardware->write_enable = zmask & ~pGC->fgPixel & ~pGC->bgPixel; hardware->pixel_write_replacement_rule = XHP_NewRule[GXcopy] [0]; hardware->write_enable = zmask & ~pGC->fgPixel & pGC->bgPixel; hardware->pixel_write_replacement_rule = XHP_NewRule[GXcopy] [1]; hardware->write_enable = zmask & pGC->fgPixel & ~pGC->bgPixel; hardware->pixel_write_replacement_rule = XHP_NewRule[GXcopy] [2]; hardware->write_enable = zmask & pGC->fgPixel & pGC->bgPixel; hardware->pixel_write_replacement_rule = XHP_NewRule[GXcopy] [3]; } hardware->write_enable = zmask; /* XXX for catseye */ hardware->frame_buf_write_enable = zmask; for (nbox = REGION_NUM_RECTS(pRegion), pBox = REGION_RECTS(pRegion); nbox--; pBox++) { /* * for each rectangle in the list of clip rects, block fill the * background for the characters and put down the foreground pixels * from the glyphs */ x = backrect.x; y = backrect.y; w = glyphWidth; h = backrect.height; dx = 0; dy = 0; /* * clip the height once since all chars are the same height */ if (y < pBox->y1) { dy = pBox->y1 - y; h -= dy; if (h <= 0) continue; y = pBox->y1; } if (y+h > pBox->y2) { h = pBox->y2 - y; if (h <= 0) continue; } if (h > 0) { int charx = dstx; int slen = nglyph; register CharInfoPtr *ppci = ppCI; register CharInfoPtr pci; char *pGlyph; int wholeBytes = w >> 3; int trailingBits = w - (wholeBytes << 3); u_char *stringBase; dyBytes = dy * rowBytes; /* * while the character is to the left of the clipping rectangle, * go to the next character */ while (charx + w <= pBox->x1) { if (--slen == 0) break; charx += w; *ppci++; } if (!slen) continue; /* * clip the first (partially) in char to the left edge of pBox */ if ((dx = pBox->x1 - charx) < 0) dx = 0; if (charx+dx >= pBox->x2) continue; /* * trim string length to right edge of pBox */ if ((charx + w * slen) >= pBox->x2) { /* compute ceiling((pBox->x2 - charx)/w) */ slen = min((pBox->x2 - charx + w - 1)/w, slen); if (slen <= 0) continue; } stringBase = (u_char *) DispAddr(pDraw->pScreen, charx, y); for (base = stringBase + dx, gwidth = w, pci = *ppci++; slen--; dx = 0, charx += w, pci = *ppci++, base = (stringBase += w)) { height = h; /* get address of first glyph row in the clip rect */ pGlyph = pGlyphBase + pci->byteOffset + dyBytes; /* * clip the last character to the right edge of pBox */ if (!slen) { if ((charx+gwidth) > pBox->x2) { if ((gwidth = pBox->x2 - charx) <= 0) break; wholeBytes = gwidth >> 3; trailingBits = gwidth - (wholeBytes << 3); } } if (gwidth > dx) { unsigned char srcbyte; char *pNextByte; if ((!XHP_QUADALIGN || !((unsigned int)base & 0x01)) && !dx && wholeBytes) { unsigned char srcbyte; for (;height--; pGlyph += rowBytes, base += stride) { register unsigned int *pdstInt = (unsigned int *) base; srcbyte = *(pNextByte = pGlyph); pNextByte++; for (i = wholeBytes; i--; srcbyte = *pNextByte++) { *pdstInt++ = XHP_pmap[srcbyte][0]; *pdstInt++ = XHP_pmap[srcbyte][1]; } if (trailingBits) { dest = (u_char *) pdstInt; for (i = 0; i < trailingBits; i++) { if (srcbyte & trailMasks[i]) *dest++ = 0xff; else *dest++ = 0x00; } } } } else { while (height--) { register j; srcbyte = *(pNextByte = pGlyph + (dx / 8)) << (dx % 8); pNextByte++; pGlyph += rowBytes; dest = base; base += stride; i = dx & 7; j = gwidth - dx; while (j--) { if (i++ == 8) { srcbyte = *pNextByte++; i = 1; } if (srcbyte & 128) *dest++ = 0xff; else *dest++ = 0x00; srcbyte <<= 1; } } } } } } } hardware->frame_buf_write_enable = 0xff;#endif}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -