~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to fb/fbfillrect.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
Import upstream version 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Id: fbfillrect.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
 
3
 *
 
4
 * Copyright © 1998 Keith Packard
 
5
 *
 
6
 * Permission to use, copy, modify, distribute, and sell this software and its
 
7
 * documentation for any purpose is hereby granted without fee, provided that
 
8
 * the above copyright notice appear in all copies and that both that
 
9
 * copyright notice and this permission notice appear in supporting
 
10
 * documentation, and that the name of Keith Packard not be used in
 
11
 * advertising or publicity pertaining to distribution of the software without
 
12
 * specific, written prior permission.  Keith Packard makes no
 
13
 * representations about the suitability of this software for any purpose.  It
 
14
 * is provided "as is" without express or implied warranty.
 
15
 *
 
16
 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
17
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 
18
 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
19
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 
20
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 
21
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 
22
 * PERFORMANCE OF THIS SOFTWARE.
 
23
 */
 
24
/* $XFree86: xc/programs/Xserver/fb/fbfillrect.c,v 1.1 1999/11/19 13:53:43 hohndel Exp $ */
 
25
 
 
26
#ifdef HAVE_DIX_CONFIG_H
 
27
#include <dix-config.h>
 
28
#endif
 
29
 
 
30
#include "fb.h"
 
31
 
 
32
void
 
33
fbPolyFillRect(DrawablePtr  pDrawable, 
 
34
               GCPtr        pGC, 
 
35
               int          nrect,
 
36
               xRectangle   *prect)
 
37
{
 
38
    RegionPtr       pClip = fbGetCompositeClip(pGC);
 
39
    register BoxPtr pbox;
 
40
    BoxPtr          pextent;
 
41
    int             extentX1, extentX2, extentY1, extentY2;
 
42
    int             fullX1, fullX2, fullY1, fullY2;
 
43
    int             partX1, partX2, partY1, partY2;
 
44
    int             xorg, yorg;
 
45
    int             n;
 
46
 
 
47
    xorg = pDrawable->x;
 
48
    yorg = pDrawable->y;
 
49
    
 
50
    pextent = REGION_EXTENTS(pGC->pScreen, pClip);
 
51
    extentX1 = pextent->x1;
 
52
    extentY1 = pextent->y1;
 
53
    extentX2 = pextent->x2;
 
54
    extentY2 = pextent->y2;
 
55
    while (nrect--)
 
56
    {
 
57
        fullX1 = prect->x + xorg;
 
58
        fullY1 = prect->y + yorg;
 
59
        fullX2 = fullX1 + (int) prect->width;
 
60
        fullY2 = fullY1 + (int) prect->height;
 
61
        prect++;
 
62
        
 
63
        if (fullX1 < extentX1)
 
64
            fullX1 = extentX1;
 
65
 
 
66
        if (fullY1 < extentY1)
 
67
            fullY1 = extentY1;
 
68
 
 
69
        if (fullX2 > extentX2)
 
70
            fullX2 = extentX2;
 
71
        
 
72
        if (fullY2 > extentY2)
 
73
            fullY2 = extentY2;
 
74
 
 
75
        if ((fullX1 >= fullX2) || (fullY1 >= fullY2))
 
76
            continue;
 
77
        n = REGION_NUM_RECTS (pClip);
 
78
        if (n == 1)
 
79
        {
 
80
            fbFill (pDrawable,
 
81
                    pGC,
 
82
                    fullX1, fullY1, fullX2-fullX1, fullY2-fullY1);
 
83
        }
 
84
        else
 
85
        {
 
86
            pbox = REGION_RECTS(pClip);
 
87
            /* 
 
88
             * clip the rectangle to each box in the clip region
 
89
             * this is logically equivalent to calling Intersect()
 
90
             */
 
91
            while(n--)
 
92
            {
 
93
                partX1 = pbox->x1;
 
94
                if (partX1 < fullX1)
 
95
                    partX1 = fullX1;
 
96
                partY1 = pbox->y1;
 
97
                if (partY1 < fullY1)
 
98
                    partY1 = fullY1;
 
99
                partX2 = pbox->x2;
 
100
                if (partX2 > fullX2)
 
101
                    partX2 = fullX2;
 
102
                partY2 = pbox->y2;
 
103
                if (partY2 > fullY2)
 
104
                    partY2 = fullY2;
 
105
    
 
106
                pbox++;
 
107
                
 
108
                if (partX1 < partX2 && partY1 < partY2)
 
109
                    fbFill (pDrawable, pGC,
 
110
                            partX1, partY1,
 
111
                            partX2 - partX1, partY2 - partY1);
 
112
            }
 
113
        }
 
114
    }
 
115
}