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

unix.superglobalmegacorp.com

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