2 * Copyright 2002-2004 Red Hat Inc., Durham, North Carolina.
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 on the rights to use, copy, modify, merge,
10 * publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial
16 * portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
22 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * Kevin E. Martin <kem@redhat.com>
35 * This file provides support for visuals. */
37 #ifdef HAVE_DMX_CONFIG_H
38 #include <dmx-config.h>
42 #include "dmxvisual.h"
44 #include "scrnintstr.h"
48 #include <GL/glxint.h>
50 extern VisualID
glxMatchVisualInConfigList(ScreenPtr pScreen
,
52 __GLXvisualConfig
* configs
,
56 dmxLookupGLXVisual(ScreenPtr pScreen
, VisualPtr pVisual
)
58 DMXScreenInfo
*dmxScreen
= &dmxScreens
[pScreen
->myNum
];
62 vid
= glxMatchVisualInConfigList(pScreen
, pVisual
,
63 dmxScreen
->glxVisuals
,
64 dmxScreen
->numGlxVisuals
);
66 /* Find the X visual of the matching GLX visual */
67 for (j
= 0; j
< dmxScreen
->beNumVisuals
; j
++)
68 if (vid
== dmxScreen
->beVisuals
[j
].visualid
)
69 return dmxScreen
->beVisuals
[j
].visual
;
72 /* No matching visual found */
77 /** Return the visual that matched \a pVisual. */
79 dmxLookupVisual(ScreenPtr pScreen
, VisualPtr pVisual
)
81 DMXScreenInfo
*dmxScreen
= &dmxScreens
[pScreen
->myNum
];
88 if (!dmxScreen
->beDisplay
)
92 if ((retval
= dmxLookupGLXVisual(pScreen
, pVisual
)))
96 for (i
= 0; i
< dmxScreen
->beNumVisuals
; i
++) {
97 if (pVisual
->class == dmxScreen
->beVisuals
[i
].class &&
98 pVisual
->bitsPerRGBValue
== dmxScreen
->beVisuals
[i
].bits_per_rgb
&&
99 pVisual
->ColormapEntries
== dmxScreen
->beVisuals
[i
].colormap_size
&&
100 pVisual
->nplanes
== dmxScreen
->beVisuals
[i
].depth
&&
101 pVisual
->redMask
== dmxScreen
->beVisuals
[i
].red_mask
&&
102 pVisual
->greenMask
== dmxScreen
->beVisuals
[i
].green_mask
&&
103 pVisual
->blueMask
== dmxScreen
->beVisuals
[i
].blue_mask
) {
104 return dmxScreen
->beVisuals
[i
].visual
;
111 /** Return the visual that matched the \a vid. */
113 dmxLookupVisualFromID(ScreenPtr pScreen
, VisualID vid
)
118 if (!dmxScreens
[pScreen
->myNum
].beDisplay
)
121 for (i
= 0; i
< pScreen
->numVisuals
; i
++) {
122 if (pScreen
->visuals
[i
].vid
== vid
) {
123 visual
= dmxLookupVisual(pScreen
, &pScreen
->visuals
[i
]);
132 /** Return the colormap for the \a visual. */
134 dmxColormapFromDefaultVisual(ScreenPtr pScreen
, Visual
* visual
)
136 DMXScreenInfo
*dmxScreen
= &dmxScreens
[pScreen
->myNum
];
139 if (dmxScreen
->beDisplay
) {
140 for (i
= 0; i
< dmxScreen
->beNumDefColormaps
; i
++)
141 if (visual
== dmxScreen
->beVisuals
[i
].visual
)
142 return dmxScreen
->beDefColormaps
[i
];