1 /**************************************************************************
3 * Copyright 2008 VMware, Inc.
4 * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
5 * Copyright 2010 LunarG, Inc.
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
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
34 #include "c99_compat.h"
36 #include "egltypedefs.h"
37 #include "egldisplay.h"
45 * "Base" class for device driver surfaces.
49 /* A surface is a display resource */
50 _EGLResource Resource
;
52 /* The context that is currently bound to the surface */
53 _EGLContext
*CurrentContext
;
57 EGLint Type
; /* one of EGL_WINDOW_BIT, EGL_PIXMAP_BIT or EGL_PBUFFER_BIT */
59 /* attributes set by attribute list */
61 EGLenum TextureFormat
;
62 EGLenum TextureTarget
;
63 EGLBoolean MipmapTexture
;
64 EGLBoolean LargestPbuffer
;
66 EGLenum VGAlphaFormat
;
69 /* attributes set by eglSurfaceAttrib */
71 EGLenum MultisampleResolve
;
74 EGLint HorizontalResolution
, VerticalResolution
;
79 /* True if the surface is bound to an OpenGL ES texture */
80 EGLBoolean BoundToTexture
;
82 EGLBoolean PostSubBufferSupportedNV
;
87 _eglInitSurface(_EGLSurface
*surf
, _EGLDisplay
*dpy
, EGLint type
,
88 _EGLConfig
*config
, const EGLint
*attrib_list
);
92 _eglQuerySurface(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*surf
, EGLint attribute
, EGLint
*value
);
96 _eglSurfaceAttrib(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*surf
, EGLint attribute
, EGLint value
);
100 _eglBindTexImage(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*surf
, EGLint buffer
);
103 _eglReleaseTexImage(_EGLDriver
*drv
, _EGLDisplay
*disp
, _EGLSurface
*surf
, EGLint buffer
);
107 _eglSwapInterval(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*surf
, EGLint interval
);
111 * Increment reference count for the surface.
113 static inline _EGLSurface
*
114 _eglGetSurface(_EGLSurface
*surf
)
117 _eglGetResource(&surf
->Resource
);
123 * Decrement reference count for the surface.
125 static inline EGLBoolean
126 _eglPutSurface(_EGLSurface
*surf
)
128 return (surf
) ? _eglPutResource(&surf
->Resource
) : EGL_FALSE
;
133 * Link a surface to its display and return the handle of the link.
134 * The handle can be passed to client directly.
136 static inline EGLSurface
137 _eglLinkSurface(_EGLSurface
*surf
)
139 _eglLinkResource(&surf
->Resource
, _EGL_RESOURCE_SURFACE
);
140 return (EGLSurface
) surf
;
145 * Unlink a linked surface from its display.
146 * Accessing an unlinked surface should generate EGL_BAD_SURFACE error.
149 _eglUnlinkSurface(_EGLSurface
*surf
)
151 _eglUnlinkResource(&surf
->Resource
, _EGL_RESOURCE_SURFACE
);
156 * Lookup a handle to find the linked surface.
157 * Return NULL if the handle has no corresponding linked surface.
159 static inline _EGLSurface
*
160 _eglLookupSurface(EGLSurface surface
, _EGLDisplay
*dpy
)
162 _EGLSurface
*surf
= (_EGLSurface
*) surface
;
163 if (!dpy
|| !_eglCheckResource((void *) surf
, _EGL_RESOURCE_SURFACE
, dpy
))
170 * Return the handle of a linked surface, or EGL_NO_SURFACE.
172 static inline EGLSurface
173 _eglGetSurfaceHandle(_EGLSurface
*surf
)
175 _EGLResource
*res
= (_EGLResource
*) surf
;
176 return (res
&& _eglIsResourceLinked(res
)) ?
177 (EGLSurface
) surf
: EGL_NO_SURFACE
;
185 #endif /* EGLSURFACE_INCLUDED */