revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / mesa / src / egl / main / eglsurface.h
blob0541ff4e2f145dd1c7ec26c6d5c1e2beb465c157
1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
5 * Copyright 2010 LunarG, Inc.
6 * All Rights Reserved.
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:
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.
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.
28 **************************************************************************/
31 #ifndef EGLSURFACE_INCLUDED
32 #define EGLSURFACE_INCLUDED
35 #include "egltypedefs.h"
36 #include "egldisplay.h"
39 /**
40 * "Base" class for device driver surfaces.
42 struct _egl_surface
44 /* A surface is a display resource */
45 _EGLResource Resource;
47 /* The context that is currently bound to the surface */
48 _EGLContext *CurrentContext;
50 _EGLConfig *Config;
52 EGLint Type; /* one of EGL_WINDOW_BIT, EGL_PIXMAP_BIT or EGL_PBUFFER_BIT */
54 /* attributes set by attribute list */
55 EGLint Width, Height;
56 EGLenum TextureFormat;
57 EGLenum TextureTarget;
58 EGLBoolean MipmapTexture;
59 EGLBoolean LargestPbuffer;
60 EGLenum RenderBuffer;
61 EGLenum VGAlphaFormat;
62 EGLenum VGColorspace;
64 /* attributes set by eglSurfaceAttrib */
65 EGLint MipmapLevel;
66 EGLenum MultisampleResolve;
67 EGLenum SwapBehavior;
69 EGLint HorizontalResolution, VerticalResolution;
70 EGLint AspectRatio;
72 EGLint SwapInterval;
74 /* True if the surface is bound to an OpenGL ES texture */
75 EGLBoolean BoundToTexture;
79 PUBLIC EGLBoolean
80 _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
81 _EGLConfig *config, const EGLint *attrib_list);
84 extern EGLBoolean
85 _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint attribute, EGLint *value);
88 extern EGLBoolean
89 _eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint attribute, EGLint value);
92 PUBLIC extern EGLBoolean
93 _eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint buffer);
96 extern EGLBoolean
97 _eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval);
101 * Increment reference count for the surface.
103 static INLINE _EGLSurface *
104 _eglGetSurface(_EGLSurface *surf)
106 if (surf)
107 _eglGetResource(&surf->Resource);
108 return surf;
113 * Decrement reference count for the surface.
115 static INLINE EGLBoolean
116 _eglPutSurface(_EGLSurface *surf)
118 return (surf) ? _eglPutResource(&surf->Resource) : EGL_FALSE;
123 * Link a surface to its display and return the handle of the link.
124 * The handle can be passed to client directly.
126 static INLINE EGLSurface
127 _eglLinkSurface(_EGLSurface *surf)
129 _eglLinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE);
130 return (EGLSurface) surf;
135 * Unlink a linked surface from its display.
136 * Accessing an unlinked surface should generate EGL_BAD_SURFACE error.
138 static INLINE void
139 _eglUnlinkSurface(_EGLSurface *surf)
141 _eglUnlinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE);
146 * Lookup a handle to find the linked surface.
147 * Return NULL if the handle has no corresponding linked surface.
149 static INLINE _EGLSurface *
150 _eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy)
152 _EGLSurface *surf = (_EGLSurface *) surface;
153 if (!dpy || !_eglCheckResource((void *) surf, _EGL_RESOURCE_SURFACE, dpy))
154 surf = NULL;
155 return surf;
160 * Return the handle of a linked surface, or EGL_NO_SURFACE.
162 static INLINE EGLSurface
163 _eglGetSurfaceHandle(_EGLSurface *surf)
165 _EGLResource *res = (_EGLResource *) surf;
166 return (res && _eglIsResourceLinked(res)) ?
167 (EGLSurface) surf : EGL_NO_SURFACE;
171 #endif /* EGLSURFACE_INCLUDED */