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
,
55 static Visual
*dmxLookupGLXVisual(ScreenPtr pScreen
, VisualPtr pVisual
)
57 DMXScreenInfo
*dmxScreen
= &dmxScreens
[pScreen
->myNum
];
61 vid
= glxMatchVisualInConfigList(pScreen
, pVisual
,
62 dmxScreen
->glxVisuals
,
63 dmxScreen
->numGlxVisuals
);
65 /* Find the X visual of the matching GLX visual */
66 for (j
= 0; j
< dmxScreen
->beNumVisuals
; j
++)
67 if (vid
== dmxScreen
->beVisuals
[j
].visualid
)
68 return dmxScreen
->beVisuals
[j
].visual
;
71 /* No matching visual found */
76 /** Return the visual that matched \a pVisual. */
77 Visual
*dmxLookupVisual(ScreenPtr pScreen
, VisualPtr pVisual
)
79 DMXScreenInfo
*dmxScreen
= &dmxScreens
[pScreen
->myNum
];
85 if (!dmxScreen
->beDisplay
)
89 if ((retval
= dmxLookupGLXVisual(pScreen
, pVisual
)))
93 for (i
= 0; i
< dmxScreen
->beNumVisuals
; i
++) {
94 if (pVisual
->class == dmxScreen
->beVisuals
[i
].class &&
95 pVisual
->bitsPerRGBValue
== dmxScreen
->beVisuals
[i
].bits_per_rgb
&&
96 pVisual
->ColormapEntries
== dmxScreen
->beVisuals
[i
].colormap_size
&&
97 pVisual
->nplanes
== dmxScreen
->beVisuals
[i
].depth
&&
98 pVisual
->redMask
== dmxScreen
->beVisuals
[i
].red_mask
&&
99 pVisual
->greenMask
== dmxScreen
->beVisuals
[i
].green_mask
&&
100 pVisual
->blueMask
== dmxScreen
->beVisuals
[i
].blue_mask
) {
101 return dmxScreen
->beVisuals
[i
].visual
;
108 /** Return the visual that matched the \a vid. */
109 Visual
*dmxLookupVisualFromID(ScreenPtr pScreen
, VisualID vid
)
114 if (!dmxScreens
[pScreen
->myNum
].beDisplay
)
117 for (i
= 0; i
< pScreen
->numVisuals
; i
++) {
118 if (pScreen
->visuals
[i
].vid
== vid
) {
119 visual
= dmxLookupVisual(pScreen
, &pScreen
->visuals
[i
]);
120 if (visual
) return visual
;
127 /** Return the colormap for the \a visual. */
128 Colormap
dmxColormapFromDefaultVisual(ScreenPtr pScreen
, Visual
*visual
)
130 DMXScreenInfo
*dmxScreen
= &dmxScreens
[pScreen
->myNum
];
133 if (dmxScreen
->beDisplay
) {
134 for (i
= 0; i
< dmxScreen
->beNumDefColormaps
; i
++)
135 if (visual
== dmxScreen
->beVisuals
[i
].visual
)
136 return dmxScreen
->beDefColormaps
[i
];