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

« back to all changes in this revision

Viewing changes to hw/xfree86/xf4bpp/ppcClip.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
/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcClip.c,v 1.4 1999/06/06 08:48:58 dawes Exp $ */
 
2
/*
 
3
 
 
4
Copyright (c) 1987  X Consortium
 
5
 
 
6
Permission is hereby granted, free of charge, to any person obtaining
 
7
a copy of this software and associated documentation files (the
 
8
"Software"), to deal in the Software without restriction, including
 
9
without limitation the rights to use, copy, modify, merge, publish,
 
10
distribute, sublicense, and/or sell copies of the Software, and to
 
11
permit persons to whom the Software is furnished to do so, subject to
 
12
the following conditions:
 
13
 
 
14
The above copyright notice and this permission notice shall be included
 
15
in all copies or substantial portions of the Software.
 
16
 
 
17
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
18
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
19
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
20
IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
 
21
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 
22
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 
23
OTHER DEALINGS IN THE SOFTWARE.
 
24
 
 
25
Except as contained in this notice, the name of the X Consortium shall
 
26
not be used in advertising or otherwise to promote the sale, use or
 
27
other dealings in this Software without prior written authorization
 
28
from the X Consortium.
 
29
 
 
30
 
 
31
Copyright IBM Corporation 1987,1988,1989
 
32
All Rights Reserved
 
33
 
 
34
Permission to use, copy, modify, and distribute this software and its
 
35
documentation for any purpose and without fee is hereby granted,
 
36
provided that the above copyright notice appear in all copies and that 
 
37
both that copyright notice and this permission notice appear in
 
38
supporting documentation, and that the name of IBM not be
 
39
used in advertising or publicity pertaining to distribution of the
 
40
software without specific, written prior permission.
 
41
 
 
42
IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 
43
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 
44
IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
45
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
46
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
47
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
48
SOFTWARE.
 
49
 
 
50
 
 
51
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
 
52
All Rights Reserved
 
53
 
 
54
Permission to use, copy, modify, and distribute this software and its
 
55
documentation for any purpose and without fee is hereby granted,
 
56
provided that the above copyright notice appear in all copies and that
 
57
both that copyright notice and this permission notice appear in
 
58
supporting documentation, and that the name of Digital not be
 
59
used in advertising or publicity pertaining to distribution of the
 
60
software without specific, written prior permission.
 
61
 
 
62
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 
63
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 
64
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
65
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
66
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
67
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
68
SOFTWARE.
 
69
 
 
70
*/
 
71
/* $XConsortium: ppcClip.c /main/4 1996/02/21 17:57:21 kaleb $ */
 
72
 
 
73
#ifdef HAVE_XORG_CONFIG_H
 
74
#include <xorg-config.h>
 
75
#endif
 
76
 
 
77
#include "xf4bpp.h"
 
78
#include "mfbmap.h"
 
79
#include "mfb.h"
 
80
#include "scrnintstr.h"
 
81
 
 
82
void
 
83
xf4bppDestroyClip(pGC)
 
84
    GCPtr       pGC;
 
85
{
 
86
    if(pGC->clientClipType == CT_NONE)
 
87
        return;
 
88
    else if (pGC->clientClipType == CT_PIXMAP)
 
89
    {
 
90
        mfbDestroyPixmap((PixmapPtr)(pGC->clientClip));
 
91
    }
 
92
    else
 
93
    {
 
94
        /* we know we'll never have a list of rectangles, since
 
95
           ChangeClip immediately turns them into a region 
 
96
        */
 
97
        REGION_DESTROY(pGC->pScreen, pGC->clientClip);
 
98
    }
 
99
    pGC->clientClip = NULL;
 
100
    pGC->clientClipType = CT_NONE;
 
101
}
 
102
 
 
103
void
 
104
xf4bppChangeClip(pGC, type, pvalue, nrects)
 
105
    GCPtr           pGC;
 
106
    int             type;
 
107
    pointer         pvalue;
 
108
    int             nrects;
 
109
{
 
110
    xf4bppDestroyClip(pGC);
 
111
    if(type == CT_PIXMAP)
 
112
    {
 
113
        /* convert the pixmap to a region */
 
114
        pGC->clientClip = (pointer) (*pGC->pScreen->BitmapToRegion)((PixmapPtr)pvalue);
 
115
        /* you wouldn't do this if you were leaving the pixmap in
 
116
           rather than converting it.
 
117
        */
 
118
        (*pGC->pScreen->DestroyPixmap)(pvalue);
 
119
    }
 
120
    else if (type == CT_REGION)
 
121
    {
 
122
        /* stuff the region in the GC */
 
123
        pGC->clientClip = pvalue;
 
124
    }
 
125
    else if (type != CT_NONE)
 
126
    {
 
127
        pGC->clientClip = (pointer) RECTS_TO_REGION(pGC->pScreen, nrects,
 
128
                                                    (xRectangle *)pvalue,
 
129
                                                    type);
 
130
        xfree(pvalue);
 
131
    }
 
132
    pGC->clientClipType = (type != CT_NONE && pGC->clientClip) ? CT_REGION :
 
133
        CT_NONE;
 
134
    pGC->stateChanges |= GCClipMask;
 
135
}
 
136
 
 
137
void
 
138
xf4bppCopyClip (pgcDst, pgcSrc)
 
139
    GCPtr pgcDst, pgcSrc;
 
140
{
 
141
    RegionPtr prgnNew;
 
142
 
 
143
    switch(pgcSrc->clientClipType)
 
144
    {
 
145
      case CT_PIXMAP:
 
146
        ((PixmapPtr) pgcSrc->clientClip)->refcnt++;
 
147
        /* Fall through !! */
 
148
      case CT_NONE:
 
149
        xf4bppChangeClip(pgcDst, pgcSrc->clientClipType, pgcSrc->clientClip, 0);
 
150
        break;
 
151
      case CT_REGION:
 
152
        prgnNew = REGION_CREATE(pgcSrc->pScreen, NULL, 1);
 
153
        REGION_COPY(pgcSrc->pScreen, prgnNew, (RegionPtr)(pgcSrc->clientClip));
 
154
        xf4bppChangeClip(pgcDst, CT_REGION, (pointer)prgnNew, 0);
 
155
        break;
 
156
    }
 
157
}