st/xa: Fix crosscompile builds with nonstandard ld locations
[mesa.git] / src / egl / main / eglsurface.h
1 #ifndef EGLSURFACE_INCLUDED
2 #define EGLSURFACE_INCLUDED
3
4
5 #include "egltypedefs.h"
6 #include "egldisplay.h"
7
8
9 /**
10 * "Base" class for device driver surfaces.
11 */
12 struct _egl_surface
13 {
14 /* A surface is a display resource */
15 _EGLResource Resource;
16
17 /* The context that is currently bound to the surface */
18 _EGLContext *CurrentContext;
19
20 _EGLConfig *Config;
21
22 EGLint Type; /* one of EGL_WINDOW_BIT, EGL_PIXMAP_BIT or EGL_PBUFFER_BIT */
23
24 /* attributes set by attribute list */
25 EGLint Width, Height;
26 EGLenum TextureFormat;
27 EGLenum TextureTarget;
28 EGLBoolean MipmapTexture;
29 EGLBoolean LargestPbuffer;
30 EGLenum RenderBuffer;
31 EGLenum VGAlphaFormat;
32 EGLenum VGColorspace;
33
34 /* attributes set by eglSurfaceAttrib */
35 EGLint MipmapLevel;
36 EGLenum MultisampleResolve;
37 EGLenum SwapBehavior;
38
39 EGLint HorizontalResolution, VerticalResolution;
40 EGLint AspectRatio;
41
42 EGLint SwapInterval;
43
44 /* True if the surface is bound to an OpenGL ES texture */
45 EGLBoolean BoundToTexture;
46 };
47
48
49 PUBLIC EGLBoolean
50 _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
51 _EGLConfig *config, const EGLint *attrib_list);
52
53
54 extern EGLBoolean
55 _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint attribute, EGLint *value);
56
57
58 extern EGLBoolean
59 _eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint attribute, EGLint value);
60
61
62 PUBLIC extern EGLBoolean
63 _eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint buffer);
64
65
66 extern EGLBoolean
67 _eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval);
68
69
70 /**
71 * Increment reference count for the surface.
72 */
73 static INLINE _EGLSurface *
74 _eglGetSurface(_EGLSurface *surf)
75 {
76 if (surf)
77 _eglGetResource(&surf->Resource);
78 return surf;
79 }
80
81
82 /**
83 * Decrement reference count for the surface.
84 */
85 static INLINE EGLBoolean
86 _eglPutSurface(_EGLSurface *surf)
87 {
88 return (surf) ? _eglPutResource(&surf->Resource) : EGL_FALSE;
89 }
90
91
92 /**
93 * Link a surface to its display and return the handle of the link.
94 * The handle can be passed to client directly.
95 */
96 static INLINE EGLSurface
97 _eglLinkSurface(_EGLSurface *surf)
98 {
99 _eglLinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE);
100 return (EGLSurface) surf;
101 }
102
103
104 /**
105 * Unlink a linked surface from its display.
106 * Accessing an unlinked surface should generate EGL_BAD_SURFACE error.
107 */
108 static INLINE void
109 _eglUnlinkSurface(_EGLSurface *surf)
110 {
111 _eglUnlinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE);
112 }
113
114
115 /**
116 * Lookup a handle to find the linked surface.
117 * Return NULL if the handle has no corresponding linked surface.
118 */
119 static INLINE _EGLSurface *
120 _eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy)
121 {
122 _EGLSurface *surf = (_EGLSurface *) surface;
123 if (!dpy || !_eglCheckResource((void *) surf, _EGL_RESOURCE_SURFACE, dpy))
124 surf = NULL;
125 return surf;
126 }
127
128
129 /**
130 * Return the handle of a linked surface, or EGL_NO_SURFACE.
131 */
132 static INLINE EGLSurface
133 _eglGetSurfaceHandle(_EGLSurface *surf)
134 {
135 _EGLResource *res = (_EGLResource *) surf;
136 return (res && _eglIsResourceLinked(res)) ?
137 (EGLSurface) surf : EGL_NO_SURFACE;
138 }
139
140
141 #endif /* EGLSURFACE_INCLUDED */