Annotation of researchv9/X11/src/X.V11R1/server/ddx/mfb/mfbpntarea.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: mfbpntarea.c,v 1.5 87/09/11 07:48:36 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:    the solid fillers are called for rectangles and window backgrounds.
        !            37:    the boxes are already translated.
        !            38:    maybe this should always take a pixmap instead of a drawable?
        !            39: 
        !            40:    NOTE:
        !            41:    iy = ++iy < tileHeight ? iy : 0
        !            42: is equivalent to iy%= tileheight, and saves a division.
        !            43: */
        !            44: 
        !            45: /*
        !            46:        MFBSOLIDFILLAREA        OPEQ    EQWHOLEOWRD
        !            47:        mfbSolidWhiteArea       |=      = ~0
        !            48:        mfbSolidBlackArea       &=~     = 0
        !            49:        mfbSolidInvertArea      ^=      ^= ~0
        !            50: 
        !            51: EQWHOLEWORD is used to write whole longwords.  it could use OPEQ,
        !            52: but *p++ |= ~0 on at least two compilers generates much
        !            53: worse code than *p++ = ~0.  similarly for *p++ &= ~~0
        !            54: and *p++ = 0.
        !            55: 
        !            56: */
        !            57: 
        !            58: void
        !            59: MFBSOLIDFILLAREA(pDraw, nbox, pbox, alu, nop)
        !            60:     DrawablePtr pDraw;
        !            61:     int nbox;
        !            62:     BoxPtr pbox;
        !            63:     int alu;
        !            64:     PixmapPtr nop;
        !            65: {
        !            66:     int nlwidth;       /* width in longwords of the drawable */
        !            67:     int w;             /* width of current box */
        !            68:     register int h;    /* height of current box */
        !            69:     register int startmask;
        !            70:     int endmask;       /* masks for reggedy bits at either end of line */
        !            71:     int nlwMiddle;     /* number of longwords between sides of boxes */
        !            72:     register int nlwExtra;     
        !            73:                        /* to get from right of box to left of next span */
        !            74:     register int nlw;  /* loop version of nlwMiddle */
        !            75:     register unsigned int *p;  /* pointer to bits we're writing */
        !            76:     unsigned int *pbits;       /* pointer to start of drawable */
        !            77: 
        !            78:     if (pDraw->type == DRAWABLE_WINDOW)
        !            79:     {
        !            80:        pbits = (unsigned int *)
        !            81:                (((PixmapPtr)(pDraw->pScreen->devPrivate))->devPrivate);
        !            82:        nlwidth = (int)
        !            83:                (((PixmapPtr)(pDraw->pScreen->devPrivate))->devKind) >> 2;
        !            84:     }
        !            85:     else
        !            86:     {
        !            87:        pbits = (unsigned int *)(((PixmapPtr)pDraw)->devPrivate);
        !            88:        nlwidth = (int)(((PixmapPtr)pDraw)->devKind) >> 2;
        !            89:     }
        !            90: 
        !            91: 
        !            92:     while (nbox--)
        !            93:     {
        !            94:        w = pbox->x2 - pbox->x1;
        !            95:        h = pbox->y2 - pbox->y1;
        !            96:        p = pbits + (pbox->y1 * nlwidth) + (pbox->x1 >> 5);
        !            97: 
        !            98:        if ( ((pbox->x1 & 0x1f) + w) < 32)
        !            99:        {
        !           100:            maskpartialbits(pbox->x1, w, startmask);
        !           101:            nlwExtra = nlwidth;
        !           102:            while (h--)
        !           103:            {
        !           104:                *p OPEQ startmask;
        !           105:                p += nlwExtra;
        !           106:            }
        !           107:        }
        !           108:        else
        !           109:        {
        !           110:            maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
        !           111:            nlwExtra = nlwidth - nlwMiddle;
        !           112: 
        !           113:            if (startmask && endmask)
        !           114:            {
        !           115:                nlwExtra -= 1;
        !           116:                while (h--)
        !           117:                {
        !           118:                    nlw = nlwMiddle;
        !           119:                    *p OPEQ startmask;
        !           120:                    p++;
        !           121:                    while (nlw--)
        !           122:                        *p++ EQWHOLEWORD;
        !           123:                    *p OPEQ endmask;
        !           124:                    p += nlwExtra;
        !           125:                }
        !           126:            }
        !           127:            else if (startmask && !endmask)
        !           128:            {
        !           129:                nlwExtra -= 1;
        !           130:                while (h--)
        !           131:                {
        !           132:                    nlw = nlwMiddle;
        !           133:                    *p OPEQ startmask;
        !           134:                    p++;
        !           135:                    while (nlw--)
        !           136:                        *p++ EQWHOLEWORD;
        !           137:                    p += nlwExtra;
        !           138:                }
        !           139:            }
        !           140:            else if (!startmask && endmask)
        !           141:            {
        !           142:                while (h--)
        !           143:                {
        !           144:                    nlw = nlwMiddle;
        !           145:                    while (nlw--)
        !           146:                        *p++ EQWHOLEWORD;
        !           147:                    *p OPEQ endmask;
        !           148:                    p += nlwExtra;
        !           149:                }
        !           150:            }
        !           151:            else /* no ragged bits at either end */
        !           152:            {
        !           153:                while (h--)
        !           154:                {
        !           155:                    nlw = nlwMiddle;
        !           156:                    while (nlw--)
        !           157:                        *p++ EQWHOLEWORD;
        !           158:                    p += nlwExtra;
        !           159:                }
        !           160:            }
        !           161:        }
        !           162:         pbox++;
        !           163:     }
        !           164: }
        !           165: 
        !           166: 
        !           167: 
        !           168: /* stipple a list of boxes
        !           169: 
        !           170: you can use the reduced rasterop for stipples.  if rrop is
        !           171: black, AND the destination with (not stipple pattern).  if rrop is
        !           172: white OR the destination with the stipple pattern.  if rrop is invert,
        !           173: XOR the destination with the stipple pattern.
        !           174: 
        !           175:        MFBSTIPPLEFILLAREA      OPEQ
        !           176:        mfbStippleWhiteArea     |=
        !           177:        mfbStippleBlackArea     &=~
        !           178:        mfbStippleInveryArea    ^=
        !           179: */
        !           180: 
        !           181: void
        !           182: MFBSTIPPLEFILLAREA(pDraw, nbox, pbox, alu, pstipple)
        !           183:     DrawablePtr pDraw;
        !           184:     int nbox;
        !           185:     BoxPtr pbox;
        !           186:     int alu;
        !           187:     PixmapPtr pstipple;
        !           188: {
        !           189:     register unsigned int *psrc;
        !           190:                        /* pointer to bits in tile, if needed */
        !           191:     int tileHeight;    /* height of the tile */
        !           192:     register unsigned int srcpix;      
        !           193: 
        !           194:     int nlwidth;       /* width in longwords of the drawable */
        !           195:     int w;             /* width of current box */
        !           196:     register int h;    /* height of current box */
        !           197:     int startmask;
        !           198:     int endmask;       /* masks for reggedy bits at either end of line */
        !           199:     int nlwMiddle;     /* number of longwords between sides of boxes */
        !           200:     register int nlwExtra;     
        !           201:                        /* to get from right of box to left of next span */
        !           202:     
        !           203:     register int nlw;  /* loop version of nlwMiddle */
        !           204:     register unsigned int *p;  /* pointer to bits we're writing */
        !           205:     int iy;            /* index of current scanline in tile */
        !           206: 
        !           207: 
        !           208:     unsigned int *pbits;       /* pointer to start of drawable */
        !           209: 
        !           210:     if (pDraw->type == DRAWABLE_WINDOW)
        !           211:     {
        !           212:        pbits = (unsigned int *)
        !           213:                (((PixmapPtr)(pDraw->pScreen->devPrivate))->devPrivate);
        !           214:        nlwidth = (int)
        !           215:                (((PixmapPtr)(pDraw->pScreen->devPrivate))->devKind) >> 2;
        !           216:     }
        !           217:     else
        !           218:     {
        !           219:        pbits = (unsigned int *)(((PixmapPtr)pDraw)->devPrivate);
        !           220:        nlwidth = (int)(((PixmapPtr)pDraw)->devKind) >> 2;
        !           221:     }
        !           222: 
        !           223:     tileHeight = pstipple->height;
        !           224:     psrc = (unsigned int *)(pstipple->devPrivate);
        !           225: 
        !           226:     while (nbox--)
        !           227:     {
        !           228:        w = pbox->x2 - pbox->x1;
        !           229:        h = pbox->y2 - pbox->y1;
        !           230:        iy = pbox->y1 % tileHeight;
        !           231:        p = pbits + (pbox->y1 * nlwidth) + (pbox->x1 >> 5);
        !           232: 
        !           233:        if ( ((pbox->x1 & 0x1f) + w) < 32)
        !           234:        {
        !           235:            maskpartialbits(pbox->x1, w, startmask);
        !           236:            nlwExtra = nlwidth;
        !           237:            while (h--)
        !           238:            {
        !           239:                srcpix = psrc[iy];
        !           240:                iy = ++iy < tileHeight ? iy : 0;
        !           241:                *p OPEQ (srcpix & startmask);
        !           242:                p += nlwExtra;
        !           243:            }
        !           244:        }
        !           245:        else
        !           246:        {
        !           247:            maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
        !           248:            nlwExtra = nlwidth - nlwMiddle;
        !           249: 
        !           250:            if (startmask && endmask)
        !           251:            {
        !           252:                nlwExtra -= 1;
        !           253:                while (h--)
        !           254:                {
        !           255:                    srcpix = psrc[iy];
        !           256:                    iy = ++iy < tileHeight ? iy : 0;
        !           257:                    nlw = nlwMiddle;
        !           258:                    *p OPEQ (srcpix & startmask);
        !           259:                    p++;
        !           260:                    while (nlw--)
        !           261:                    {
        !           262:                        *p OPEQ srcpix;
        !           263:                        p++;
        !           264:                    }
        !           265:                    *p OPEQ (srcpix & endmask);
        !           266:                    p += nlwExtra;
        !           267:                }
        !           268:            }
        !           269:            else if (startmask && !endmask)
        !           270:            {
        !           271:                nlwExtra -= 1;
        !           272:                while (h--)
        !           273:                {
        !           274:                    srcpix = psrc[iy];
        !           275:                    iy = ++iy < tileHeight ? iy : 0;
        !           276:                    nlw = nlwMiddle;
        !           277:                    *p OPEQ (srcpix & startmask);
        !           278:                    p++;
        !           279:                    while (nlw--)
        !           280:                    {
        !           281:                        *p OPEQ srcpix;
        !           282:                        p++;
        !           283:                    }
        !           284:                    p += nlwExtra;
        !           285:                }
        !           286:            }
        !           287:            else if (!startmask && endmask)
        !           288:            {
        !           289:                while (h--)
        !           290:                {
        !           291:                    srcpix = psrc[iy];
        !           292:                    iy = ++iy < tileHeight ? iy : 0;
        !           293:                    nlw = nlwMiddle;
        !           294:                    while (nlw--)
        !           295:                    {
        !           296:                        *p OPEQ srcpix;
        !           297:                        p++;
        !           298:                    }
        !           299:                    *p OPEQ (srcpix & endmask);
        !           300:                    p += nlwExtra;
        !           301:                }
        !           302:            }
        !           303:            else /* no ragged bits at either end */
        !           304:            {
        !           305:                while (h--)
        !           306:                {
        !           307:                    srcpix = psrc[iy];
        !           308:                    iy = ++iy < tileHeight ? iy : 0;
        !           309:                    nlw = nlwMiddle;
        !           310:                    while (nlw--)
        !           311:                    {
        !           312:                        *p OPEQ srcpix;
        !           313:                        p++;
        !           314:                    }
        !           315:                    p += nlwExtra;
        !           316:                }
        !           317:            }
        !           318:        }
        !           319:         pbox++;
        !           320:     }
        !           321: }
        !           322: 
        !           323: 

unix.superglobalmegacorp.com

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