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