Annotation of researchv9/X11/src/X.V11R1/server/ddx/mfb/mfbtile.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: mfbtile.c,v 1.5 87/09/11 07:48:49 toddb Exp $ */
        !            25: #include "X.h"
        !            26: 
        !            27: #include "windowstr.h"
        !            28: #include "regionstr.h"
        !            29: #include "pixmapstr.h"
        !            30: #include "scrnintstr.h"
        !            31: 
        !            32: #include "mfb.h"
        !            33: #include "maskbits.h"
        !            34: 
        !            35: /* 
        !            36:    this code could be called by the paint window background stuff,
        !            37: too; there would be some speed hit because of the different
        !            38: parameters and the need to check for a rop when filling
        !            39: with a tile.
        !            40: 
        !            41:    the boxes are already translated.
        !            42: 
        !            43:    NOTE:
        !            44:    iy = ++iy < tileHeight ? iy : 0
        !            45: is equivalent to iy%= tileheight, and saves a division.
        !            46: */
        !            47: 
        !            48: /* 
        !            49:     tile area with a 32 bit wide pixmap 
        !            50: */
        !            51: void
        !            52: mfbTileArea32(pDraw, nbox, pbox, alu, ptile)
        !            53:     DrawablePtr pDraw;
        !            54:     int nbox;
        !            55:     BoxPtr pbox;
        !            56:     int alu;
        !            57:     PixmapPtr ptile;
        !            58: {
        !            59:     register unsigned int *psrc;
        !            60:                        /* pointer to bits in tile, if needed */
        !            61:     int tileHeight;    /* height of the tile */
        !            62:     register unsigned int srcpix;      
        !            63: 
        !            64:     int nlwidth;       /* width in longwords of the drawable */
        !            65:     int w;             /* width of current box */
        !            66:     register int h;    /* height of current box */
        !            67:     int startmask;
        !            68:     int endmask;       /* masks for reggedy bits at either end of line */
        !            69:     int nlwMiddle;     /* number of longwords between sides of boxes */
        !            70:     register int nlwExtra;     
        !            71:                        /* to get from right of box to left of next span */
        !            72:     
        !            73:     register int nlw;  /* loop version of nlwMiddle */
        !            74:     register unsigned int *p;  /* pointer to bits we're writing */
        !            75:     int iy;            /* index of current scanline in tile */
        !            76: 
        !            77: 
        !            78:     unsigned int *pbits;       /* pointer to start of drawable */
        !            79: 
        !            80:     if (pDraw->type == DRAWABLE_WINDOW)
        !            81:     {
        !            82:        pbits = (unsigned int *)
        !            83:                (((PixmapPtr)(pDraw->pScreen->devPrivate))->devPrivate);
        !            84:        nlwidth = (int)
        !            85:                (((PixmapPtr)(pDraw->pScreen->devPrivate))->devKind) >> 2;
        !            86:     }
        !            87:     else
        !            88:     {
        !            89:        pbits = (unsigned int *)(((PixmapPtr)pDraw)->devPrivate);
        !            90:        nlwidth = (int)(((PixmapPtr)pDraw)->devKind) >> 2;
        !            91:     }
        !            92: 
        !            93:     tileHeight = ptile->height;
        !            94:     psrc = (unsigned int *)(ptile->devPrivate);
        !            95: 
        !            96:     while (nbox--)
        !            97:     {
        !            98:        w = pbox->x2 - pbox->x1;
        !            99:        h = pbox->y2 - pbox->y1;
        !           100:        iy = pbox->y1 % tileHeight;
        !           101:        p = pbits + (pbox->y1 * nlwidth) + (pbox->x1 >> 5);
        !           102: 
        !           103:        if ( ((pbox->x1 & 0x1f) + w) < 32)
        !           104:        {
        !           105:            maskpartialbits(pbox->x1, w, startmask);
        !           106:            nlwExtra = nlwidth;
        !           107:            while (h--)
        !           108:            {
        !           109:                srcpix = psrc[iy];
        !           110:                iy = ++iy < tileHeight ? iy : 0;
        !           111:                *p = (*p & ~startmask) |
        !           112:                     (DoRop(alu, srcpix, *p) & startmask);
        !           113:                p += nlwExtra;
        !           114:            }
        !           115:        }
        !           116:        else
        !           117:        {
        !           118:            maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
        !           119:            nlwExtra = nlwidth - nlwMiddle;
        !           120: 
        !           121:            if (startmask && endmask)
        !           122:            {
        !           123:                nlwExtra -= 1;
        !           124:                while (h--)
        !           125:                {
        !           126:                    srcpix = psrc[iy];
        !           127:                    iy = ++iy < tileHeight ? iy : 0;
        !           128:                    nlw = nlwMiddle;
        !           129:                    *p = (*p & ~startmask) | 
        !           130:                         (DoRop(alu, srcpix, *p) & startmask);
        !           131:                    p++;
        !           132:                    while (nlw--)
        !           133:                    {
        !           134:                        *p = DoRop(alu, srcpix, *p);
        !           135:                        p++;
        !           136:                    }
        !           137:                    *p = (*p & ~endmask) |
        !           138:                         (DoRop(alu, srcpix, *p) & endmask);
        !           139:                    p += nlwExtra;
        !           140:                }
        !           141:            }
        !           142:            else if (startmask && !endmask)
        !           143:            {
        !           144:                nlwExtra -= 1;
        !           145:                while (h--)
        !           146:                {
        !           147:                    srcpix = psrc[iy];
        !           148:                    iy = ++iy < tileHeight ? iy : 0;
        !           149:                    nlw = nlwMiddle;
        !           150:                    *p = (*p & ~startmask) | 
        !           151:                         (DoRop(alu, srcpix, *p) & startmask);
        !           152:                    p++;
        !           153:                    while (nlw--)
        !           154:                    {
        !           155:                        *p = DoRop(alu, srcpix, *p);
        !           156:                        p++;
        !           157:                    }
        !           158:                    p += nlwExtra;
        !           159:                }
        !           160:            }
        !           161:            else if (!startmask && endmask)
        !           162:            {
        !           163:                while (h--)
        !           164:                {
        !           165:                    srcpix = psrc[iy];
        !           166:                    iy = ++iy < tileHeight ? iy : 0;
        !           167:                    nlw = nlwMiddle;
        !           168:                    while (nlw--)
        !           169:                    {
        !           170:                        *p = DoRop(alu, srcpix, *p);
        !           171:                        p++;
        !           172:                    }
        !           173:                    *p = (*p & ~endmask) |
        !           174:                         (DoRop(alu, srcpix, *p) & endmask);
        !           175:                    p += nlwExtra;
        !           176:                }
        !           177:            }
        !           178:            else /* no ragged bits at either end */
        !           179:            {
        !           180:                while (h--)
        !           181:                {
        !           182:                    srcpix = psrc[iy];
        !           183:                    iy = ++iy < tileHeight ? iy : 0;
        !           184:                    nlw = nlwMiddle;
        !           185:                    while (nlw--)
        !           186:                    {
        !           187:                        *p = DoRop(alu, srcpix, *p);
        !           188:                        p++;
        !           189:                    }
        !           190:                    p += nlwExtra;
        !           191:                }
        !           192:            }
        !           193:        }
        !           194:         pbox++;
        !           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.