egl: Add support for more EGLImage extensions to EGL core.
[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 int LargestPbuffer;
72
73 EGLint NumScreens;
74 _EGLScreen **Screens; /* array [NumScreens] */
75
76 EGLint MaxConfigs;
77 EGLint NumConfigs;
78 _EGLConfig **Configs; /* array [NumConfigs] of ptr to _EGLConfig */
79
80 /* lists of resources */
81 _EGLResource *ResourceLists[_EGL_NUM_RESOURCES];
82 };
83
84
85 extern void
86 _eglFiniDisplay(void);
87
88
89 extern _EGLDisplay *
90 _eglNewDisplay(EGLNativeDisplayType displayName);
91
92
93 extern EGLDisplay
94 _eglLinkDisplay(_EGLDisplay *dpy);
95
96
97 extern void
98 _eglUnlinkDisplay(_EGLDisplay *dpy);
99
100
101 extern _EGLDisplay *
102 _eglFindDisplay(EGLNativeDisplayType nativeDisplay);
103
104
105 PUBLIC void
106 _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *dpy);
107
108
109 PUBLIC void
110 _eglCleanupDisplay(_EGLDisplay *disp);
111
112
113 #ifndef _EGL_SKIP_HANDLE_CHECK
114
115
116 extern EGLBoolean
117 _eglCheckDisplayHandle(EGLDisplay dpy);
118
119
120 PUBLIC EGLBoolean
121 _eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy);
122
123
124 #else /* !_EGL_SKIP_HANDLE_CHECK */
125
126 /* Only do a quick check. This is NOT standard compliant. */
127
128 static INLINE EGLBoolean
129 _eglCheckDisplayHandle(EGLDisplay dpy)
130 {
131 return ((_EGLDisplay *) dpy != NULL);
132 }
133
134
135 static INLINE EGLBoolean
136 _eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy);
137 {
138 return (((_EGLResource *) res)->Display == dpy);
139 }
140
141
142 #endif /* _EGL_SKIP_HANDLE_CHECK */
143
144
145 /**
146 * Lookup a handle to find the linked display.
147 * Return NULL if the handle has no corresponding linked display.
148 */
149 static INLINE _EGLDisplay *
150 _eglLookupDisplay(EGLDisplay display)
151 {
152 _EGLDisplay *dpy = (_EGLDisplay *) display;
153 if (!_eglCheckDisplayHandle(display))
154 dpy = NULL;
155 return dpy;
156 }
157
158
159 /**
160 * Return the handle of a linked display, or EGL_NO_DISPLAY.
161 */
162 static INLINE EGLDisplay
163 _eglGetDisplayHandle(_EGLDisplay *dpy)
164 {
165 return (EGLDisplay) ((dpy) ? dpy : EGL_NO_DISPLAY);
166 }
167
168
169 /**
170 * Return true if the display is linked.
171 */
172 static INLINE EGLBoolean
173 _eglIsDisplayLinked(_EGLDisplay *dpy)
174 {
175 return (EGLBoolean) (_eglGetDisplayHandle(dpy) != EGL_NO_DISPLAY);
176 }
177
178
179 extern void
180 _eglLinkResource(_EGLResource *res, _EGLResourceType type, _EGLDisplay *dpy);
181
182
183 extern void
184 _eglUnlinkResource(_EGLResource *res, _EGLResourceType type);
185
186
187 /**
188 * Return true if the resource is linked.
189 */
190 static INLINE EGLBoolean
191 _eglIsResourceLinked(_EGLResource *res)
192 {
193 return res->IsLinked;
194 }
195
196
197 #endif /* EGLDISPLAY_INCLUDED */