Annotation of researchv9/X11/src/X.V11R1/server/ddx/mfb/mfbimage.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: /* $Header: mfbimage.c,v 1.31 87/09/07 19:07:51 rws Exp $ */
                     25: 
                     26: #include "X.h"
                     27: 
                     28: #include "windowstr.h"
                     29: #include "pixmapstr.h"
                     30: #include "scrnintstr.h"
                     31: #include "gcstruct.h"
                     32: 
                     33: #include "mfb.h"
                     34: #include "mi.h"
                     35: #include "Xmd.h"
                     36: 
                     37: #include "maskbits.h"
                     38: 
                     39: #include "servermd.h"
                     40: 
                     41: /* Put and Get images on a monochrome frame buffer
                     42:  *
                     43:  *   we do this by creating a temporary pixmap and making its
                     44:  * pointer to bits point to the buffer read in from the client.
                     45:  * this works because of the padding rules specified at startup
                     46:  *
                     47:  * Note that CopyArea must know how to copy a bitmap into the server-format
                     48:  * temporary pixmap.
                     49:  *
                     50:  * For speed, mfbPutImage should allocate the temporary pixmap on the stack.
                     51:  *
                     52:  *     even though an XYBitmap and an XYPixmap have the same
                     53:  * format (for this device), PutImage has different semantics for the
                     54:  * two.  XYPixmap just does the copy; XYBitmap takes gc.fgPixel for
                     55:  * a 1 bit, gc.bgPixel for a 0 bit, which we notice is exactly
                     56:  * like CopyPlane.
                     57:  *
                     58:  *   written by drewry, september 1986
                     59:  */
                     60: 
                     61: 
                     62: void
                     63: mfbPutImage(dst, pGC, depth, x, y, w, h, leftPad, format, pImage)
                     64:     DrawablePtr dst;
                     65:     GCPtr      pGC;
                     66:     int                depth, x, y, w, h;
                     67:     int leftPad;
                     68:     unsigned int format;
                     69:     int        *pImage;
                     70: {
                     71:     pointer    pbits;
                     72:     PixmapPtr  pFakePixmap;
                     73: 
                     74:     if (!(pGC->planemask & 1))
                     75:        return;
                     76: 
                     77:     /* 0 may confuse CreatePixmap, and will sometimes be
                     78:        passed by the mi text code
                     79:     */
                     80:     if ((w == 0) || (h == 0))
                     81:        return;
                     82: 
                     83:     /* mfb is always depth 1 */
                     84:     pFakePixmap = (PixmapPtr)mfbCreatePixmap(dst->pScreen, w+leftPad, h, 1);
                     85:     if (!pFakePixmap)
                     86:     {
                     87:        ErrorF( "mfbPutImage can't make temp pixmap\n");
                     88:        return;
                     89:     }
                     90: 
                     91:     pbits = pFakePixmap->devPrivate;
                     92:     pFakePixmap->devPrivate = (pointer)pImage;
                     93:     ((mfbPrivGC *)(pGC->devPriv))->fExpose = FALSE;
                     94:     if (format == XYPixmap)
                     95:        (*pGC->CopyArea)(pFakePixmap, dst, pGC, leftPad, 0, w, h, x, y);
                     96:     else
                     97:        (*pGC->CopyPlane)(pFakePixmap, dst, pGC, leftPad, 0, w, h, x, y, 1);
                     98:     ((mfbPrivGC*)(pGC->devPriv))->fExpose = TRUE;
                     99:     pFakePixmap->devPrivate = pbits;
                    100:     (*dst->pScreen->DestroyPixmap)(pFakePixmap);
                    101: }
                    102: 
                    103: 
                    104: /*
                    105:  * pdstLine points to space allocated by caller, which he can do since
                    106:  * he knows dimensions of the pixmap
                    107:  * we can call mfbDoBitblt because the dispatcher has promised not to send us
                    108:  * anything that would require going over the edge of the screen.
                    109:  *
                    110:  *     XYPixmap and ZPixmap are the same for mfb.
                    111:  *     For any planemask with bit 0 == 0, just fill the dst with 0.
                    112:  */
                    113: void
                    114: mfbGetImage( pDrawable, sx, sy, w, h, format, planeMask, pdstLine)
                    115:     DrawablePtr pDrawable;
                    116:     int                sx, sy, w, h;
                    117:     unsigned int format;
                    118:     unsigned int planeMask;
                    119:     pointer    pdstLine;
                    120: {
                    121:     int xorg, yorg;
                    122:     PixmapPtr pPixmap;
                    123:     BoxRec box;
                    124:     DDXPointRec ptSrc;
                    125:     RegionPtr prgnDst;
                    126:     pointer pspare;
                    127: 
                    128:     if (planeMask & 0x1)
                    129:     {
                    130:         if (pDrawable->type == DRAWABLE_WINDOW)
                    131:         {
                    132:            xorg = ((WindowPtr)pDrawable)->absCorner.x;
                    133:            yorg = ((WindowPtr)pDrawable)->absCorner.y;
                    134:         }
                    135:         else
                    136:         {
                    137:            xorg = 0;
                    138:            yorg = 0;
                    139:         }
                    140: 
                    141:         sx += xorg;
                    142:         sy += yorg;
                    143: 
                    144:         pPixmap = (PixmapPtr)mfbCreatePixmap(pDrawable->pScreen, w, h, 1);
                    145:         pspare = pPixmap->devPrivate;
                    146:         pPixmap->devPrivate = pdstLine;
                    147:         ptSrc.x = sx;
                    148:         ptSrc.y = sy;
                    149:         box.x1 = 0;
                    150:         box.y1 = 0;
                    151:         box.x2 = w;
                    152:         box.y2 = h;
                    153: 
                    154:         prgnDst = (*pDrawable->pScreen->RegionCreate)(&box, 1);
                    155:         mfbDoBitblt(pDrawable, pPixmap, GXcopy, prgnDst, &ptSrc);
                    156:         (*pDrawable->pScreen->RegionDestroy)(prgnDst);
                    157:         pPixmap->devPrivate = pspare;
                    158:         mfbDestroyPixmap(pPixmap);
                    159:     }
                    160:     else
                    161:     {
                    162:        bzero(pdstLine, PixmapBytePad(w, 1) * h);
                    163:     }
                    164: }

unix.superglobalmegacorp.com

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