egl: Move surface functions in egldisplay.[ch] to eglsurface.[ch]
[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 /**
9 * Optional EGL extensions info.
10 */
11 struct _egl_extensions
12 {
13 EGLBoolean MESA_screen_surface;
14 EGLBoolean MESA_copy_context;
15
16 char String[_EGL_MAX_EXTENSIONS_LEN];
17 };
18
19
20 struct _egl_display
21 {
22 /* used to link displays */
23 _EGLDisplay *Next;
24
25 EGLNativeDisplayType NativeDisplay;
26
27 _EGLDriver *Driver;
28 void *DriverData; /* private to driver */
29
30 int APImajor, APIminor; /**< as returned by eglInitialize() */
31 char Version[1000]; /**< initialized from APImajor/minor, DriverName */
32
33 /** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */
34 EGLint ClientAPIsMask;
35 char ClientAPIs[1000]; /**< updated by eglQueryString */
36
37 _EGLExtensions Extensions;
38
39 int LargestPbuffer;
40
41 EGLint NumScreens;
42 _EGLScreen **Screens; /* array [NumScreens] */
43
44 EGLint MaxConfigs;
45 EGLint NumConfigs;
46 _EGLConfig **Configs; /* array [NumConfigs] of ptr to _EGLConfig */
47
48 /* lists of linked contexts and surface */
49 _EGLContext *ContextList;
50 _EGLSurface *SurfaceList;
51 };
52
53
54 extern void
55 _eglFiniDisplay(void);
56
57
58 extern _EGLDisplay *
59 _eglNewDisplay(NativeDisplayType displayName);
60
61
62 extern EGLDisplay
63 _eglLinkDisplay(_EGLDisplay *dpy);
64
65
66 extern void
67 _eglUnlinkDisplay(_EGLDisplay *dpy);
68
69
70 extern _EGLDisplay *
71 _eglFindDisplay(NativeDisplayType nativeDisplay);
72
73
74 PUBLIC void
75 _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *dpy);
76
77
78 PUBLIC void
79 _eglCleanupDisplay(_EGLDisplay *disp);
80
81
82 #ifndef _EGL_SKIP_HANDLE_CHECK
83
84
85 extern EGLBoolean
86 _eglCheckDisplayHandle(EGLDisplay dpy);
87
88
89 #else /* !_EGL_SKIP_HANDLE_CHECK */
90
91 /* Only do a quick check. This is NOT standard compliant. */
92
93 static INLINE EGLBoolean
94 _eglCheckDisplayHandle(EGLDisplay dpy)
95 {
96 return ((_EGLDisplay *) dpy != NULL);
97 }
98
99
100 #endif /* _EGL_SKIP_HANDLE_CHECK */
101
102
103 /**
104 * Lookup a handle to find the linked display.
105 * Return NULL if the handle has no corresponding linked display.
106 */
107 static INLINE _EGLDisplay *
108 _eglLookupDisplay(EGLDisplay display)
109 {
110 _EGLDisplay *dpy = (_EGLDisplay *) display;
111 if (!_eglCheckDisplayHandle(display))
112 dpy = NULL;
113 return dpy;
114 }
115
116
117 /**
118 * Return the handle of a linked display, or EGL_NO_DISPLAY.
119 */
120 static INLINE EGLDisplay
121 _eglGetDisplayHandle(_EGLDisplay *dpy)
122 {
123 return (EGLDisplay) ((dpy) ? dpy : EGL_NO_DISPLAY);
124 }
125
126
127 /**
128 * Return true if the display is linked.
129 */
130 static INLINE EGLBoolean
131 _eglIsDisplayLinked(_EGLDisplay *dpy)
132 {
133 return (EGLBoolean) (_eglGetDisplayHandle(dpy) != EGL_NO_DISPLAY);
134 }
135
136
137 /**
138 * Cast an unsigned int to a pointer.
139 */
140 static INLINE void *
141 _eglUIntToPointer(unsigned int v)
142 {
143 return (void *) ((uintptr_t) v);
144 }
145
146
147 /**
148 * Cast a pointer to an unsigned int. The pointer must be one that is
149 * returned by _eglUIntToPointer.
150 */
151 static INLINE unsigned int
152 _eglPointerToUInt(const void *p)
153 {
154 return (unsigned int) ((uintptr_t) p);
155 }
156
157
158 #endif /* EGLDISPLAY_INCLUDED */