1 #ifndef EGLSURFACE_INCLUDED
2 #define EGLSURFACE_INCLUDED
5 #include "egltypedefs.h"
6 #include "egldisplay.h"
10 * "Base" class for device driver surfaces.
14 /* A surface is a display resource */
15 _EGLResource Resource
;
17 /* The context that is currently bound to the surface */
18 _EGLContext
*CurrentContext
;
22 EGLint Type
; /* one of EGL_WINDOW_BIT, EGL_PIXMAP_BIT or EGL_PBUFFER_BIT */
24 /* attributes set by attribute list */
26 EGLenum TextureFormat
;
27 EGLenum TextureTarget
;
28 EGLBoolean MipmapTexture
;
29 EGLBoolean LargestPbuffer
;
31 EGLenum VGAlphaFormat
;
34 /* attributes set by eglSurfaceAttrib */
36 EGLenum MultisampleResolve
;
39 EGLint HorizontalResolution
, VerticalResolution
;
44 /* True if the surface is bound to an OpenGL ES texture */
45 EGLBoolean BoundToTexture
;
50 _eglInitSurface(_EGLSurface
*surf
, _EGLDisplay
*dpy
, EGLint type
,
51 _EGLConfig
*config
, const EGLint
*attrib_list
);
55 _eglSwapBuffers(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*surf
);
59 _eglCopyBuffers(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*surf
, EGLNativePixmapType target
);
63 _eglQuerySurface(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*surf
, EGLint attribute
, EGLint
*value
);
67 _eglCreateWindowSurface(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLConfig
*conf
, EGLNativeWindowType window
, const EGLint
*attrib_list
);
71 _eglCreatePixmapSurface(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLConfig
*conf
, EGLNativePixmapType pixmap
, const EGLint
*attrib_list
);
75 _eglCreatePbufferSurface(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLConfig
*conf
, const EGLint
*attrib_list
);
79 _eglDestroySurface(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*surf
);
83 _eglSurfaceAttrib(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*surf
, EGLint attribute
, EGLint value
);
86 PUBLIC
extern EGLBoolean
87 _eglBindTexImage(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*surf
, EGLint buffer
);
91 _eglReleaseTexImage(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*surf
, EGLint buffer
);
95 _eglSwapInterval(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*surf
, EGLint interval
);
98 #ifdef EGL_VERSION_1_2
101 _eglCreatePbufferFromClientBuffer(_EGLDriver
*drv
, _EGLDisplay
*dpy
,
102 EGLenum buftype
, EGLClientBuffer buffer
,
103 _EGLConfig
*conf
, const EGLint
*attrib_list
);
105 #endif /* EGL_VERSION_1_2 */
109 * Return true if there is a context bound to the surface.
111 * The binding is considered a reference to the surface. Drivers should not
112 * destroy a surface when it is bound.
114 static INLINE EGLBoolean
115 _eglIsSurfaceBound(_EGLSurface
*surf
)
117 return (surf
->CurrentContext
!= NULL
);
122 * Link a surface to a display and return the handle of the link.
123 * The handle can be passed to client directly.
125 static INLINE EGLSurface
126 _eglLinkSurface(_EGLSurface
*surf
, _EGLDisplay
*dpy
)
128 _eglLinkResource(&surf
->Resource
, _EGL_RESOURCE_SURFACE
, dpy
);
129 return (EGLSurface
) surf
;
134 * Unlink a linked surface from its display.
135 * Accessing an unlinked surface should generate EGL_BAD_SURFACE error.
138 _eglUnlinkSurface(_EGLSurface
*surf
)
140 _eglUnlinkResource(&surf
->Resource
, _EGL_RESOURCE_SURFACE
);
145 * Lookup a handle to find the linked surface.
146 * Return NULL if the handle has no corresponding linked surface.
148 static INLINE _EGLSurface
*
149 _eglLookupSurface(EGLSurface surface
, _EGLDisplay
*dpy
)
151 _EGLSurface
*surf
= (_EGLSurface
*) surface
;
152 if (!dpy
|| !_eglCheckResource((void *) surf
, _EGL_RESOURCE_SURFACE
, dpy
))
159 * Return the handle of a linked surface, or EGL_NO_SURFACE.
161 static INLINE EGLSurface
162 _eglGetSurfaceHandle(_EGLSurface
*surf
)
164 _EGLResource
*res
= (_EGLResource
*) surf
;
165 return (res
&& _eglIsResourceLinked(res
)) ?
166 (EGLSurface
) surf
: EGL_NO_SURFACE
;
171 * Return true if the surface is linked to a display.
173 * The link is considered a reference to the surface (the display is owning the
174 * surface). Drivers should not destroy a surface when it is linked.
176 static INLINE EGLBoolean
177 _eglIsSurfaceLinked(_EGLSurface
*surf
)
179 _EGLResource
*res
= (_EGLResource
*) surf
;
180 return (res
&& _eglIsResourceLinked(res
));
184 #endif /* EGLSURFACE_INCLUDED */