eglimage.h revision cdc920a0
1#ifndef EGLIMAGE_INCLUDED
2#define EGLIMAGE_INCLUDED
3
4
5#include "egltypedefs.h"
6#include "egldisplay.h"
7
8
9/**
10 * "Base" class for device driver images.
11 */
12struct _egl_image
13{
14   /* An image is a display resource */
15   _EGLResource Resource;
16
17   EGLBoolean Preserved;
18   EGLint GLTextureLevel;
19   EGLint GLTextureZOffset;
20};
21
22
23PUBLIC EGLBoolean
24_eglInitImage(_EGLImage *img, _EGLDisplay *dpy, const EGLint *attrib_list);
25
26
27extern _EGLImage *
28_eglCreateImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
29                   EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list);
30
31
32extern EGLBoolean
33_eglDestroyImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image);
34
35
36/**
37 * Link an image to a display and return the handle of the link.
38 * The handle can be passed to client directly.
39 */
40static INLINE EGLImageKHR
41_eglLinkImage(_EGLImage *img, _EGLDisplay *dpy)
42{
43   _eglLinkResource(&img->Resource, _EGL_RESOURCE_IMAGE, dpy);
44   return (EGLImageKHR) img;
45}
46
47
48/**
49 * Unlink a linked image from its display.
50 * Accessing an unlinked image should generate EGL_BAD_PARAMETER error.
51 */
52static INLINE void
53_eglUnlinkImage(_EGLImage *img)
54{
55   _eglUnlinkResource(&img->Resource, _EGL_RESOURCE_IMAGE);
56}
57
58
59/**
60 * Lookup a handle to find the linked image.
61 * Return NULL if the handle has no corresponding linked image.
62 */
63static INLINE _EGLImage *
64_eglLookupImage(EGLImageKHR image, _EGLDisplay *dpy)
65{
66   _EGLImage *img = (_EGLImage *) image;
67   if (!dpy || !_eglCheckResource((void *) img, _EGL_RESOURCE_IMAGE, dpy))
68      img = NULL;
69   return img;
70}
71
72
73/**
74 * Return the handle of a linked image, or EGL_NO_IMAGE_KHR.
75 */
76static INLINE EGLImageKHR
77_eglGetImageHandle(_EGLImage *img)
78{
79   _EGLResource *res = (_EGLResource *) img;
80   return (res && _eglIsResourceLinked(res)) ?
81      (EGLImageKHR) img : EGL_NO_IMAGE_KHR;
82}
83
84
85/**
86 * Return true if the image is linked to a display.
87 */
88static INLINE EGLBoolean
89_eglIsImageLinked(_EGLImage *img)
90{
91   _EGLResource *res = (_EGLResource *) img;
92   return (res && _eglIsResourceLinked(res));
93}
94
95
96#endif /* EGLIMAGE_INCLUDED */
97