eglimage.c revision d69242be55091e53b0ae2cfa6282790ce1862f29
1#include <assert.h>
2#include <string.h>
3
4#include "eglimage.h"
5#include "eglcurrent.h"
6#include "egllog.h"
7
8
9#ifdef EGL_KHR_image_base
10
11
12/**
13 * Parse the list of image attributes and return the proper error code.
14 */
15static EGLint
16_eglParseImageAttribList(_EGLImage *img, const EGLint *attrib_list)
17{
18   EGLint i, err = EGL_SUCCESS;
19
20   if (!attrib_list)
21      return EGL_SUCCESS;
22
23   for (i = 0; attrib_list[i] != EGL_NONE; i++) {
24      EGLint attr = attrib_list[i++];
25      EGLint val = attrib_list[i];
26
27      switch (attr) {
28      case EGL_IMAGE_PRESERVED_KHR:
29         img->Preserved = val;
30         break;
31      default:
32         err = EGL_BAD_ATTRIBUTE;
33         break;
34      }
35
36      if (err != EGL_SUCCESS) {
37         _eglLog(_EGL_DEBUG, "bad image attribute 0x%04x", attr);
38         break;
39      }
40   }
41
42   return err;
43}
44
45
46EGLBoolean
47_eglInitImage(_EGLImage *img, _EGLDisplay *dpy, const EGLint *attrib_list)
48{
49   EGLint err;
50
51   memset(img, 0, sizeof(_EGLImage));
52   img->Resource.Display = dpy;
53
54   img->Preserved = EGL_FALSE;
55
56   err = _eglParseImageAttribList(img, attrib_list);
57   if (err != EGL_SUCCESS)
58      return _eglError(err, "eglCreateImageKHR");
59
60   return EGL_TRUE;
61}
62
63
64_EGLImage *
65_eglCreateImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
66                   EGLenum target, EGLClientBuffer buffer,
67                   const EGLint *attr_list)
68{
69   /* driver should override this function */
70   return NULL;
71}
72
73
74EGLBoolean
75_eglDestroyImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image)
76{
77   /* driver should override this function */
78   return EGL_FALSE;
79}
80
81
82#endif /* EGL_KHR_image_base */
83