Merge branch 'mesa_7_5_branch'
[mesa.git] / src / egl / main / egldisplay.h
1 #ifndef EGLDISPLAY_INCLUDED
2 #define EGLDISPLAY_INCLUDED
3
4 #ifdef _EGL_PLATFORM_X
5 #include <X11/Xlib.h>
6 #endif
7
8 #include "egltypedefs.h"
9 #include "eglhash.h"
10
11
12 struct _egl_display
13 {
14 EGLNativeDisplayType NativeDisplay;
15 EGLDisplay Handle;
16
17 const char *DriverName;
18 const char *DriverArgs;
19 _EGLDriver *Driver;
20
21 EGLint NumScreens;
22 _EGLScreen **Screens; /* array [NumScreens] */
23
24 EGLint NumConfigs;
25 _EGLConfig **Configs; /* array [NumConfigs] of ptr to _EGLConfig */
26
27 /* lists of linked contexts and surface */
28 _EGLContext *ContextList;
29 _EGLSurface *SurfaceList;
30
31 /* hash table to map surfaces to handles */
32 _EGLHashtable *SurfaceHash;
33
34 #ifdef _EGL_PLATFORM_X
35 Display *Xdpy;
36 #endif
37 };
38
39
40 extern _EGLDisplay *
41 _eglNewDisplay(NativeDisplayType displayName);
42
43
44 extern EGLDisplay
45 _eglLinkDisplay(_EGLDisplay *dpy);
46
47
48 extern void
49 _eglUnlinkDisplay(_EGLDisplay *dpy);
50
51
52 extern EGLDisplay
53 _eglGetDisplayHandle(_EGLDisplay *display);
54
55
56 extern _EGLDisplay *
57 _eglLookupDisplay(EGLDisplay dpy);
58
59
60 /**
61 * Return true if the display is linked.
62 */
63 static INLINE EGLBoolean
64 _eglIsDisplayLinked(_EGLDisplay *dpy)
65 {
66 return (EGLBoolean) (_eglGetDisplayHandle(dpy) != EGL_NO_DISPLAY);
67 }
68
69
70 extern _EGLDisplay *
71 _eglFindDisplay(NativeDisplayType nativeDisplay);
72
73
74 extern void
75 _eglReleaseDisplayResources(_EGLDriver *drv, EGLDisplay dpy);
76
77
78 extern void
79 _eglCleanupDisplay(_EGLDisplay *disp);
80
81
82 extern EGLContext
83 _eglLinkContext(_EGLContext *ctx, _EGLDisplay *dpy);
84
85
86 extern void
87 _eglUnlinkContext(_EGLContext *ctx);
88
89
90 extern EGLContext
91 _eglGetContextHandle(_EGLContext *ctx);
92
93
94 extern _EGLContext *
95 _eglLookupContext(EGLContext ctx);
96
97
98 /**
99 * Return true if the context is linked to a display.
100 */
101 static INLINE EGLBoolean
102 _eglIsContextLinked(_EGLContext *ctx)
103 {
104 return (EGLBoolean) (_eglGetContextHandle(ctx) != EGL_NO_CONTEXT);
105 }
106
107 extern EGLSurface
108 _eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy);
109
110
111 extern void
112 _eglUnlinkSurface(_EGLSurface *surf);
113
114
115 extern EGLSurface
116 _eglGetSurfaceHandle(_EGLSurface *);
117
118
119 extern _EGLSurface *
120 _eglLookupSurface(EGLSurface surf);
121
122
123 /**
124 * Return true if the surface is linked to a display.
125 */
126 static INLINE EGLBoolean
127 _eglIsSurfaceLinked(_EGLSurface *surf)
128 {
129 return (EGLBoolean) (_eglGetSurfaceHandle(surf) != EGL_NO_SURFACE);
130 }
131
132
133 /**
134 * Cast an unsigned int to a pointer.
135 */
136 static INLINE void *
137 _eglUIntToPointer(unsigned int v)
138 {
139 return (void *) ((uintptr_t) v);
140 }
141
142
143 /**
144 * Cast a pointer to an unsigned int. The pointer must be one that is
145 * returned by _eglUIntToPointer.
146 */
147 static INLINE unsigned int
148 _eglPointerToUInt(const void *p)
149 {
150 return (unsigned int) ((uintptr_t) p);
151 }
152
153
154 #endif /* EGLDISPLAY_INCLUDED */