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