Merge remote branch 'origin/master' into nv50-compiler
[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 #include "eglmutex.h"
8 #include "eglarray.h"
9
10
11 enum _egl_platform_type {
12 _EGL_PLATFORM_WINDOWS,
13 _EGL_PLATFORM_X11,
14 _EGL_PLATFORM_DRM,
15 _EGL_PLATFORM_FBDEV,
16
17 _EGL_NUM_PLATFORMS,
18 _EGL_INVALID_PLATFORM = -1
19 };
20 typedef enum _egl_platform_type _EGLPlatformType;
21
22
23 enum _egl_resource_type {
24 _EGL_RESOURCE_CONTEXT,
25 _EGL_RESOURCE_SURFACE,
26 _EGL_RESOURCE_IMAGE,
27
28 _EGL_NUM_RESOURCES
29 };
30 /* this cannot and need not go into egltypedefs.h */
31 typedef enum _egl_resource_type _EGLResourceType;
32
33
34 /**
35 * A resource of a display.
36 */
37 struct _egl_resource
38 {
39 /* which display the resource belongs to */
40 _EGLDisplay *Display;
41 EGLBoolean IsLinked;
42
43 /* used to link resources of the same type */
44 _EGLResource *Next;
45 };
46
47
48 /**
49 * Optional EGL extensions info.
50 */
51 struct _egl_extensions
52 {
53 EGLBoolean MESA_screen_surface;
54 EGLBoolean MESA_copy_context;
55 EGLBoolean MESA_drm_display;
56 EGLBoolean KHR_image_base;
57 EGLBoolean KHR_image_pixmap;
58 EGLBoolean KHR_vg_parent_image;
59 EGLBoolean KHR_gl_texture_2D_image;
60 EGLBoolean KHR_gl_texture_cubemap_image;
61 EGLBoolean KHR_gl_texture_3D_image;
62 EGLBoolean KHR_gl_renderbuffer_image;
63 EGLBoolean KHR_surfaceless_gles1;
64 EGLBoolean KHR_surfaceless_gles2;
65 EGLBoolean KHR_surfaceless_opengl;
66 EGLBoolean NOK_swap_region;
67 EGLBoolean NOK_texture_from_pixmap;
68
69 char String[_EGL_MAX_EXTENSIONS_LEN];
70 };
71
72
73 struct _egl_display
74 {
75 /* used to link displays */
76 _EGLDisplay *Next;
77
78 _EGLMutex Mutex;
79
80 _EGLPlatformType Platform;
81 void *PlatformDisplay;
82
83 EGLBoolean Initialized; /**< True if the display is initialized */
84 _EGLDriver *Driver;
85 void *DriverData; /* private to driver */
86
87 int APImajor, APIminor; /**< as returned by eglInitialize() */
88 char Version[1000]; /**< initialized from APImajor/minor, DriverName */
89
90 /** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */
91 EGLint ClientAPIsMask;
92 char ClientAPIs[1000]; /**< updated by eglQueryString */
93
94 _EGLExtensions Extensions;
95
96 _EGLArray *Screens;
97 _EGLArray *Configs;
98
99 /* lists of resources */
100 _EGLResource *ResourceLists[_EGL_NUM_RESOURCES];
101 };
102
103
104 extern _EGLPlatformType
105 _eglGetNativePlatform(void);
106
107
108 extern void
109 _eglFiniDisplay(void);
110
111
112 extern _EGLDisplay *
113 _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy);
114
115
116 PUBLIC void
117 _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *dpy);
118
119
120 PUBLIC void
121 _eglCleanupDisplay(_EGLDisplay *disp);
122
123
124 extern EGLBoolean
125 _eglCheckDisplayHandle(EGLDisplay dpy);
126
127
128 PUBLIC EGLBoolean
129 _eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy);
130
131
132 /**
133 * Lookup a handle to find the linked display.
134 * Return NULL if the handle has no corresponding linked display.
135 */
136 static INLINE _EGLDisplay *
137 _eglLookupDisplay(EGLDisplay display)
138 {
139 _EGLDisplay *dpy = (_EGLDisplay *) display;
140 if (!_eglCheckDisplayHandle(display))
141 dpy = NULL;
142 return dpy;
143 }
144
145
146 /**
147 * Return the handle of a linked display, or EGL_NO_DISPLAY.
148 */
149 static INLINE EGLDisplay
150 _eglGetDisplayHandle(_EGLDisplay *dpy)
151 {
152 return (EGLDisplay) ((dpy) ? dpy : EGL_NO_DISPLAY);
153 }
154
155
156 extern void
157 _eglLinkResource(_EGLResource *res, _EGLResourceType type, _EGLDisplay *dpy);
158
159
160 extern void
161 _eglUnlinkResource(_EGLResource *res, _EGLResourceType type);
162
163
164 /**
165 * Return true if the resource is linked.
166 */
167 static INLINE EGLBoolean
168 _eglIsResourceLinked(_EGLResource *res)
169 {
170 return res->IsLinked;
171 }
172
173
174 #endif /* EGLDISPLAY_INCLUDED */