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 _eglQuerySurface(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*surf
, EGLint attribute
, EGLint
*value
);
59 _eglSurfaceAttrib(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*surf
, EGLint attribute
, EGLint value
);
62 PUBLIC
extern EGLBoolean
63 _eglBindTexImage(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*surf
, EGLint buffer
);
67 _eglSwapInterval(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*surf
, EGLint interval
);
71 * Return true if there is a context bound to the surface.
73 * The binding is considered a reference to the surface. Drivers should not
74 * destroy a surface when it is bound.
76 static INLINE EGLBoolean
77 _eglIsSurfaceBound(_EGLSurface
*surf
)
79 return (surf
->CurrentContext
!= NULL
);
84 * Increment reference count for the surface.
86 static INLINE _EGLSurface
*
87 _eglGetSurface(_EGLSurface
*surf
)
90 _eglGetResource(&surf
->Resource
);
96 * Decrement reference count for the surface.
98 static INLINE EGLBoolean
99 _eglPutSurface(_EGLSurface
*surf
)
101 return (surf
) ? _eglPutResource(&surf
->Resource
) : EGL_FALSE
;
106 * Link a surface to its display and return the handle of the link.
107 * The handle can be passed to client directly.
109 static INLINE EGLSurface
110 _eglLinkSurface(_EGLSurface
*surf
)
112 _eglLinkResource(&surf
->Resource
, _EGL_RESOURCE_SURFACE
);
113 return (EGLSurface
) surf
;
118 * Unlink a linked surface from its display.
119 * Accessing an unlinked surface should generate EGL_BAD_SURFACE error.
122 _eglUnlinkSurface(_EGLSurface
*surf
)
124 _eglUnlinkResource(&surf
->Resource
, _EGL_RESOURCE_SURFACE
);
129 * Lookup a handle to find the linked surface.
130 * Return NULL if the handle has no corresponding linked surface.
132 static INLINE _EGLSurface
*
133 _eglLookupSurface(EGLSurface surface
, _EGLDisplay
*dpy
)
135 _EGLSurface
*surf
= (_EGLSurface
*) surface
;
136 if (!dpy
|| !_eglCheckResource((void *) surf
, _EGL_RESOURCE_SURFACE
, dpy
))
143 * Return the handle of a linked surface, or EGL_NO_SURFACE.
145 static INLINE EGLSurface
146 _eglGetSurfaceHandle(_EGLSurface
*surf
)
148 _EGLResource
*res
= (_EGLResource
*) surf
;
149 return (res
&& _eglIsResourceLinked(res
)) ?
150 (EGLSurface
) surf
: EGL_NO_SURFACE
;
155 * Return true if the surface is linked to a display.
157 * The link is considered a reference to the surface (the display is owning the
158 * surface). Drivers should not destroy a surface when it is linked.
160 static INLINE EGLBoolean
161 _eglIsSurfaceLinked(_EGLSurface
*surf
)
163 _EGLResource
*res
= (_EGLResource
*) surf
;
164 return (res
&& _eglIsResourceLinked(res
));
168 #endif /* EGLSURFACE_INCLUDED */