Annotation of researchv9/X11/src/X.V11R1/server/ddx/mfb/mfbpushpxl.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: mfbpushpxl.c,v 1.16 87/09/11 07:48:33 toddb Exp $ */
        !            25: 
        !            26: #include "X.h"
        !            27: #include "gcstruct.h"
        !            28: #include "screenint.h"
        !            29: #include "pixmapstr.h"
        !            30: #include "miscstruct.h"
        !            31: #include "maskbits.h"
        !            32: 
        !            33: #define NPT 128
        !            34: 
        !            35: /* mfbPushPixels -- squeegees the forground color of pGC through pBitMap
        !            36:  * into pDrawable.  pBitMap is a stencil (dx by dy of it is used, it may
        !            37:  * be bigger) which is placed on the drawable at xOrg, yOrg.  Where a 1 bit
        !            38:  * is set in the bitmap, the fill style is put onto the drawable using
        !            39:  * the GC's logical function. The drawable is not changed where the bitmap
        !            40:  * has a zero bit or outside the area covered by the stencil.
        !            41:  */
        !            42: void
        !            43: mfbPushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
        !            44:     GCPtr      pGC;
        !            45:     PixmapPtr  pBitMap;
        !            46:     DrawablePtr pDrawable;
        !            47:     int                dx, dy, xOrg, yOrg;
        !            48: {
        !            49:     int                h, dxDiv32, ibEnd;
        !            50:     unsigned int *pwLineStart;
        !            51:     register unsigned int      *pw, *pwEnd;
        !            52:     register unsigned int mask;
        !            53:     register int ib, w;
        !            54:     register int ipt;          /* index into above arrays */
        !            55:     Bool       fInBox;
        !            56:     DDXPointRec        pt[NPT];
        !            57:     int                width[NPT];
        !            58: 
        !            59:     /* Now scan convert the pixmap and use the result to call fillspans in
        !            60:      * in the drawable with the original GC */
        !            61:     ipt = 0;
        !            62:     dxDiv32 = dx/32;
        !            63:     for(h = 0; h < dy; h++)
        !            64:     {
        !            65: 
        !            66:        pw = (unsigned int *)
        !            67:             (((char *)(pBitMap->devPrivate))+(h * pBitMap->devKind));
        !            68:        pwLineStart = pw;
        !            69:        /* Process all words which are fully in the pixmap */
        !            70:        
        !            71:        fInBox = FALSE;
        !            72:        pwEnd = pwLineStart + dxDiv32;
        !            73:        while(pw  < pwEnd)
        !            74:        {
        !            75:            w = *pw;
        !            76:            mask = endtab[1];
        !            77:            for(ib = 0; ib < 32; ib++)
        !            78:            {
        !            79:                if(w & mask)
        !            80:                {
        !            81:                    if(!fInBox)
        !            82:                    {
        !            83:                        pt[ipt].x = ((pw - pwLineStart) << 5) + ib + xOrg;
        !            84:                        pt[ipt].y = h + yOrg;
        !            85:                        /* start new box */
        !            86:                        fInBox = TRUE;
        !            87:                    }
        !            88:                }
        !            89:                else
        !            90:                {
        !            91:                    if(fInBox)
        !            92:                    {
        !            93:                        width[ipt] = ((pw - pwLineStart) << 5) + 
        !            94:                                     ib + xOrg - pt[ipt].x;
        !            95:                        if (++ipt >= NPT)
        !            96:                        {
        !            97:                            (*pGC->FillSpans)(pDrawable, pGC, NPT, pt,
        !            98:                                              width, TRUE);
        !            99:                            ipt = 0;
        !           100:                        }
        !           101:                        /* end box */
        !           102:                        fInBox = FALSE;
        !           103:                    }
        !           104:                }
        !           105:                mask = SCRRIGHT(mask, 1);
        !           106:            }
        !           107:            pw++;
        !           108:        }
        !           109:        ibEnd = dx & 0x1F;
        !           110:        if(ibEnd)
        !           111:        {
        !           112:            /* Process final partial word on line */
        !           113:            w = *pw;
        !           114:            mask = endtab[1];
        !           115:            for(ib = 0; ib < ibEnd; ib++)
        !           116:            {
        !           117:                if(w & mask)
        !           118:                {
        !           119:                    if(!fInBox)
        !           120:                    {
        !           121:                        /* start new box */
        !           122:                        pt[ipt].x = ((pw - pwLineStart) << 5) + ib + xOrg;
        !           123:                        pt[ipt].y = h + yOrg;
        !           124:                        fInBox = TRUE;
        !           125:                    }
        !           126:                }
        !           127:                else
        !           128:                {
        !           129:                    if(fInBox)
        !           130:                    {
        !           131:                        /* end box */
        !           132:                        width[ipt] = ((pw - pwLineStart) << 5) + 
        !           133:                                     ib + xOrg - pt[ipt].x;
        !           134:                        if (++ipt >= NPT)
        !           135:                        {
        !           136:                            (*pGC->FillSpans)(pDrawable, pGC, NPT, pt,
        !           137:                                              width, TRUE);
        !           138:                            ipt = 0;
        !           139:                        }
        !           140:                        fInBox = FALSE;
        !           141:                    }
        !           142:                }
        !           143:                mask = SCRRIGHT(mask, 1);
        !           144:            }
        !           145:        }
        !           146:        /* If scanline ended with last bit set, end the box */
        !           147:        if(fInBox)
        !           148:        {
        !           149:            width[ipt] = ((pw - pwLineStart) << 5) + ib + xOrg - pt[ipt].x;
        !           150:            if (++ipt >= NPT)
        !           151:            {
        !           152:                (*pGC->FillSpans)(pDrawable, pGC, NPT, pt, width, TRUE);
        !           153:                ipt = 0;
        !           154:            }
        !           155:        }
        !           156:     }
        !           157:     /* Flush any remaining spans */
        !           158:     if (ipt)
        !           159:     {
        !           160:        (*pGC->FillSpans)(pDrawable, pGC, ipt, pt, width, TRUE);
        !           161:     }
        !           162: }

unix.superglobalmegacorp.com

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