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

« back to all changes in this revision

Viewing changes to mfb/mfbbstore.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
/* $Xorg: mfbbstore.c,v 1.4 2001/02/09 02:05:18 xorgcvs Exp $ */
 
2
/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
 
3
/*
 
4
 
 
5
Copyright 1987, 1998  The Open Group
 
6
 
 
7
Permission to use, copy, modify, distribute, and sell this software and its
 
8
documentation for any purpose is hereby granted without fee, provided that
 
9
the above copyright notice appear in all copies and that both that
 
10
copyright notice and this permission notice appear in supporting
 
11
documentation.
 
12
 
 
13
The above copyright notice and this permission notice shall be included
 
14
in all copies or substantial portions of the Software.
 
15
 
 
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
17
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
18
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
19
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
 
20
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 
21
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 
22
OTHER DEALINGS IN THE SOFTWARE.
 
23
 
 
24
Except as contained in this notice, the name of The Open Group shall
 
25
not be used in advertising or otherwise to promote the sale, use or
 
26
other dealings in this Software without prior written authorization
 
27
from The Open Group.
 
28
 
 
29
*/
 
30
 
 
31
#ifdef HAVE_DIX_CONFIG_H
 
32
#include <dix-config.h>
 
33
#endif
 
34
 
 
35
#include    "mfb.h"
 
36
#include    <X11/X.h>
 
37
#include    "mibstore.h"
 
38
#include    "regionstr.h"
 
39
#include    "scrnintstr.h"
 
40
#include    "pixmapstr.h"
 
41
#include    "windowstr.h"
 
42
 
 
43
/*-
 
44
 *-----------------------------------------------------------------------
 
45
 * mfbSaveAreas --
 
46
 *      Function called by miSaveAreas to actually fetch the areas to be
 
47
 *      saved into the backing pixmap. This is very simple to do, since
 
48
 *      mfbDoBitblt is designed for this very thing. The region to save is
 
49
 *      already destination-relative and we're given the offset to the
 
50
 *      window origin, so we have only to create an array of points of the
 
51
 *      u.l. corners of the boxes in the region translated to the screen
 
52
 *      coordinate system and fetch the screen pixmap out of its devPrivate
 
53
 *      field....
 
54
 *
 
55
 * Results:
 
56
 *      None.
 
57
 *
 
58
 * Side Effects:
 
59
 *      Data are copied from the screen into the pixmap.
 
60
 *
 
61
 *-----------------------------------------------------------------------
 
62
 */
 
63
void
 
64
mfbSaveAreas(pPixmap, prgnSave, xorg, yorg, pWin)
 
65
    PixmapPtr           pPixmap;        /* Backing pixmap */
 
66
    RegionPtr           prgnSave;       /* Region to save (pixmap-relative) */
 
67
    int                 xorg;           /* X origin of region */
 
68
    int                 yorg;           /* Y origin of region */
 
69
    WindowPtr           pWin;
 
70
{
 
71
    register DDXPointPtr pPt;
 
72
    DDXPointPtr         pPtsInit;
 
73
    register BoxPtr     pBox;
 
74
    register int        numRects;
 
75
    
 
76
    numRects = REGION_NUM_RECTS(prgnSave);
 
77
    pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects * sizeof(DDXPointRec));
 
78
    if (!pPtsInit)
 
79
        return;
 
80
    
 
81
    pBox = REGION_RECTS(prgnSave);
 
82
    pPt = pPtsInit;
 
83
    while (numRects--)
 
84
    {
 
85
        pPt->x = pBox->x1 + xorg;
 
86
        pPt->y = pBox->y1 + yorg;
 
87
        pPt++;
 
88
        pBox++;
 
89
    }
 
90
 
 
91
    mfbDoBitblt((DrawablePtr)pPixmap->drawable.pScreen->devPrivate,
 
92
                (DrawablePtr)pPixmap,
 
93
                GXcopy,
 
94
                prgnSave,
 
95
                pPtsInit);
 
96
 
 
97
    DEALLOCATE_LOCAL(pPtsInit);
 
98
}
 
99
 
 
100
/*-
 
101
 *-----------------------------------------------------------------------
 
102
 * mfbRestoreAreas --
 
103
 *      Function called by miRestoreAreas to actually fetch the areas to be
 
104
 *      restored from the backing pixmap. This is very simple to do, since
 
105
 *      mfbDoBitblt is designed for this very thing. The region to restore is
 
106
 *      already destination-relative and we're given the offset to the
 
107
 *      window origin, so we have only to create an array of points of the
 
108
 *      u.l. corners of the boxes in the region translated to the pixmap
 
109
 *      coordinate system and fetch the screen pixmap out of its devPrivate
 
110
 *      field....
 
111
 *
 
112
 * Results:
 
113
 *      None.
 
114
 *
 
115
 * Side Effects:
 
116
 *      Data are copied from the pixmap into the screen.
 
117
 *
 
118
 *-----------------------------------------------------------------------
 
119
 */
 
120
void
 
121
mfbRestoreAreas(pPixmap, prgnRestore, xorg, yorg, pWin)
 
122
    PixmapPtr           pPixmap;        /* Backing pixmap */
 
123
    RegionPtr           prgnRestore;    /* Region to restore (screen-relative)*/
 
124
    int                 xorg;           /* X origin of window */
 
125
    int                 yorg;           /* Y origin of window */
 
126
    WindowPtr           pWin;
 
127
{
 
128
    register DDXPointPtr pPt;
 
129
    DDXPointPtr         pPtsInit;
 
130
    register BoxPtr     pBox;
 
131
    register int        numRects;
 
132
    
 
133
    numRects = REGION_NUM_RECTS(prgnRestore);
 
134
    pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects*sizeof(DDXPointRec));
 
135
    if (!pPtsInit)
 
136
        return;
 
137
    
 
138
    pBox = REGION_RECTS(prgnRestore);
 
139
    pPt = pPtsInit;
 
140
    while (numRects--)
 
141
    {
 
142
        pPt->x = pBox->x1 - xorg;
 
143
        pPt->y = pBox->y1 - yorg;
 
144
        pPt++;
 
145
        pBox++;
 
146
    }
 
147
 
 
148
    mfbDoBitblt((DrawablePtr)pPixmap,
 
149
                (DrawablePtr)pPixmap->drawable.pScreen->devPrivate,
 
150
                GXcopy,
 
151
                prgnRestore,
 
152
                pPtsInit);
 
153
 
 
154
    DEALLOCATE_LOCAL(pPtsInit);
 
155
}