xref: /OK3568_Linux_fs/external/xserver/glx/vndserver.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright (c) 2016, NVIDIA CORPORATION.
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Permission is hereby granted, free of charge, to any person obtaining a
5*4882a593Smuzhiyun  * copy of this software and/or associated documentation files (the
6*4882a593Smuzhiyun  * "Materials"), to deal in the Materials without restriction, including
7*4882a593Smuzhiyun  * without limitation the rights to use, copy, modify, merge, publish,
8*4882a593Smuzhiyun  * distribute, sublicense, and/or sell copies of the Materials, and to
9*4882a593Smuzhiyun  * permit persons to whom the Materials are furnished to do so, subject to
10*4882a593Smuzhiyun  * the following conditions:
11*4882a593Smuzhiyun  *
12*4882a593Smuzhiyun  * The above copyright notice and this permission notice shall be included
13*4882a593Smuzhiyun  * unaltered in all copies or substantial portions of the Materials.
14*4882a593Smuzhiyun  * Any additions, deletions, or changes to the original source files
15*4882a593Smuzhiyun  * must be clearly indicated in accompanying documentation.
16*4882a593Smuzhiyun  *
17*4882a593Smuzhiyun  * If only executable code is distributed, then the accompanying
18*4882a593Smuzhiyun  * documentation must state that "this software is based in part on the
19*4882a593Smuzhiyun  * work of the Khronos Group."
20*4882a593Smuzhiyun  *
21*4882a593Smuzhiyun  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22*4882a593Smuzhiyun  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23*4882a593Smuzhiyun  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24*4882a593Smuzhiyun  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
25*4882a593Smuzhiyun  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26*4882a593Smuzhiyun  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27*4882a593Smuzhiyun  * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
28*4882a593Smuzhiyun  */
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun #ifndef VNDSERVER_H
31*4882a593Smuzhiyun #define VNDSERVER_H
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun #include <dix-config.h>
34*4882a593Smuzhiyun #include "glxvndabi.h"
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun #define GLXContextID CARD32
37*4882a593Smuzhiyun #define GLXDrawable CARD32
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun #if defined(__cplusplus)
40*4882a593Smuzhiyun extern "C" {
41*4882a593Smuzhiyun #endif
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun typedef struct GlxScreenPrivRec {
44*4882a593Smuzhiyun     GlxServerVendor *vendor;
45*4882a593Smuzhiyun } GlxScreenPriv;
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun typedef struct GlxContextTagInfoRec {
48*4882a593Smuzhiyun     GLXContextTag tag;
49*4882a593Smuzhiyun     ClientPtr client;
50*4882a593Smuzhiyun     GlxServerVendor *vendor;
51*4882a593Smuzhiyun     void *data;
52*4882a593Smuzhiyun     GLXContextID context;
53*4882a593Smuzhiyun     GLXDrawable drawable;
54*4882a593Smuzhiyun     GLXDrawable readdrawable;
55*4882a593Smuzhiyun } GlxContextTagInfo;
56*4882a593Smuzhiyun 
57*4882a593Smuzhiyun typedef struct GlxClientPrivRec {
58*4882a593Smuzhiyun     GlxContextTagInfo *contextTags;
59*4882a593Smuzhiyun     unsigned int contextTagCount;
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun     /**
62*4882a593Smuzhiyun      * The vendor handles for each screen.
63*4882a593Smuzhiyun      */
64*4882a593Smuzhiyun     GlxServerVendor **vendors;
65*4882a593Smuzhiyun } GlxClientPriv;
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun extern int GlxErrorBase;
68*4882a593Smuzhiyun extern RESTYPE idResource;
69*4882a593Smuzhiyun 
70*4882a593Smuzhiyun extern ExtensionEntry *GlxExtensionEntry;
71*4882a593Smuzhiyun Bool GlxDispatchInit(void);
72*4882a593Smuzhiyun void GlxDispatchReset(void);
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun /**
75*4882a593Smuzhiyun  * Handles a request from the client.
76*4882a593Smuzhiyun  *
77*4882a593Smuzhiyun  * This function will look up the correct handler function and forward the
78*4882a593Smuzhiyun  * request to it.
79*4882a593Smuzhiyun  */
80*4882a593Smuzhiyun int GlxDispatchRequest(ClientPtr client);
81*4882a593Smuzhiyun 
82*4882a593Smuzhiyun /**
83*4882a593Smuzhiyun  * Looks up the GlxClientPriv struct for a client. If we don't have a
84*4882a593Smuzhiyun  * GlxClientPriv struct yet, then allocate one.
85*4882a593Smuzhiyun  */
86*4882a593Smuzhiyun GlxClientPriv *GlxGetClientData(ClientPtr client);
87*4882a593Smuzhiyun 
88*4882a593Smuzhiyun /**
89*4882a593Smuzhiyun  * Frees any data that's specific to a client. This should be called when a
90*4882a593Smuzhiyun  * client disconnects.
91*4882a593Smuzhiyun  */
92*4882a593Smuzhiyun void GlxFreeClientData(ClientPtr client);
93*4882a593Smuzhiyun 
94*4882a593Smuzhiyun Bool GlxAddXIDMap(XID id, GlxServerVendor *vendor);
95*4882a593Smuzhiyun GlxServerVendor * GlxGetXIDMap(XID id);
96*4882a593Smuzhiyun void GlxRemoveXIDMap(XID id);
97*4882a593Smuzhiyun 
98*4882a593Smuzhiyun /**
99*4882a593Smuzhiyun  * Records the client that sent the current request. This is needed in
100*4882a593Smuzhiyun  * GlxGetXIDMap to know which client's (screen -> vendor) mapping to use for a
101*4882a593Smuzhiyun  * regular X window.
102*4882a593Smuzhiyun  */
103*4882a593Smuzhiyun void GlxSetRequestClient(ClientPtr client);
104*4882a593Smuzhiyun 
105*4882a593Smuzhiyun GlxContextTagInfo *GlxAllocContextTag(ClientPtr client, GlxServerVendor *vendor);
106*4882a593Smuzhiyun GlxContextTagInfo *GlxLookupContextTag(ClientPtr client, GLXContextTag tag);
107*4882a593Smuzhiyun void GlxFreeContextTag(GlxContextTagInfo *tagInfo);
108*4882a593Smuzhiyun 
109*4882a593Smuzhiyun Bool GlxSetScreenVendor(ScreenPtr screen, GlxServerVendor *vendor);
110*4882a593Smuzhiyun Bool GlxSetClientScreenVendor(ClientPtr client, ScreenPtr screen, GlxServerVendor *vendor);
111*4882a593Smuzhiyun GlxScreenPriv *GlxGetScreen(ScreenPtr pScreen);
112*4882a593Smuzhiyun GlxServerVendor *GlxGetVendorForScreen(ClientPtr client, ScreenPtr screen);
113*4882a593Smuzhiyun 
GlxCheckSwap(ClientPtr client,CARD32 value)114*4882a593Smuzhiyun static inline CARD32 GlxCheckSwap(ClientPtr client, CARD32 value)
115*4882a593Smuzhiyun {
116*4882a593Smuzhiyun     if (client->swapped)
117*4882a593Smuzhiyun     {
118*4882a593Smuzhiyun         value = ((value & 0XFF000000) >> 24) | ((value & 0X00FF0000) >>  8)
119*4882a593Smuzhiyun             | ((value & 0X0000FF00) <<  8) | ((value & 0X000000FF) << 24);
120*4882a593Smuzhiyun     }
121*4882a593Smuzhiyun     return value;
122*4882a593Smuzhiyun }
123*4882a593Smuzhiyun 
124*4882a593Smuzhiyun #if defined(__cplusplus)
125*4882a593Smuzhiyun }
126*4882a593Smuzhiyun #endif
127*4882a593Smuzhiyun 
128*4882a593Smuzhiyun _X_EXPORT const GlxServerExports *glvndGetExports(void);
129*4882a593Smuzhiyun 
130*4882a593Smuzhiyun #endif // VNDSERVER_H
131