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

« back to all changes in this revision

Viewing changes to cfb/cfbscrinit.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/cfb/cfbscrinit.c,v 1.19 2001/01/17 22:36:36 dawes Exp $ */
 
2
/************************************************************
 
3
Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
 
4
 
 
5
                    All Rights Reserved
 
6
 
 
7
Permission  to  use,  copy,  modify,  and  distribute   this
 
8
software  and  its documentation for any purpose and without
 
9
fee is hereby granted, provided that the above copyright no-
 
10
tice  appear  in all copies and that both that copyright no-
 
11
tice and this permission notice appear in  supporting  docu-
 
12
mentation,  and  that the names of Sun or The Open Group
 
13
not be used in advertising or publicity pertaining to 
 
14
distribution  of  the software  without specific prior 
 
15
written permission. Sun and The Open Group make no 
 
16
representations about the suitability of this software for 
 
17
any purpose. It is provided "as is" without any express or 
 
18
implied warranty.
 
19
 
 
20
SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
 
21
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
 
22
NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
 
23
ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
24
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
 
25
PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
 
26
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 
27
THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
28
 
 
29
********************************************************/
 
30
/* $Xorg: cfbscrinit.c,v 1.3 2000/08/17 19:48:15 cpqbld Exp $ */
 
31
 
 
32
#ifdef HAVE_DIX_CONFIG_H
 
33
#include <dix-config.h>
 
34
#endif
 
35
 
 
36
#include <X11/X.h>
 
37
#include <X11/Xmd.h>
 
38
#include "servermd.h"
 
39
#include "scrnintstr.h"
 
40
#include "pixmapstr.h"
 
41
#include "resource.h"
 
42
#include "colormap.h"
 
43
#include "colormapst.h"
 
44
#include "cfb.h"
 
45
#include "mi.h"
 
46
#include "mistruct.h"
 
47
#include "dix.h"
 
48
#include "cfbmskbits.h"
 
49
#include "mibstore.h"
 
50
 
 
51
BSFuncRec cfbBSFuncRec = {
 
52
    cfbSaveAreas,
 
53
    cfbRestoreAreas,
 
54
    (BackingStoreSetClipmaskRgnProcPtr) 0,
 
55
    (BackingStoreGetImagePixmapProcPtr) 0,
 
56
    (BackingStoreGetSpansPixmapProcPtr) 0,
 
57
};
 
58
 
 
59
Bool
 
60
cfbCloseScreen (index, pScreen)
 
61
    int         index;
 
62
    ScreenPtr   pScreen;
 
63
{
 
64
    int     d;
 
65
    DepthPtr    depths = pScreen->allowedDepths;
 
66
 
 
67
    for (d = 0; d < pScreen->numDepths; d++)
 
68
        xfree (depths[d].vids);
 
69
    xfree (depths);
 
70
    xfree (pScreen->visuals);
 
71
#ifdef CFB_NEED_SCREEN_PRIVATE
 
72
    xfree (pScreen->devPrivates[cfbScreenPrivateIndex].ptr);
 
73
#else
 
74
    xfree (pScreen->devPrivate);
 
75
#endif
 
76
    return TRUE;
 
77
}
 
78
 
 
79
static void DestroyColormapNoop(
 
80
        ColormapPtr pColormap)
 
81
{
 
82
    /* NOOP */
 
83
}
 
84
 
 
85
static void StoreColorsNoop(
 
86
        ColormapPtr pColormap,
 
87
        int ndef,
 
88
        xColorItem * pdef)
 
89
{
 
90
    /* NOOP */
 
91
}
 
92
 
 
93
Bool
 
94
cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
 
95
    register ScreenPtr pScreen;
 
96
    pointer pbits;              /* pointer to screen bitmap */
 
97
    int xsize, ysize;           /* in pixels */
 
98
    int dpix, dpiy;             /* dots per inch */
 
99
    int width;                  /* pixel width of frame buffer */
 
100
{
 
101
    if (!cfbAllocatePrivates(pScreen, (int *) 0, (int *) 0))
 
102
        return FALSE;
 
103
    pScreen->defColormap = FakeClientID(0);
 
104
    /* let CreateDefColormap do whatever it wants for pixels */ 
 
105
    pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
 
106
    pScreen->QueryBestSize = mfbQueryBestSizeWeak();
 
107
    /* SaveScreen */
 
108
    pScreen->GetImage = cfbGetImage;
 
109
    pScreen->GetSpans = cfbGetSpans;
 
110
    pScreen->CreateWindow = cfbCreateWindow;
 
111
    pScreen->DestroyWindow = cfbDestroyWindow;
 
112
    pScreen->PositionWindow = cfbPositionWindow;
 
113
    pScreen->ChangeWindowAttributes = cfbChangeWindowAttributes;
 
114
    pScreen->RealizeWindow = cfbMapWindow;
 
115
    pScreen->UnrealizeWindow = cfbUnmapWindow;
 
116
    pScreen->PaintWindowBackground = cfbPaintWindow;
 
117
    pScreen->PaintWindowBorder = cfbPaintWindow;
 
118
    pScreen->CopyWindow = cfbCopyWindow;
 
119
    pScreen->CreatePixmap = cfbCreatePixmap;
 
120
    pScreen->DestroyPixmap = cfbDestroyPixmap;
 
121
    pScreen->RealizeFont = mfbRealizeFontWeak();
 
122
    pScreen->UnrealizeFont = mfbUnrealizeFontWeak();
 
123
    pScreen->CreateGC = cfbCreateGC;
 
124
    pScreen->CreateColormap = cfbInitializeColormap;
 
125
    pScreen->DestroyColormap = DestroyColormapNoop;
 
126
    pScreen->InstallColormap = cfbInstallColormap;
 
127
    pScreen->UninstallColormap = cfbUninstallColormap;
 
128
    pScreen->ListInstalledColormaps = cfbListInstalledColormaps;
 
129
    pScreen->StoreColors = StoreColorsNoop;
 
130
    pScreen->ResolveColor = cfbResolveColor;
 
131
    pScreen->BitmapToRegion = mfbPixmapToRegionWeak();
 
132
 
 
133
    mfbRegisterCopyPlaneProc (pScreen, cfbCopyPlane);
 
134
    return TRUE;
 
135
}
 
136
 
 
137
#ifdef CFB_NEED_SCREEN_PRIVATE
 
138
Bool
 
139
cfbCreateScreenResources(pScreen)
 
140
    ScreenPtr pScreen;
 
141
{
 
142
    Bool retval;
 
143
 
 
144
    pointer oldDevPrivate = pScreen->devPrivate;
 
145
    pScreen->devPrivate = pScreen->devPrivates[cfbScreenPrivateIndex].ptr;
 
146
    retval = miCreateScreenResources(pScreen);
 
147
    pScreen->devPrivates[cfbScreenPrivateIndex].ptr = pScreen->devPrivate;
 
148
    pScreen->devPrivate = oldDevPrivate;
 
149
    return retval;
 
150
}
 
151
#endif
 
152
 
 
153
Bool
 
154
cfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
 
155
    register ScreenPtr pScreen;
 
156
    pointer pbits;              /* pointer to screen bitmap */
 
157
    int xsize, ysize;           /* in pixels */
 
158
    int dpix, dpiy;             /* dots per inch */
 
159
    int width;                  /* pixel width of frame buffer */
 
160
{
 
161
#ifdef CFB_NEED_SCREEN_PRIVATE
 
162
    pointer oldDevPrivate;
 
163
#endif
 
164
    VisualPtr   visuals;
 
165
    DepthPtr    depths;
 
166
    int         nvisuals;
 
167
    int         ndepths;
 
168
    int         rootdepth;
 
169
    VisualID    defaultVisual;
 
170
 
 
171
    rootdepth = 0;
 
172
    if (!cfbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &rootdepth,
 
173
                         &defaultVisual,((unsigned long)1<<(PSZ-1)), 8))
 
174
        return FALSE;
 
175
#ifdef CFB_NEED_SCREEN_PRIVATE
 
176
    oldDevPrivate = pScreen->devPrivate;
 
177
#endif
 
178
    if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
 
179
                        rootdepth, ndepths, depths,
 
180
                        defaultVisual, nvisuals, visuals))
 
181
        return FALSE;
 
182
    /* overwrite miCloseScreen with our own */
 
183
    pScreen->CloseScreen = cfbCloseScreen;
 
184
#ifdef CFB_NEED_SCREEN_PRIVATE
 
185
    pScreen->CreateScreenResources = cfbCreateScreenResources;
 
186
    pScreen->devPrivates[cfbScreenPrivateIndex].ptr = pScreen->devPrivate;
 
187
    pScreen->devPrivate = oldDevPrivate;
 
188
#endif
 
189
    pScreen->BackingStoreFuncs = cfbBSFuncRec;
 
190
    pScreen->GetScreenPixmap = cfbGetScreenPixmap;
 
191
    pScreen->SetScreenPixmap = cfbSetScreenPixmap;
 
192
    return TRUE;
 
193
}
 
194
 
 
195
/* dts * (inch/dot) * (25.4 mm / inch) = mm */
 
196
Bool
 
197
cfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
 
198
    register ScreenPtr pScreen;
 
199
    pointer pbits;              /* pointer to screen bitmap */
 
200
    int xsize, ysize;           /* in pixels */
 
201
    int dpix, dpiy;             /* dots per inch */
 
202
    int width;                  /* pixel width of frame buffer */
 
203
{
 
204
    if (!cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width))
 
205
        return FALSE;
 
206
    return cfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
 
207
}
 
208
 
 
209
PixmapPtr
 
210
cfbGetScreenPixmap(pScreen)
 
211
    ScreenPtr pScreen;
 
212
{
 
213
#ifdef CFB_NEED_SCREEN_PRIVATE
 
214
    return (PixmapPtr)pScreen->devPrivates[cfbScreenPrivateIndex].ptr;
 
215
#else
 
216
    return (PixmapPtr)pScreen->devPrivate;
 
217
#endif
 
218
}
 
219
 
 
220
void
 
221
cfbSetScreenPixmap(pPix)
 
222
    PixmapPtr pPix;
 
223
{
 
224
#ifdef CFB_NEED_SCREEN_PRIVATE
 
225
    if (pPix)
 
226
        pPix->drawable.pScreen->devPrivates[cfbScreenPrivateIndex].ptr =
 
227
            (pointer)pPix;
 
228
#else
 
229
    if (pPix)
 
230
        pPix->drawable.pScreen->devPrivate = (pointer)pPix;
 
231
#endif
 
232
}