Annotation of researchv9/X11/src/X.V11R1/server/ddx/mi/miglblt.c, revision 1.1.1.1

1.1       root        1: /***********************************************************
                      2: Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
                      3: and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
                      4: 
                      5:                         All Rights Reserved
                      6: 
                      7: Permission to use, copy, modify, and distribute this software and its 
                      8: documentation for any purpose and without fee is hereby granted, 
                      9: provided that the above copyright notice appear in all copies and that
                     10: both that copyright notice and this permission notice appear in 
                     11: supporting documentation, and that the names of Digital or MIT not be
                     12: used in advertising or publicity pertaining to distribution of the
                     13: software without specific, written prior permission.  
                     14: 
                     15: DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
                     16: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
                     17: DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
                     18: ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
                     19: WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
                     20: ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
                     21: SOFTWARE.
                     22: 
                     23: ******************************************************************/
                     24: 
                     25: /* $Header: miglblt.c,v 1.16 87/09/08 10:10:10 toddb Exp $ */
                     26: 
                     27: #include       "X.h"
                     28: #include       "Xmd.h"
                     29: #include       "Xproto.h"
                     30: #include       "fontstruct.h"
                     31: #include       "dixfontstr.h"
                     32: #include       "gcstruct.h"
                     33: #include       "windowstr.h"
                     34: #include       "scrnintstr.h"
                     35: #include       "pixmap.h"
                     36: #include       "servermd.h"
                     37: 
                     38: 
                     39: /*
                     40:     machine-independent glyph blt.
                     41:     assumes that glyph bits in snf are written in bytes,
                     42: have same bit order as the server's bitmap format,
                     43: and are byte padded.  this corresponds to the snf distributed
                     44: with the sample server.
                     45: 
                     46:     get a scratch GC.
                     47:     in the scratch GC set alu = GXcopy, fg = 1, bg = 0
                     48:     allocate a bitmap big enough to hold the largest glyph in the font
                     49:     validate the scratch gc with the bitmap
                     50:     for each glyph
                     51:        carefully put the bits of the glyph in a buffer,
                     52:            padded to the server pixmap scanline padding rules
                     53:        fake a call to PutImage from the buffer into the bitmap
                     54:        use the bitmap in a call to PushPixels
                     55: */
                     56: 
                     57: void
                     58: miPolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
                     59:     DrawablePtr pDrawable;
                     60:     GC                 *pGC;
                     61:     int        x, y;
                     62:     unsigned int nglyph;
                     63:     CharInfoPtr *ppci;         /* array of character info */
                     64:     unsigned char *pglyphBase; /* start of array of glyphs */
                     65: {
                     66:     int width, height;
                     67:     PixmapPtr pPixmap;
                     68:     int nbyLine;                       /* bytes per line of padded pixmap */
                     69:     FontRec *pfont;
                     70:     GCPtr pGCtmp;
                     71:     register int i;
                     72:     register int j;
                     73:     unsigned char *pbits;              /* buffer for PutImage */
                     74:     register unsigned char *pb;                /* temp pointer into buffer */
                     75:     register CharInfoPtr pci;          /* currect char info */
                     76:     register unsigned char *pglyph;    /* pointer bits in glyph */
                     77:     int gWidth, gHeight;               /* width and height of glyph */
                     78:     register int nbyGlyphWidth;                /* bytes per scanline of glyph */
                     79:     int nbyPadGlyph;                   /* server padded line of glyph */
                     80: 
                     81:     int gcvals[3];
                     82: 
                     83:     if ((pDrawable->type == DRAWABLE_WINDOW) &&
                     84:        (pGC->miTranslate))
                     85:     {
                     86:        x += ((WindowPtr)pDrawable)->absCorner.x;
                     87:        y += ((WindowPtr)pDrawable)->absCorner.y;
                     88:     }
                     89: 
                     90:     pfont = pGC->font;
                     91:     width = pfont->pFI->maxbounds.metrics.rightSideBearing - 
                     92:        pfont->pFI->minbounds.metrics.leftSideBearing;
                     93:     height = pfont->pFI->maxbounds.metrics.ascent + 
                     94:        pfont->pFI->maxbounds.metrics.descent;
                     95: 
                     96:     pPixmap = (PixmapPtr)(*pDrawable->pScreen->CreatePixmap)
                     97:       (pDrawable->pScreen, width, height, 1, XYBitmap);
                     98: 
                     99:     pGCtmp = GetScratchGC(1, pDrawable->pScreen);
                    100: 
                    101:     gcvals[0] = GXcopy;
                    102:     gcvals[1] = 1;
                    103:     gcvals[2] = 0;
                    104: 
                    105:     DoChangeGC(pGCtmp, GCFunction|GCForeground|GCBackground, gcvals, 0);
                    106: 
                    107:     nbyLine = PixmapBytePad(width, 1);
                    108:     pbits = (unsigned char *)ALLOCATE_LOCAL(height*nbyLine);
                    109:     if (!pbits)
                    110:         return ;
                    111: 
                    112:     while(nglyph--)
                    113:     {
                    114:        pci = *ppci++;
                    115:        pglyph = pglyphBase + pci->byteOffset;
                    116:        gWidth = GLYPHWIDTHPIXELS(pci);
                    117:        gHeight = GLYPHHEIGHTPIXELS(pci);
                    118:        nbyGlyphWidth = GLYPHWIDTHBYTESPADDED(pci);
                    119:        nbyPadGlyph = PixmapBytePad(gWidth, 1);
                    120: 
                    121:        for (i=0, pb = pbits; i<gHeight; i++, pb = pbits+(i*nbyPadGlyph))
                    122:            for (j = 0; j < nbyGlyphWidth; j++)
                    123:                *pb++ = *pglyph++;
                    124: 
                    125: 
                    126:        if ((pGCtmp->serialNumber) != (pPixmap->drawable.serialNumber))
                    127:            ValidateGC(pPixmap, pGCtmp);
                    128:        (*pGCtmp->PutImage)(pPixmap, pGCtmp, pPixmap->drawable.depth,
                    129:                            0, 0, gWidth, gHeight, 
                    130:                            0, XYBitmap, pbits);
                    131: 
                    132:        if ((pGC->serialNumber) != (pDrawable->serialNumber))
                    133:            ValidateGC(pDrawable, pGC);
                    134:        (*pGC->PushPixels)(pGC, pPixmap, pDrawable,
                    135:                           gWidth, gHeight,
                    136:                           x + pci->metrics.leftSideBearing,
                    137:                           y - pci->metrics.ascent);
                    138:        x += pci->metrics.characterWidth;
                    139:     }
                    140:     (*pDrawable->pScreen->DestroyPixmap)(pPixmap);
                    141:     DEALLOCATE_LOCAL(pbits);
                    142:     FreeScratchGC(pGCtmp);
                    143: }
                    144: 
                    145: 
                    146: void
                    147: miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
                    148:     DrawablePtr pDrawable;
                    149:     GC                 *pGC;
                    150:     int        x, y;
                    151:     unsigned int nglyph;
                    152:     CharInfoPtr *ppci;         /* array of character info */
                    153:     unsigned char *pglyphBase; /* start of array of glyphs */
                    154: {
                    155:     ExtentInfoRec info;                /* used by QueryGlyphExtents() */
                    156:     long gcvals[3];
                    157:     int oldAlu, oldFS;
                    158:     unsigned long      oldFG;
                    159:     xRectangle backrect;
                    160: 
                    161:     QueryGlyphExtents(pGC->font, ppci, nglyph, &info);
                    162: 
                    163:     backrect.x = x;
                    164:     backrect.y = y - pGC->font->pFI->fontAscent;
                    165:     backrect.width = info.overallWidth;
                    166:     backrect.height = pGC->font->pFI->fontAscent + 
                    167:                      pGC->font->pFI->fontDescent;
                    168: 
                    169:     oldAlu = pGC->alu;
                    170:     oldFG = pGC->fgPixel;
                    171:     oldFS = pGC->fillStyle;
                    172: 
                    173:     /* fill in the background */
                    174:     gcvals[0] = (long) GXcopy;
                    175:     gcvals[1] = (long) pGC->bgPixel;
                    176:     gcvals[2] = (long) FillSolid;
                    177:     DoChangeGC(pGC, GCFunction|GCForeground|GCFillStyle, gcvals, 0);
                    178:     ValidateGC(pDrawable, pGC);
                    179:     (*pGC->PolyFillRect)(pDrawable, pGC, 1, &backrect);
                    180: 
                    181:     /* put down the glyphs */
                    182:     gcvals[0] = (long) oldFG;
                    183:     DoChangeGC(pGC, GCForeground, gcvals, 0);
                    184:     ValidateGC(pDrawable, pGC);
                    185:     (*pGC->PolyGlyphBlt)(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
                    186: 
                    187:     /* put all the toys away when done playing */
                    188:     gcvals[0] = (long) oldAlu;
                    189:     gcvals[1] = (long) oldFG;
                    190:     gcvals[2] = (long) oldFS;
                    191:     DoChangeGC(pGC, GCFunction|GCForeground|GCFillStyle, gcvals, 0);
                    192: /*
                    193:    ???
                    194:    should we cal ValidateGC now, to leave everything exactly as we
                    195: found it
                    196:    ???
                    197: */
                    198: 
                    199: }
                    200: 

unix.superglobalmegacorp.com

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