105b261ecSmrg/*
205b261ecSmrg * Copyright © 1998 Keith Packard
305b261ecSmrg *
405b261ecSmrg * Permission to use, copy, modify, distribute, and sell this software and its
505b261ecSmrg * documentation for any purpose is hereby granted without fee, provided that
605b261ecSmrg * the above copyright notice appear in all copies and that both that
705b261ecSmrg * copyright notice and this permission notice appear in supporting
805b261ecSmrg * documentation, and that the name of Keith Packard not be used in
905b261ecSmrg * advertising or publicity pertaining to distribution of the software without
1005b261ecSmrg * specific, written prior permission.  Keith Packard makes no
1105b261ecSmrg * representations about the suitability of this software for any purpose.  It
1205b261ecSmrg * is provided "as is" without express or implied warranty.
1305b261ecSmrg *
1405b261ecSmrg * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1505b261ecSmrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
1605b261ecSmrg * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1705b261ecSmrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
1805b261ecSmrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
1905b261ecSmrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2005b261ecSmrg * PERFORMANCE OF THIS SOFTWARE.
2105b261ecSmrg */
2205b261ecSmrg
2305b261ecSmrg#ifdef HAVE_DIX_CONFIG_H
2405b261ecSmrg#include <dix-config.h>
2505b261ecSmrg#endif
2605b261ecSmrg
2705b261ecSmrg#include "fb.h"
2805b261ecSmrg
2905b261ecSmrgvoid
3035c4bbdfSmrgfbFillSpans(DrawablePtr pDrawable,
3135c4bbdfSmrg            GCPtr pGC, int n, DDXPointPtr ppt, int *pwidth, int fSorted)
3205b261ecSmrg{
3335c4bbdfSmrg    RegionPtr pClip = fbGetCompositeClip(pGC);
3435c4bbdfSmrg    BoxPtr pextent, pbox;
3535c4bbdfSmrg    int nbox;
3635c4bbdfSmrg    int extentX1, extentX2, extentY1, extentY2;
3735c4bbdfSmrg    int fullX1, fullX2, fullY1;
3835c4bbdfSmrg    int partX1, partX2;
3935c4bbdfSmrg
406747b715Smrg    pextent = RegionExtents(pClip);
4105b261ecSmrg    extentX1 = pextent->x1;
4205b261ecSmrg    extentY1 = pextent->y1;
4305b261ecSmrg    extentX2 = pextent->x2;
4405b261ecSmrg    extentY2 = pextent->y2;
4535c4bbdfSmrg    while (n--) {
4635c4bbdfSmrg        fullX1 = ppt->x;
4735c4bbdfSmrg        fullY1 = ppt->y;
4835c4bbdfSmrg        fullX2 = fullX1 + (int) *pwidth;
4935c4bbdfSmrg        ppt++;
5035c4bbdfSmrg        pwidth++;
5135c4bbdfSmrg
5235c4bbdfSmrg        if (fullY1 < extentY1 || extentY2 <= fullY1)
5335c4bbdfSmrg            continue;
5435c4bbdfSmrg
5535c4bbdfSmrg        if (fullX1 < extentX1)
5635c4bbdfSmrg            fullX1 = extentX1;
5735c4bbdfSmrg
5835c4bbdfSmrg        if (fullX2 > extentX2)
5935c4bbdfSmrg            fullX2 = extentX2;
6035c4bbdfSmrg
6135c4bbdfSmrg        if (fullX1 >= fullX2)
6235c4bbdfSmrg            continue;
6305b261ecSmrg
6435c4bbdfSmrg        nbox = RegionNumRects(pClip);
6535c4bbdfSmrg        if (nbox == 1) {
6635c4bbdfSmrg            fbFill(pDrawable, pGC, fullX1, fullY1, fullX2 - fullX1, 1);
6735c4bbdfSmrg        }
6835c4bbdfSmrg        else {
6935c4bbdfSmrg            pbox = RegionRects(pClip);
7035c4bbdfSmrg            while (nbox--) {
7135c4bbdfSmrg                if (pbox->y1 <= fullY1 && fullY1 < pbox->y2) {
7235c4bbdfSmrg                    partX1 = pbox->x1;
7335c4bbdfSmrg                    if (partX1 < fullX1)
7435c4bbdfSmrg                        partX1 = fullX1;
7535c4bbdfSmrg                    partX2 = pbox->x2;
7635c4bbdfSmrg                    if (partX2 > fullX2)
7735c4bbdfSmrg                        partX2 = fullX2;
7835c4bbdfSmrg                    if (partX2 > partX1) {
7935c4bbdfSmrg                        fbFill(pDrawable, pGC,
8035c4bbdfSmrg                               partX1, fullY1, partX2 - partX1, 1);
8135c4bbdfSmrg                    }
8235c4bbdfSmrg                }
8335c4bbdfSmrg                pbox++;
8435c4bbdfSmrg            }
8535c4bbdfSmrg        }
8605b261ecSmrg    }
8705b261ecSmrg}
88