Annotation of researchv9/X11/src/X.V11R1/server/ddx/mfb/mfbtegblt.c, revision 1.1

1.1     ! root        1: /* $Header: mfbtegblt.c,v 1.1 87/09/11 07:48:45 toddb Exp $ */
        !             2: /***********************************************************
        !             3: Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
        !             4: and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
        !             5: 
        !             6:                         All Rights Reserved
        !             7: 
        !             8: Permission to use, copy, modify, and distribute this software and its 
        !             9: documentation for any purpose and without fee is hereby granted, 
        !            10: provided that the above copyright notice appear in all copies and that
        !            11: both that copyright notice and this permission notice appear in 
        !            12: supporting documentation, and that the names of Digital or MIT not be
        !            13: used in advertising or publicity pertaining to distribution of the
        !            14: software without specific, written prior permission.  
        !            15: 
        !            16: DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
        !            17: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
        !            18: DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
        !            19: ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
        !            20: WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
        !            21: ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
        !            22: SOFTWARE.
        !            23: 
        !            24: ******************************************************************/
        !            25: #include       "X.h"
        !            26: #include       "Xmd.h"
        !            27: #include       "Xproto.h"
        !            28: #include       "fontstruct.h"
        !            29: #include       "dixfontstr.h"
        !            30: #include       "gcstruct.h"
        !            31: #include       "windowstr.h"
        !            32: #include       "scrnintstr.h"
        !            33: #include       "pixmapstr.h"
        !            34: #include       "regionstr.h"
        !            35: #include       "mfb.h"
        !            36: #include       "maskbits.h"
        !            37: 
        !            38: /*
        !            39:     this works for fonts with glyphs <= 32 bits wide.
        !            40: 
        !            41:     This should be called only with a terminal-emulator font;
        !            42: this means that the FIXED_METRICS flag is set, and that
        !            43: glyphbounds == charbounds.
        !            44: 
        !            45:     in theory, this goes faster; even if it doesn't, it reduces the
        !            46: flicker caused by writing a string over itself with image text (since
        !            47: the background gets repainted per character instead of per string.)
        !            48: this seems to be important for some converted X10 applications.
        !            49: 
        !            50:     Image text looks at the bits in the glyph and the fg and bg in the
        !            51: GC.  it paints a rectangle, as defined in the protocol dcoument,
        !            52: and the paints the characters.
        !            53: 
        !            54:    to avoid source proliferation, this file is compiled
        !            55: two times:
        !            56:        MFBTEGLYPHBLT           OP
        !            57:        mfbTEGlyphBltWhite              (white text, black bg )
        !            58:        mfbTEGlyphBltBlack      ~       (black text, white bg )
        !            59: 
        !            60: */
        !            61: 
        !            62: void
        !            63: MFBTEGLYPHBLT(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
        !            64:     DrawablePtr pDrawable;
        !            65:     GC                 *pGC;
        !            66:     int        x, y;
        !            67:     unsigned int nglyph;
        !            68:     CharInfoPtr *ppci;         /* array of character info */
        !            69:     unsigned char *pglyphBase; /* start of array of glyphs */
        !            70: {
        !            71:     CharInfoPtr pci;
        !            72:     FontInfoPtr pfi = pGC->font->pFI;
        !            73:     int xorg, yorg;
        !            74:     int widthDst;
        !            75:     unsigned int *pdstBase;    /* pointer to longword with top row 
        !            76:                                   of current glyph */
        !            77: 
        !            78:     int w;                     /* width of glyph and char */
        !            79:     int h;                     /* height of glyph and char */
        !            80:     register int xpos;         /* current x%32  */
        !            81:     int ypos;                  /* current y%32 */
        !            82:     register unsigned char *pglyph;
        !            83:     int widthGlyph;
        !            84: 
        !            85:     register unsigned int *pdst;/* pointer to current longword in dst */
        !            86:     int hTmp;                  /* counter for height */
        !            87:     register int startmask, endmask;
        !            88:     int nfirst;                        /* used if glyphs spans a longword boundary */
        !            89:     register unsigned int tmpSrc;
        !            90:     BoxRec bbox;               /* for clipping */
        !            91: 
        !            92:     if (pDrawable->type == DRAWABLE_WINDOW)
        !            93:     {
        !            94:        xorg = ((WindowPtr)pDrawable)->absCorner.x;
        !            95:        yorg = ((WindowPtr)pDrawable)->absCorner.y;
        !            96:        pdstBase = (unsigned int *)
        !            97:                (((PixmapPtr)(pDrawable->pScreen->devPrivate))->devPrivate);
        !            98:        widthDst = (int)
        !            99:                  (((PixmapPtr)(pDrawable->pScreen->devPrivate))->devKind) >> 2;
        !           100:     }
        !           101:     else
        !           102:     {
        !           103:        xorg = 0;
        !           104:        yorg = 0;
        !           105:        pdstBase = (unsigned int *)(((PixmapPtr)pDrawable)->devPrivate);
        !           106:        widthDst = (int)(((PixmapPtr)pDrawable)->devKind) >> 2;
        !           107:     }
        !           108: 
        !           109:     xpos = x + xorg;
        !           110:     ypos = y + yorg;
        !           111: 
        !           112:     pci = &pfi->maxbounds;
        !           113:     w = pci->metrics.characterWidth;
        !           114:     h = pfi->fontAscent + pfi->fontDescent;
        !           115:     widthGlyph = GLYPHWIDTHBYTESPADDED(pci);
        !           116: 
        !           117:     xpos += pci->metrics.leftSideBearing;
        !           118:     ypos -= pfi->fontAscent;
        !           119: 
        !           120:     bbox.x1 = xpos;
        !           121:     bbox.x2 = xpos + (w * nglyph);
        !           122:     bbox.y1 = ypos;
        !           123:     bbox.y2 = ypos + h;
        !           124: 
        !           125:     switch ((*pGC->pScreen->RectIn)(
        !           126:                 ((mfbPrivGC *)(pGC->devPriv))->pCompositeClip, &bbox))
        !           127:     {
        !           128:       case rgnOUT:
        !           129:        break;
        !           130:       case rgnPART:
        !           131:        /* this is the WRONG thing to do, but it works.
        !           132:           calling the non-terminal text is easy, but slow, given
        !           133:           what we know about the font.
        !           134: 
        !           135:           the right thing to do is something like:
        !           136:            for each clip rectangle
        !           137:                compute at which row the glyph starts to be in it,
        !           138:                   and at which row the glyph ceases to be in it
        !           139:                compute which is the first glyph inside the left
        !           140:                    edge, and the last one inside the right edge
        !           141:                draw a fractional first glyph, using only
        !           142:                    the rows we know are in
        !           143:                draw all the whole glyphs, using the appropriate rows
        !           144:                draw any pieces of the last glyph, using the right rows
        !           145: 
        !           146:           this way, the code would take advantage of knowing that
        !           147:           all glyphs are the same height and don't overlap.
        !           148: 
        !           149:           one day...
        !           150:        */
        !           151:        CLIPTETEXT(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
        !           152:        break;
        !           153:       case rgnIN:
        !           154:         pdstBase += ((widthDst * ypos) + (xpos >> 5));
        !           155:         xpos &= 0x1f;
        !           156:         while(nglyph--)
        !           157:         {
        !           158:            pglyph = pglyphBase + (*ppci++)->byteOffset;
        !           159:            hTmp = h;
        !           160:            pdst = pdstBase;
        !           161: 
        !           162:            if ( (xpos+w) < 32)
        !           163:            {
        !           164:                maskpartialbits(xpos, w, startmask);
        !           165:                while(hTmp--)
        !           166:                {
        !           167:                    getleftbits(pglyph, w, tmpSrc);
        !           168:                    *pdst = (*pdst & ~startmask) |
        !           169:                            (OP(SCRRIGHT(tmpSrc, xpos)) & startmask);
        !           170:                    pdst += widthDst;
        !           171:                    pglyph += widthGlyph;
        !           172:                }
        !           173:                xpos += w;
        !           174:            }
        !           175:            else
        !           176:            {
        !           177:                mask32bits(xpos, w, startmask, endmask);
        !           178:                nfirst = 32 - xpos;
        !           179:                while(hTmp--)
        !           180:                {
        !           181:                    getleftbits(pglyph, w, tmpSrc);
        !           182:                    *pdst = (*pdst & ~startmask) |
        !           183:                            (OP(SCRRIGHT(tmpSrc, xpos)) & startmask);
        !           184:                    *(pdst+1) = (*(pdst+1) & ~endmask) |
        !           185:                            (OP(SCRLEFT(tmpSrc, nfirst)) & endmask);
        !           186:                    pdst += widthDst;
        !           187:                    pglyph += widthGlyph;
        !           188:                }
        !           189:                xpos += w;
        !           190:                xpos &= 0x1f;
        !           191:                pdstBase++;
        !           192:            }
        !           193:         }
        !           194:        break;
        !           195:     }
        !           196: }
        !           197: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.