Merge branch 'mesa_7_7_branch'
[mesa.git] / src / egl / main / egldisplay.h
1 #ifndef EGLDISPLAY_INCLUDED
2 #define EGLDISPLAY_INCLUDED
3
4 #include "egltypedefs.h"
5 #include "egldefines.h"
6
7
8 enum _egl_resource_type {
9 _EGL_RESOURCE_CONTEXT,
10 _EGL_RESOURCE_SURFACE,
11 _EGL_RESOURCE_IMAGE,
12
13 _EGL_NUM_RESOURCES
14 };
15
16
17 /**
18 * A resource of a display.
19 */
20 struct _egl_resource
21 {
22 /* which display the resource belongs to */
23 _EGLDisplay *Display;
24 EGLBoolean IsLinked;
25
26 /* used to link resources of the same type */
27 _EGLResource *Next;
28 };
29
30
31 /**
32 * Optional EGL extensions info.
33 */
34 struct _egl_extensions
35 {
36 EGLBoolean MESA_screen_surface;
37 EGLBoolean MESA_copy_context;
38 EGLBoolean KHR_image_base;
39 EGLBoolean KHR_image_pixmap;
40
41 char String[_EGL_MAX_EXTENSIONS_LEN];
42 };
43
44
45 struct _egl_display
46 {
47 /* used to link displays */
48 _EGLDisplay *Next;
49
50 EGLNativeDisplayType NativeDisplay;
51
52 _EGLDriver *Driver;
53 void *DriverData; /* private to driver */
54
55 int APImajor, APIminor; /**< as returned by eglInitialize() */
56 char Version[1000]; /**< initialized from APImajor/minor, DriverName */
57
58 /** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */
59 EGLint ClientAPIsMask;
60 char ClientAPIs[1000]; /**< updated by eglQueryString */
61
62 _EGLExtensions Extensions;
63
64 int LargestPbuffer;
65
66 EGLint NumScreens;
67 _EGLScreen **Screens; /* array [NumScreens] */
68
69 EGLint MaxConfigs;
70 EGLint NumConfigs;
71 _EGLConfig **Configs; /* array [NumConfigs] of ptr to _EGLConfig */
72
73 /* lists of resources */
74 _EGLResource *ResourceLists[_EGL_NUM_RESOURCES];
75 };
76
77
78 extern void
79 _eglFiniDisplay(void);
80
81
82 extern _EGLDisplay *
83 _eglNewDisplay(EGLNativeDisplayType displayName);
84
85
86 extern EGLDisplay
87 _eglLinkDisplay(_EGLDisplay *dpy);
88
89
90 extern void
91 _eglUnlinkDisplay(_EGLDisplay *dpy);
92
93
94 extern _EGLDisplay *
95 _eglFindDisplay(EGLNativeDisplayType nativeDisplay);
96
97
98 PUBLIC void
99 _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *dpy);
100
101
102 PUBLIC void
103 _eglCleanupDisplay(_EGLDisplay *disp);
104
105
106 #ifndef _EGL_SKIP_HANDLE_CHECK
107
108
109 extern EGLBoolean
110 _eglCheckDisplayHandle(EGLDisplay dpy);
111
112
113 PUBLIC EGLBoolean
114 _eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy);
115
116
117 #else /* !_EGL_SKIP_HANDLE_CHECK */
118
119 /* Only do a quick check. This is NOT standard compliant. */
120
121 static INLINE EGLBoolean
122 _eglCheckDisplayHandle(EGLDisplay dpy)
123 {
124 return ((_EGLDisplay *) dpy != NULL);
125 }
126
127
128 static INLINE EGLBoolean
129 _eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy);
130 {
131 return (((_EGLResource *) res)->Display == dpy);
132 }
133
134
135 #endif /* _EGL_SKIP_HANDLE_CHECK */
136
137
138 /**
139 * Lookup a handle to find the linked display.
140 * Return NULL if the handle has no corresponding linked display.
141 */
142 static INLINE _EGLDisplay *
143 _eglLookupDisplay(EGLDisplay display)
144 {
145 _EGLDisplay *dpy = (_EGLDisplay *) display;
146 if (!_eglCheckDisplayHandle(display))
147 dpy = NULL;
148 return dpy;
149 }
150
151
152 /**
153 * Return the handle of a linked display, or EGL_NO_DISPLAY.
154 */
155 static INLINE EGLDisplay
156 _eglGetDisplayHandle(_EGLDisplay *dpy)
157 {
158 return (EGLDisplay) ((dpy) ? dpy : EGL_NO_DISPLAY);
159 }
160
161
162 /**
163 * Return true if the display is linked.
164 */
165 static INLINE EGLBoolean
166 _eglIsDisplayLinked(_EGLDisplay *dpy)
167 {
168 return (EGLBoolean) (_eglGetDisplayHandle(dpy) != EGL_NO_DISPLAY);
169 }
170
171
172 extern void
173 _eglLinkResource(_EGLResource *res, _EGLResourceType type, _EGLDisplay *dpy);
174
175
176 extern void
177 _eglUnlinkResource(_EGLResource *res, _EGLResourceType type);
178
179
180 /**
181 * Return true if the resource is linked.
182 */
183 static INLINE EGLBoolean
184 _eglIsResourceLinked(_EGLResource *res)
185 {
186 return res->IsLinked;
187 }
188
189
190 #endif /* EGLDISPLAY_INCLUDED */