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