eglsurface.h revision cdc920a0
14a49301eSmrg#ifndef EGLSURFACE_INCLUDED
24a49301eSmrg#define EGLSURFACE_INCLUDED
34a49301eSmrg
44a49301eSmrg
54a49301eSmrg#include "egltypedefs.h"
6cdc920a0Smrg#include "egldisplay.h"
74a49301eSmrg
84a49301eSmrg
94a49301eSmrg/**
104a49301eSmrg * "Base" class for device driver surfaces.
114a49301eSmrg */
124a49301eSmrgstruct _egl_surface
134a49301eSmrg{
14cdc920a0Smrg   /* A surface is a display resource */
15cdc920a0Smrg   _EGLResource Resource;
164a49301eSmrg
17cdc920a0Smrg   /* The context that is currently bound to the surface */
18cdc920a0Smrg   _EGLContext *CurrentContext;
194a49301eSmrg
204a49301eSmrg   _EGLConfig *Config;
214a49301eSmrg
224a49301eSmrg   EGLint Type; /* one of EGL_WINDOW_BIT, EGL_PIXMAP_BIT or EGL_PBUFFER_BIT */
234a49301eSmrg
24cdc920a0Smrg   /* attributes set by attribute list */
25cdc920a0Smrg   EGLint Width, Height;
26cdc920a0Smrg   EGLenum TextureFormat;
27cdc920a0Smrg   EGLenum TextureTarget;
28cdc920a0Smrg   EGLBoolean MipmapTexture;
29cdc920a0Smrg   EGLBoolean LargestPbuffer;
30cdc920a0Smrg   EGLenum RenderBuffer;
31cdc920a0Smrg   EGLenum VGAlphaFormat;
32cdc920a0Smrg   EGLenum VGColorspace;
33cdc920a0Smrg
34cdc920a0Smrg   /* attributes set by eglSurfaceAttrib */
35cdc920a0Smrg   EGLint MipmapLevel;
36cdc920a0Smrg   EGLenum MultisampleResolve;
37cdc920a0Smrg   EGLenum SwapBehavior;
384a49301eSmrg
394a49301eSmrg   EGLint HorizontalResolution, VerticalResolution;
404a49301eSmrg   EGLint AspectRatio;
41cdc920a0Smrg
42cdc920a0Smrg   EGLint SwapInterval;
43cdc920a0Smrg
44cdc920a0Smrg   /* True if the surface is bound to an OpenGL ES texture */
45cdc920a0Smrg   EGLBoolean BoundToTexture;
464a49301eSmrg};
474a49301eSmrg
484a49301eSmrg
49cdc920a0SmrgPUBLIC EGLBoolean
50cdc920a0Smrg_eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
514a49301eSmrg                _EGLConfig *config, const EGLint *attrib_list);
524a49301eSmrg
534a49301eSmrg
544a49301eSmrgextern EGLBoolean
554a49301eSmrg_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf);
564a49301eSmrg
574a49301eSmrg
584a49301eSmrgextern EGLBoolean
59cdc920a0Smrg_eglCopyBuffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLNativePixmapType target);
604a49301eSmrg
614a49301eSmrg
624a49301eSmrgextern EGLBoolean
634a49301eSmrg_eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint attribute, EGLint *value);
644a49301eSmrg
654a49301eSmrg
664a49301eSmrgextern _EGLSurface *
67cdc920a0Smrg_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, EGLNativeWindowType window, const EGLint *attrib_list);
684a49301eSmrg
694a49301eSmrg
704a49301eSmrgextern _EGLSurface *
71cdc920a0Smrg_eglCreatePixmapSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, EGLNativePixmapType pixmap, const EGLint *attrib_list);
724a49301eSmrg
734a49301eSmrg
744a49301eSmrgextern _EGLSurface *
754a49301eSmrg_eglCreatePbufferSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, const EGLint *attrib_list);
764a49301eSmrg
774a49301eSmrg
784a49301eSmrgextern EGLBoolean
794a49301eSmrg_eglDestroySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf);
804a49301eSmrg
814a49301eSmrg
824a49301eSmrgextern EGLBoolean
834a49301eSmrg_eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint attribute, EGLint value);
844a49301eSmrg
854a49301eSmrg
864a49301eSmrgextern EGLBoolean
874a49301eSmrg_eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint buffer);
884a49301eSmrg
894a49301eSmrg
904a49301eSmrgextern EGLBoolean
914a49301eSmrg_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint buffer);
924a49301eSmrg
934a49301eSmrg
944a49301eSmrgextern EGLBoolean
954a49301eSmrg_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval);
964a49301eSmrg
974a49301eSmrg
984a49301eSmrg#ifdef EGL_VERSION_1_2
994a49301eSmrg
1004a49301eSmrgextern _EGLSurface *
1014a49301eSmrg_eglCreatePbufferFromClientBuffer(_EGLDriver *drv, _EGLDisplay *dpy,
1024a49301eSmrg                                  EGLenum buftype, EGLClientBuffer buffer,
1034a49301eSmrg                                  _EGLConfig *conf, const EGLint *attrib_list);
1044a49301eSmrg
1054a49301eSmrg#endif /* EGL_VERSION_1_2 */
1064a49301eSmrg
1074a49301eSmrg
1084a49301eSmrg/**
109cdc920a0Smrg * Return true if there is a context bound to the surface.
110cdc920a0Smrg *
111cdc920a0Smrg * The binding is considered a reference to the surface.  Drivers should not
112cdc920a0Smrg * destroy a surface when it is bound.
1134a49301eSmrg */
1144a49301eSmrgstatic INLINE EGLBoolean
1154a49301eSmrg_eglIsSurfaceBound(_EGLSurface *surf)
1164a49301eSmrg{
117cdc920a0Smrg   return (surf->CurrentContext != NULL);
118cdc920a0Smrg}
119cdc920a0Smrg
120cdc920a0Smrg
121cdc920a0Smrg/**
122cdc920a0Smrg * Link a surface to a display and return the handle of the link.
123cdc920a0Smrg * The handle can be passed to client directly.
124cdc920a0Smrg */
125cdc920a0Smrgstatic INLINE EGLSurface
126cdc920a0Smrg_eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy)
127cdc920a0Smrg{
128cdc920a0Smrg   _eglLinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE, dpy);
129cdc920a0Smrg   return (EGLSurface) surf;
130cdc920a0Smrg}
131cdc920a0Smrg
132cdc920a0Smrg
133cdc920a0Smrg/**
134cdc920a0Smrg * Unlink a linked surface from its display.
135cdc920a0Smrg * Accessing an unlinked surface should generate EGL_BAD_SURFACE error.
136cdc920a0Smrg */
137cdc920a0Smrgstatic INLINE void
138cdc920a0Smrg_eglUnlinkSurface(_EGLSurface *surf)
139cdc920a0Smrg{
140cdc920a0Smrg   _eglUnlinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE);
141cdc920a0Smrg}
142cdc920a0Smrg
143cdc920a0Smrg
144cdc920a0Smrg/**
145cdc920a0Smrg * Lookup a handle to find the linked surface.
146cdc920a0Smrg * Return NULL if the handle has no corresponding linked surface.
147cdc920a0Smrg */
148cdc920a0Smrgstatic INLINE _EGLSurface *
149cdc920a0Smrg_eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy)
150cdc920a0Smrg{
151cdc920a0Smrg   _EGLSurface *surf = (_EGLSurface *) surface;
152cdc920a0Smrg   if (!dpy || !_eglCheckResource((void *) surf, _EGL_RESOURCE_SURFACE, dpy))
153cdc920a0Smrg      surf = NULL;
154cdc920a0Smrg   return surf;
155cdc920a0Smrg}
156cdc920a0Smrg
157cdc920a0Smrg
158cdc920a0Smrg/**
159cdc920a0Smrg * Return the handle of a linked surface, or EGL_NO_SURFACE.
160cdc920a0Smrg */
161cdc920a0Smrgstatic INLINE EGLSurface
162cdc920a0Smrg_eglGetSurfaceHandle(_EGLSurface *surf)
163cdc920a0Smrg{
164cdc920a0Smrg   _EGLResource *res = (_EGLResource *) surf;
165cdc920a0Smrg   return (res && _eglIsResourceLinked(res)) ?
166cdc920a0Smrg      (EGLSurface) surf : EGL_NO_SURFACE;
167cdc920a0Smrg}
168cdc920a0Smrg
169cdc920a0Smrg
170cdc920a0Smrg/**
171cdc920a0Smrg * Return true if the surface is linked to a display.
172cdc920a0Smrg *
173cdc920a0Smrg * The link is considered a reference to the surface (the display is owning the
174cdc920a0Smrg * surface).  Drivers should not destroy a surface when it is linked.
175cdc920a0Smrg */
176cdc920a0Smrgstatic INLINE EGLBoolean
177cdc920a0Smrg_eglIsSurfaceLinked(_EGLSurface *surf)
178cdc920a0Smrg{
179cdc920a0Smrg   _EGLResource *res = (_EGLResource *) surf;
180cdc920a0Smrg   return (res && _eglIsResourceLinked(res));
1814a49301eSmrg}
1824a49301eSmrg
1834a49301eSmrg
1844a49301eSmrg#endif /* EGLSURFACE_INCLUDED */
185