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

« back to all changes in this revision

Viewing changes to mfb/mfbscrinit.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/mfb/mfbscrinit.c,v 3.8tsi Exp $ */
 
2
/***********************************************************
 
3
 
 
4
Copyright 1987, 1998  The Open Group
 
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.
 
11
 
 
12
The above copyright notice and this permission notice shall be included in
 
13
all copies or substantial portions of the Software.
 
14
 
 
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
16
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
18
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
19
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
20
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
21
 
 
22
Except as contained in this notice, the name of The Open Group shall not be
 
23
used in advertising or otherwise to promote the sale, use or other dealings
 
24
in this Software without prior written authorization from The Open Group.
 
25
 
 
26
 
 
27
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
28
 
 
29
                        All Rights Reserved
 
30
 
 
31
Permission to use, copy, modify, and distribute this software and its 
 
32
documentation for any purpose and without fee is hereby granted, 
 
33
provided that the above copyright notice appear in all copies and that
 
34
both that copyright notice and this permission notice appear in 
 
35
supporting documentation, and that the name of Digital not be
 
36
used in advertising or publicity pertaining to distribution of the
 
37
software without specific, written prior permission.  
 
38
 
 
39
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 
40
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 
41
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
42
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
43
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
44
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
45
SOFTWARE.
 
46
 
 
47
******************************************************************/
 
48
/* $Xorg: mfbscrinit.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
 
49
 
 
50
#ifdef HAVE_DIX_CONFIG_H
 
51
#include <dix-config.h>
 
52
#endif
 
53
 
 
54
#include <X11/X.h>
 
55
#include <X11/Xproto.h> /* for xColorItem */
 
56
#include <X11/Xmd.h>
 
57
#include "scrnintstr.h"
 
58
#include "pixmapstr.h"
 
59
#include "windowstr.h"
 
60
#include "resource.h"
 
61
#include "colormap.h"
 
62
#include "mfb.h"
 
63
#include "mistruct.h"
 
64
#include "dix.h"
 
65
#include "mi.h"
 
66
#include "mibstore.h"
 
67
#include "migc.h"
 
68
#include "servermd.h"
 
69
 
 
70
#ifdef PIXMAP_PER_WINDOW
 
71
int frameWindowPrivateIndex;
 
72
int frameGetWindowPrivateIndex(void) { return frameWindowPrivateIndex; }
 
73
#endif
 
74
int mfbWindowPrivateIndex;
 
75
int mfbGetWindowPrivateIndex(void) { return mfbWindowPrivateIndex; }
 
76
int mfbGCPrivateIndex;
 
77
int mfbGetGCPrivateIndex(void) { return mfbGCPrivateIndex; }
 
78
static unsigned long mfbGeneration = 0;
 
79
 
 
80
static VisualRec visual = {
 
81
/* vid  class       bpRGB cmpE nplan rMask gMask bMask oRed oGreen oBlue */
 
82
   0,   StaticGray, 1,    2,   1,    0,    0,    0,    0,   0,     0
 
83
};
 
84
 
 
85
static VisualID VID;
 
86
 
 
87
static DepthRec depth = {
 
88
/* depth        numVid          vids */
 
89
    1,          1,              &VID
 
90
};
 
91
 
 
92
 
 
93
BSFuncRec mfbBSFuncRec = {
 
94
    mfbSaveAreas,
 
95
    mfbRestoreAreas,
 
96
    (BackingStoreSetClipmaskRgnProcPtr) 0,
 
97
    (BackingStoreGetImagePixmapProcPtr) 0,
 
98
    (BackingStoreGetSpansPixmapProcPtr) 0,
 
99
};
 
100
 
 
101
 
 
102
Bool
 
103
mfbAllocatePrivates(pScreen, pWinIndex, pGCIndex)
 
104
    ScreenPtr pScreen;
 
105
    int *pWinIndex, *pGCIndex;
 
106
{
 
107
    if (mfbGeneration != serverGeneration)
 
108
    {
 
109
#ifdef PIXMAP_PER_WINDOW
 
110
        frameWindowPrivateIndex = AllocateWindowPrivateIndex();
 
111
#endif
 
112
        mfbWindowPrivateIndex = AllocateWindowPrivateIndex();
 
113
        mfbGCPrivateIndex = miAllocateGCPrivateIndex();
 
114
        visual.vid = FakeClientID(0);
 
115
        VID = visual.vid;
 
116
        mfbGeneration = serverGeneration;
 
117
    }
 
118
    if (pWinIndex)
 
119
        *pWinIndex = mfbWindowPrivateIndex;
 
120
    if (pGCIndex)
 
121
        *pGCIndex = mfbGCPrivateIndex;
 
122
    pScreen->GetWindowPixmap = mfbGetWindowPixmap;
 
123
    pScreen->SetWindowPixmap = mfbSetWindowPixmap;
 
124
    return (AllocateWindowPrivate(pScreen, mfbWindowPrivateIndex,
 
125
                                  sizeof(mfbPrivWin)) &&
 
126
            AllocateGCPrivate(pScreen, mfbGCPrivateIndex, sizeof(mfbPrivGC)));
 
127
}
 
128
 
 
129
 
 
130
/* dts * (inch/dot) * (25.4 mm / inch) = mm */
 
131
Bool
 
132
mfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
 
133
    register ScreenPtr pScreen;
 
134
    pointer pbits;              /* pointer to screen bitmap */
 
135
    int xsize, ysize;           /* in pixels */
 
136
    int dpix, dpiy;             /* dots per inch */
 
137
    int width;                  /* pixel width of frame buffer */
 
138
{
 
139
    if  (!mfbAllocatePrivates(pScreen, (int *)NULL, (int *)NULL))
 
140
        return FALSE;
 
141
    pScreen->defColormap = (Colormap) FakeClientID(0);
 
142
    /* whitePixel, blackPixel */
 
143
    pScreen->QueryBestSize = mfbQueryBestSize;
 
144
    /* SaveScreen */
 
145
    pScreen->GetImage = mfbGetImage;
 
146
    pScreen->GetSpans = mfbGetSpans;
 
147
    pScreen->CreateWindow = mfbCreateWindow;
 
148
    pScreen->DestroyWindow = mfbDestroyWindow;
 
149
    pScreen->PositionWindow = mfbPositionWindow;
 
150
    pScreen->ChangeWindowAttributes = mfbChangeWindowAttributes;
 
151
    pScreen->RealizeWindow = mfbMapWindow;
 
152
    pScreen->UnrealizeWindow = mfbUnmapWindow;
 
153
    pScreen->PaintWindowBackground = mfbPaintWindow;
 
154
    pScreen->PaintWindowBorder = mfbPaintWindow;
 
155
    pScreen->CopyWindow = mfbCopyWindow;
 
156
    pScreen->CreatePixmap = mfbCreatePixmap;
 
157
    pScreen->DestroyPixmap = mfbDestroyPixmap;
 
158
    pScreen->RealizeFont = mfbRealizeFont;
 
159
    pScreen->UnrealizeFont = mfbUnrealizeFont;
 
160
    pScreen->CreateGC = mfbCreateGC;
 
161
    pScreen->CreateColormap = mfbCreateColormap;
 
162
    pScreen->DestroyColormap = mfbDestroyColormap;
 
163
    pScreen->InstallColormap = mfbInstallColormap;
 
164
    pScreen->UninstallColormap = mfbUninstallColormap;
 
165
    pScreen->ListInstalledColormaps = mfbListInstalledColormaps;
 
166
    pScreen->StoreColors = (StoreColorsProcPtr)NoopDDA;
 
167
    pScreen->ResolveColor = mfbResolveColor;
 
168
    pScreen->BitmapToRegion = mfbPixmapToRegion;
 
169
    if (!miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
 
170
                        1, 1, &depth, VID, 1, &visual))
 
171
        return FALSE;
 
172
    pScreen->BackingStoreFuncs = mfbBSFuncRec;
 
173
    return TRUE;
 
174
}
 
175
 
 
176
PixmapPtr
 
177
mfbGetWindowPixmap(pWin)
 
178
    WindowPtr pWin;
 
179
{
 
180
#ifdef PIXMAP_PER_WINDOW
 
181
    return (PixmapPtr)(pWin->devPrivates[frameWindowPrivateIndex].ptr);
 
182
#else
 
183
    ScreenPtr pScreen = pWin->drawable.pScreen;
 
184
 
 
185
    return (* pScreen->GetScreenPixmap)(pScreen);
 
186
#endif
 
187
}
 
188
 
 
189
void
 
190
mfbSetWindowPixmap(pWin, pPix)
 
191
    WindowPtr pWin;
 
192
    PixmapPtr pPix;
 
193
{
 
194
#ifdef PIXMAP_PER_WINDOW
 
195
    pWin->devPrivates[frameWindowPrivateIndex].ptr = (pointer)pPix;
 
196
#else
 
197
    (* pWin->drawable.pScreen->SetScreenPixmap)(pPix);
 
198
#endif
 
199
}
 
200
 
 
201
void mfbFillInScreen(ScreenPtr pScreen)
 
202
{
 
203
    pScreen->ChangeWindowAttributes = mfbChangeWindowAttributes;
 
204
    pScreen->RealizeWindow = mfbMapWindow;
 
205
    pScreen->UnrealizeWindow = mfbUnmapWindow;
 
206
    pScreen->DestroyPixmap = mfbDestroyPixmap;
 
207
    pScreen->RealizeFont = mfbRealizeFont;
 
208
    pScreen->UnrealizeFont = mfbUnrealizeFont;
 
209
    pScreen->BitmapToRegion = mfbPixmapToRegion;
 
210
}