Commit | Line | Data |
---|---|---|
a09e091a JB |
1 | /* |
2 | * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) | |
3 | * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. | |
4 | * | |
5 | * Permission is hereby granted, free of charge, to any person obtaining a | |
6 | * copy of this software and associated documentation files (the "Software"), | |
7 | * to deal in the Software without restriction, including without limitation | |
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
9 | * and/or sell copies of the Software, and to permit persons to whom the | |
10 | * Software is furnished to do so, subject to the following conditions: | |
11 | * | |
12 | * The above copyright notice including the dates of first publication and | |
13 | * either this permission notice or a reference to | |
14 | * http://oss.sgi.com/projects/FreeB/ | |
15 | * shall be included 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 MERCHANTABILITY, | |
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
20 | * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF | |
22 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
23 | * SOFTWARE. | |
24 | * | |
25 | * Except as contained in this notice, the name of Silicon Graphics, Inc. | |
26 | * shall not be used in advertising or otherwise to promote the sale, use or | |
27 | * other dealings in this Software without prior written authorization from | |
28 | * Silicon Graphics, Inc. | |
29 | */ | |
30 | ||
31 | #ifdef HAVE_DMX_CONFIG_H | |
32 | #include <dmx-config.h> | |
33 | #endif | |
34 | ||
35 | #include "glxserver.h" | |
36 | #include "glxvisuals.h" | |
37 | ||
38 | int | |
39 | glxVisualsMatch(__GLXvisualConfig * v1, __GLXvisualConfig * v2) | |
40 | { | |
41 | if ((v1->class == v2->class) && | |
42 | (v1->rgba == v2->rgba) && | |
43 | (v1->redSize == v2->redSize) && | |
44 | (v1->greenSize == v2->greenSize) && | |
45 | (v1->blueSize == v2->blueSize) && | |
46 | (v1->alphaSize == v2->alphaSize) && | |
47 | (v1->redMask == v2->redMask) && | |
48 | (v1->greenMask == v2->greenMask) && | |
49 | (v1->blueMask == v2->blueMask) && | |
50 | (v1->alphaMask == v2->alphaMask) && | |
51 | (v1->accumRedSize == v2->accumRedSize) && | |
52 | (v1->accumGreenSize == v2->accumGreenSize) && | |
53 | (v1->accumBlueSize == v2->accumBlueSize) && | |
54 | (v1->accumAlphaSize == v2->accumAlphaSize) && | |
55 | (v1->doubleBuffer == v2->doubleBuffer) && | |
56 | (v1->stereo == v2->stereo) && | |
57 | (v1->bufferSize == v2->bufferSize) && | |
58 | (v1->depthSize == v2->depthSize) && | |
59 | (v1->stencilSize == v2->stencilSize) && | |
60 | (v1->auxBuffers == v2->auxBuffers) && | |
61 | (v1->level == v2->level) && | |
62 | (v1->visualRating == v2->visualRating) && | |
63 | (v1->transparentPixel == v2->transparentPixel) && | |
64 | (v1->transparentRed == v2->transparentRed) && | |
65 | (v1->transparentGreen == v2->transparentGreen) && | |
66 | (v1->transparentBlue == v2->transparentBlue) && | |
67 | (v1->transparentAlpha == v2->transparentAlpha) && | |
68 | (v1->transparentIndex == v2->transparentIndex) && | |
69 | (v1->multiSampleSize == v2->multiSampleSize) && | |
70 | (v1->nMultiSampleBuffers == v2->nMultiSampleBuffers) && | |
71 | (v1->visualSelectGroup == v2->visualSelectGroup)) { | |
72 | ||
73 | return 1; | |
74 | ||
75 | } | |
76 | ||
77 | return 0; | |
78 | ||
79 | } | |
80 | ||
81 | VisualID | |
82 | glxMatchGLXVisualInConfigList(__GLXvisualConfig * pGlxVisual, | |
83 | __GLXvisualConfig * configs, int nconfigs) | |
84 | { | |
85 | int i; | |
86 | ||
87 | for (i = 0; i < nconfigs; i++) { | |
88 | ||
89 | if (glxVisualsMatch(pGlxVisual, &configs[i])) { | |
90 | ||
91 | return configs[i].vid; | |
92 | ||
93 | } | |
94 | } | |
95 | ||
96 | return 0; | |
97 | } | |
98 | ||
99 | VisualID | |
100 | glxMatchVisualInConfigList(ScreenPtr pScreen, VisualPtr pVisual, | |
101 | __GLXvisualConfig * configs, int nconfigs) | |
102 | { | |
103 | __GLXscreenInfo *pGlxScreen; | |
104 | __GLXvisualConfig *pGlxVisual; | |
105 | int i; | |
106 | ||
107 | /* check that the glx extension has been initialized */ | |
108 | if (!__glXActiveScreens) | |
109 | return 0; | |
110 | ||
111 | pGlxScreen = &__glXActiveScreens[pScreen->myNum]; | |
112 | pGlxVisual = pGlxScreen->pGlxVisual; | |
113 | ||
114 | /* find the glx visual info for pVisual */ | |
115 | for (i = 0; i < pGlxScreen->numVisuals; i++, pGlxVisual++) { | |
116 | if (pGlxVisual->vid == pVisual->vid) { | |
117 | break; | |
118 | } | |
119 | } | |
120 | if (i == pGlxScreen->numVisuals) { | |
121 | /* | |
122 | * the visual is not supported by glx | |
123 | */ | |
124 | return 0; | |
125 | } | |
126 | ||
127 | return (glxMatchGLXVisualInConfigList(pGlxVisual, configs, nconfigs)); | |
128 | } | |
129 | ||
130 | VisualPtr | |
131 | glxMatchVisual(ScreenPtr pScreen, VisualPtr pVisual, ScreenPtr pMatchScreen) | |
132 | { | |
133 | __GLXscreenInfo *pGlxScreen2; | |
134 | int j; | |
135 | VisualID vid; | |
136 | ||
137 | /* check that the glx extension has been initialized */ | |
138 | if (!__glXActiveScreens) | |
139 | return NULL; | |
140 | ||
141 | pGlxScreen2 = &__glXActiveScreens[pMatchScreen->myNum]; | |
142 | ||
143 | vid = glxMatchVisualInConfigList(pScreen, pVisual, | |
144 | pGlxScreen2->pGlxVisual, | |
145 | pGlxScreen2->numVisuals); | |
146 | if (vid) { | |
147 | /* | |
148 | * find the X visual of the matching glx visual | |
149 | */ | |
150 | for (j = 0; j < pMatchScreen->numVisuals; j++) { | |
151 | if (vid == pMatchScreen->visuals[j].vid) { | |
152 | return &pMatchScreen->visuals[j]; | |
153 | } | |
154 | } | |
155 | } | |
156 | ||
157 | return 0; | |
158 | } |