Annotation of researchv9/X11/src/X.V11R1/server/ddx/mfb/mfbgetsp.c, revision 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: mfbgetsp.c,v 1.17 87/09/07 19:08:27 toddb Exp $ */
        !            25: #include "X.h"
        !            26: #include "Xmd.h"
        !            27: 
        !            28: #include "misc.h"
        !            29: #include "region.h"
        !            30: #include "gc.h"
        !            31: #include "windowstr.h"
        !            32: #include "pixmapstr.h"
        !            33: #include "scrnintstr.h"
        !            34: 
        !            35: #include "mfb.h"
        !            36: #include "maskbits.h"
        !            37: 
        !            38: #include "servermd.h"
        !            39: 
        !            40: /* GetSpans -- for each span, gets bits from drawable starting at ppt[i]
        !            41:  * and continuing for pwidth[i] bits
        !            42:  * Each scanline returned will be server scanline padded, i.e., it will come
        !            43:  * out to an integral number of words.
        !            44:  */
        !            45: unsigned int *
        !            46: mfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans)
        !            47:     DrawablePtr                pDrawable;      /* drawable from which to get bits */
        !            48:     int                        wMax;           /* largest value of all *pwidths */
        !            49:     register DDXPointPtr ppt;          /* points to start copying from */
        !            50:     int                        *pwidth;        /* list of number of bits to copy */
        !            51:     int                        nspans;         /* number of scanlines to copy */
        !            52: {
        !            53:     register unsigned int      *pdst;  /* where to put the bits */
        !            54:     register unsigned int      *psrc;  /* where to get the bits */
        !            55:     register unsigned int      tmpSrc; /* scratch buffer for bits */
        !            56:     unsigned int               *psrcBase;      /* start of src bitmap */
        !            57:     int                        widthSrc;       /* width of pixmap in bytes */
        !            58:     register DDXPointPtr pptLast;      /* one past last point to get */
        !            59:     int                xEnd;           /* last pixel to copy from */
        !            60:     register int       nstart; 
        !            61:     int                        nend; 
        !            62:     int                        srcStartOver; 
        !            63:     int                        startmask, endmask, nlMiddle, nl, srcBit;
        !            64:     int                        w;
        !            65:     unsigned int       *pdstStart;
        !            66:     unsigned int       *pdstNext;
        !            67: 
        !            68: 
        !            69:     pptLast = ppt + nspans;
        !            70: 
        !            71:     if (pDrawable->type == DRAWABLE_WINDOW)
        !            72:     {
        !            73:        psrcBase = (unsigned int *)
        !            74:                (((PixmapPtr)(pDrawable->pScreen->devPrivate))->devPrivate);
        !            75:        widthSrc = (int)
        !            76:                   ((PixmapPtr)(pDrawable->pScreen->devPrivate))->devKind;
        !            77:     }
        !            78:     else
        !            79:     {
        !            80:        psrcBase = (unsigned int *)(((PixmapPtr)pDrawable)->devPrivate);
        !            81:        widthSrc = (int)(((PixmapPtr)pDrawable)->devKind);
        !            82:     }
        !            83:     pdstStart = (unsigned int *)Xalloc(nspans * PixmapBytePad(wMax, 1));
        !            84:     pdst = pdstStart;
        !            85: 
        !            86:     while(ppt < pptLast)
        !            87:     {
        !            88:        xEnd = min(ppt->x + *pwidth, widthSrc << 3);
        !            89:        pwidth++;
        !            90:        psrc = psrcBase + (ppt->y * (widthSrc >> 2)) + (ppt->x >> 5); 
        !            91:        w = xEnd - ppt->x;
        !            92:        srcBit = ppt->x & 0x1f;
        !            93:        /* This shouldn't be needed */
        !            94:        pdstNext = pdst + PixmapWidthInPadUnits(w, 1);
        !            95: 
        !            96:        if (srcBit + w <= 32) 
        !            97:        { 
        !            98:            getbits(psrc, srcBit, w, tmpSrc);
        !            99:            putbits(tmpSrc, 0, w, pdst); 
        !           100:            pdst++;
        !           101:        } 
        !           102:        else 
        !           103:        { 
        !           104: 
        !           105:            maskbits(ppt->x, w, startmask, endmask, nlMiddle);
        !           106:            if (startmask) 
        !           107:                nstart = 32 - srcBit; 
        !           108:            else 
        !           109:                nstart = 0; 
        !           110:            if (endmask) 
        !           111:                nend = xEnd & 0x1f; 
        !           112:            srcStartOver = srcBit + nstart > 31;
        !           113:            if (startmask) 
        !           114:            { 
        !           115:                getbits(psrc, srcBit, nstart, tmpSrc);
        !           116:                putbits(tmpSrc, 0, nstart, pdst);
        !           117:                if(srcStartOver)
        !           118:                    psrc++;
        !           119:            } 
        !           120:            nl = nlMiddle; 
        !           121:            while (nl--) 
        !           122:            { 
        !           123:                tmpSrc = *psrc;
        !           124:                putbits(tmpSrc, nstart, 32, pdst);
        !           125:                psrc++;
        !           126:                pdst++;
        !           127:            } 
        !           128:            if (endmask) 
        !           129:            { 
        !           130:                getbits(psrc, 0, nend, tmpSrc);
        !           131:                putbits(tmpSrc, nstart, nend, pdst);
        !           132:                if(nstart + nend > 32)
        !           133:                    pdst++;
        !           134:            } 
        !           135:            pdst++; 
        !           136:            while(pdst < pdstNext)
        !           137:            {
        !           138:                *pdst++ = 0;
        !           139:            }
        !           140:        } 
        !           141:         ppt++;
        !           142:     }
        !           143:     return(pdstStart);
        !           144: }
        !           145: 

unix.superglobalmegacorp.com

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