Annotation of researchv9/X11/src/X.V11R1/server/ddx/mfb/mfbfillrct.c, revision 1.1.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: mfbfillrct.c,v 1.32 87/09/08 15:32:46 drewry Locked $ */
                     25: #include "X.h"
                     26: #include "Xprotostr.h"
                     27: #include "pixmapstr.h"
                     28: #include "gcstruct.h"
                     29: #include "windowstr.h"
                     30: #include "miscstruct.h"
                     31: #include "regionstr.h"
                     32: #include "scrnintstr.h"
                     33: 
                     34: #include "mfb.h"
                     35: #include "maskbits.h"
                     36: 
                     37: #define MODEQ(a, b) ((a) %= (b))
                     38: void mfbPaintOddSize();
                     39: 
                     40: /* 
                     41:     filled rectangles.
                     42:     translate the rectangles, clip them, and call the
                     43: helper function in the GC.
                     44: */
                     45: 
                     46: void
                     47: mfbPolyFillRect(pDrawable, pGC, nrectFill, prectInit)
                     48:     DrawablePtr pDrawable;
                     49:     GCPtr      pGC;
                     50:     int                nrectFill;      /* number of rectangles to fill */
                     51:     xRectangle *prectInit;     /* Pointer to first rectangle to fill */
                     52: {
                     53:     int xorg, yorg;
                     54:     register int n;            /* spare counter */
                     55:     xRectangle *prect;         /* temporary */
                     56:     RegionPtr prgnClip;
                     57:     register BoxPtr pbox;      /* used to clip with */
                     58:     register BoxPtr pboxClipped;
                     59:     BoxPtr pboxClippedBase;
                     60: 
                     61:     int alu;
                     62:     void (* pfn) ();
                     63:     PixmapPtr ppix;
                     64: 
                     65:     alu = ((mfbPrivGC *)(pGC->devPriv))->ropFillArea;
                     66:     pfn = ((mfbPrivGC *)(pGC->devPriv))->FillArea;
                     67:     ppix = *( ((mfbPrivGC *)(pGC->devPriv))->ppPixmap);
                     68:     prgnClip = ((mfbPrivGC *)(pGC->devPriv))->pCompositeClip;
                     69: 
                     70:     pboxClippedBase = (BoxPtr)ALLOCATE_LOCAL(prgnClip->numRects * 
                     71:                                             sizeof(BoxRec));
                     72: 
                     73:     if (!pboxClippedBase)
                     74:        return;
                     75: 
                     76:     prect = prectInit;
                     77:     if (pDrawable->type == DRAWABLE_WINDOW)
                     78:     {
                     79:        xorg = ((WindowPtr)pDrawable)->absCorner.x;
                     80:        yorg = ((WindowPtr)pDrawable)->absCorner.y;
                     81:         prect = prectInit;
                     82:        n = nrectFill;
                     83:         while(n--)
                     84:         {
                     85:            prect->x += xorg;
                     86:            prect->y += yorg;
                     87:            prect++;
                     88:         }
                     89:     }
                     90: 
                     91:     prect = prectInit;
                     92:     while (nrectFill--)
                     93:     {
                     94:        BoxRec box;
                     95: 
                     96:        if (prect->width <= 0 || prect->height <= 0)
                     97:        {
                     98:            prect++;
                     99:            continue;
                    100:        }
                    101:        box.x1 = prect->x;
                    102:        box.y1 = prect->y;
                    103:        box.x2 = box.x1 + prect->width;
                    104:        box.y2 = box.y1 + prect->height;
                    105:        prect++;
                    106: 
                    107:        switch((*pGC->pScreen->RectIn)(prgnClip, &box))
                    108:        {
                    109:          case rgnOUT:
                    110:            break;
                    111:          case rgnIN:
                    112:            (*pfn)(pDrawable, 1, &box, alu, ppix);
                    113:            break;
                    114:          case rgnPART:
                    115:            pboxClipped = pboxClippedBase;
                    116:            pbox = prgnClip->rects;
                    117:            n = prgnClip->numRects;
                    118: 
                    119:            /* clip the rectangle to each box in the clip region
                    120:               this is logically equivalent to calling Intersect()
                    121:            */
                    122:            while(n--)
                    123:            {
                    124:                pboxClipped->x1 = max(box.x1, pbox->x1);
                    125:                pboxClipped->y1 = max(box.y1, pbox->y1);
                    126:                pboxClipped->x2 = min(box.x2, pbox->x2);
                    127:                pboxClipped->y2 = min(box.y2, pbox->y2);
                    128:                pbox++;
                    129: 
                    130:                /* see if clipping left anything */
                    131:                if(pboxClipped->x1 < pboxClipped->x2 && 
                    132:                   pboxClipped->y1 < pboxClipped->y2)
                    133:                {
                    134:                    pboxClipped++;
                    135:                }
                    136:            }
                    137:            (*pfn)(pDrawable, pboxClipped-pboxClippedBase, 
                    138:                   pboxClippedBase, alu, ppix);
                    139:            break;
                    140:        }
                    141:     }
                    142:     DEALLOCATE_LOCAL(pboxClippedBase);
                    143: }

unix.superglobalmegacorp.com

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