summaryrefslogtreecommitdiff
path: root/hw/xscreen/xs-visual.c
blob: 3280538434bc0c52e1aab180b5eddeda3fc77f0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* $Xorg: Visual.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
/*

   Copyright 1993 by Davor Matic

   Permission to use, copy, modify, distribute, and sell this software
   and its documentation for any purpose is hereby granted without fee,
   provided that the above copyright notice appear in all copies and that
   both that copyright notice and this permission notice appear in
   supporting documentation.  Davor Matic makes no representations about
   the suitability of this software for any purpose.  It is provided "as
   is" without express or implied warranty.

*/
/* $XFree86$ */

#ifdef HAVE_XNEST_CONFIG_H
#include <xs-config.h>
#endif

#include <X11/Xmd.h>
#include <xcb/xcb.h>
#include <xcb/xproto.h>
#include "scrnintstr.h"
#include "dix.h"
#include "mi.h"
#include "mibstore.h"

static int           num_visuals = 0;
static xcb_visualtype_t *visuals;
static uint8_t         *depths;

static void xsInitVisuals(void)
{
    /*initialize the visuals*/
}

xcb_visualtype_t *xsGetVisual(VisualPtr pVisual)
{
    int i;

    for (i = 0; i < num_visuals; i++)
        if (pVisual->class == visuals[i]._class &&
                pVisual->bitsPerRGBValue == visuals[i].bits_per_rgb_value &&
                pVisual->ColormapEntries == visuals[i].colormap_entries &&
                pVisual->nplanes == depths[i] &&
                pVisual->redMask == visuals[i].red_mask &&
                pVisual->greenMask == visuals[i].green_mask &&
                pVisual->blueMask == visuals[i].blue_mask)
            return &visuals[i];

    return NULL;
}

static xcb_visualtype_t *visualFromID(ScreenPtr pScreen, xcb_visualid_t visual)
{
    int i;

    for (i = 0; i < pScreen->numVisuals; i++)
        if (pScreen->visuals[i].vid == visual)
            return xsGetVisual(&pScreen->visuals[i]);

    return NULL;
}

static xcb_visualtype_t *xsGetDefaultVisual(ScreenPtr pScreen)
{
    xcb_visualid_t v;

    v = pScreen->rootVisual;
    return visualFromID(pScreen, v);
}

/*
xcb_colormap_t xsDefaultVisualColormap(xcb_visualtype_t *visual)
{
    int i;
    xcb_colormap_t noneCmap = { 0 };

    for (i = 0; i < num_visuals; i++)
        if (&visuals[i] == visual)
            return xsDefaultColormaps[i];

    return noneCmap;
}
*/