egl/main: no longer export internal function
[mesa.git] / src / egl / main / eglsurface.h
1 /**************************************************************************
2 *
3 * Copyright 2008 VMware, Inc.
4 * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
5 * Copyright 2010 LunarG, Inc.
6 * All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sub license, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
15 *
16 * The above copyright notice and this permission notice (including the
17 * next paragraph) shall be included in all copies or substantial portions
18 * of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
27 *
28 **************************************************************************/
29
30
31 #ifndef EGLSURFACE_INCLUDED
32 #define EGLSURFACE_INCLUDED
33
34 #include "c99_compat.h"
35
36 #include "egltypedefs.h"
37 #include "egldisplay.h"
38
39
40 /**
41 * "Base" class for device driver surfaces.
42 */
43 struct _egl_surface
44 {
45 /* A surface is a display resource */
46 _EGLResource Resource;
47
48 /* The context that is currently bound to the surface */
49 _EGLContext *CurrentContext;
50
51 _EGLConfig *Config;
52
53 EGLint Type; /* one of EGL_WINDOW_BIT, EGL_PIXMAP_BIT or EGL_PBUFFER_BIT */
54
55 /* attributes set by attribute list */
56 EGLint Width, Height;
57 EGLenum TextureFormat;
58 EGLenum TextureTarget;
59 EGLBoolean MipmapTexture;
60 EGLBoolean LargestPbuffer;
61 EGLenum RenderBuffer;
62 EGLenum VGAlphaFormat;
63 EGLenum VGColorspace;
64
65 /* attributes set by eglSurfaceAttrib */
66 EGLint MipmapLevel;
67 EGLenum MultisampleResolve;
68 EGLenum SwapBehavior;
69
70 EGLint HorizontalResolution, VerticalResolution;
71 EGLint AspectRatio;
72
73 EGLint SwapInterval;
74
75 /* True if the surface is bound to an OpenGL ES texture */
76 EGLBoolean BoundToTexture;
77
78 EGLBoolean PostSubBufferSupportedNV;
79 };
80
81
82 extern EGLBoolean
83 _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
84 _EGLConfig *config, const EGLint *attrib_list);
85
86
87 extern EGLBoolean
88 _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint attribute, EGLint *value);
89
90
91 extern EGLBoolean
92 _eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint attribute, EGLint value);
93
94
95 extern EGLBoolean
96 _eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint buffer);
97
98 extern EGLBoolean
99 _eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint buffer);
100
101
102 extern EGLBoolean
103 _eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval);
104
105
106 /**
107 * Increment reference count for the surface.
108 */
109 static inline _EGLSurface *
110 _eglGetSurface(_EGLSurface *surf)
111 {
112 if (surf)
113 _eglGetResource(&surf->Resource);
114 return surf;
115 }
116
117
118 /**
119 * Decrement reference count for the surface.
120 */
121 static inline EGLBoolean
122 _eglPutSurface(_EGLSurface *surf)
123 {
124 return (surf) ? _eglPutResource(&surf->Resource) : EGL_FALSE;
125 }
126
127
128 /**
129 * Link a surface to its display and return the handle of the link.
130 * The handle can be passed to client directly.
131 */
132 static inline EGLSurface
133 _eglLinkSurface(_EGLSurface *surf)
134 {
135 _eglLinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE);
136 return (EGLSurface) surf;
137 }
138
139
140 /**
141 * Unlink a linked surface from its display.
142 * Accessing an unlinked surface should generate EGL_BAD_SURFACE error.
143 */
144 static inline void
145 _eglUnlinkSurface(_EGLSurface *surf)
146 {
147 _eglUnlinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE);
148 }
149
150
151 /**
152 * Lookup a handle to find the linked surface.
153 * Return NULL if the handle has no corresponding linked surface.
154 */
155 static inline _EGLSurface *
156 _eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy)
157 {
158 _EGLSurface *surf = (_EGLSurface *) surface;
159 if (!dpy || !_eglCheckResource((void *) surf, _EGL_RESOURCE_SURFACE, dpy))
160 surf = NULL;
161 return surf;
162 }
163
164
165 /**
166 * Return the handle of a linked surface, or EGL_NO_SURFACE.
167 */
168 static inline EGLSurface
169 _eglGetSurfaceHandle(_EGLSurface *surf)
170 {
171 _EGLResource *res = (_EGLResource *) surf;
172 return (res && _eglIsResourceLinked(res)) ?
173 (EGLSurface) surf : EGL_NO_SURFACE;
174 }
175
176
177 #endif /* EGLSURFACE_INCLUDED */