Merge branch 'master' into pipe-video
[mesa.git] / src / egl / main / eglimage.c
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 */
15 EGLint
16 _eglParseImageAttribList(_EGLImageAttribs *attrs, _EGLDisplay *dpy,
17 const EGLint *attrib_list)
18 {
19 EGLint i, err = EGL_SUCCESS;
20
21 (void) dpy;
22
23 memset(attrs, 0, sizeof(attrs));
24 attrs->ImagePreserved = EGL_FALSE;
25 attrs->GLTextureLevel = 0;
26 attrs->GLTextureZOffset = 0;
27
28 if (!attrib_list)
29 return err;
30
31 for (i = 0; attrib_list[i] != EGL_NONE; i++) {
32 EGLint attr = attrib_list[i++];
33 EGLint val = attrib_list[i];
34
35 switch (attr) {
36 /* EGL_KHR_image_base */
37 case EGL_IMAGE_PRESERVED_KHR:
38 attrs->ImagePreserved = val;
39 break;
40
41 /* EGL_KHR_gl_image */
42 case EGL_GL_TEXTURE_LEVEL_KHR:
43 attrs->GLTextureLevel = val;
44 break;
45 case EGL_GL_TEXTURE_ZOFFSET_KHR:
46 attrs->GLTextureZOffset = val;
47 break;
48
49 /* EGL_MESA_drm_image */
50 case EGL_WIDTH:
51 attrs->Width = val;
52 break;
53 case EGL_HEIGHT:
54 attrs->Height = val;
55 break;
56 case EGL_DRM_BUFFER_FORMAT_MESA:
57 attrs->DRMBufferFormatMESA = val;
58 break;
59 case EGL_DRM_BUFFER_USE_MESA:
60 attrs->DRMBufferUseMESA = val;
61 break;
62 case EGL_DRM_BUFFER_STRIDE_MESA:
63 attrs->DRMBufferStrideMESA = val;
64 break;
65
66 default:
67 /* unknown attrs are ignored */
68 break;
69 }
70
71 if (err != EGL_SUCCESS) {
72 _eglLog(_EGL_DEBUG, "bad image attribute 0x%04x", attr);
73 break;
74 }
75 }
76
77 return err;
78 }
79
80
81 EGLBoolean
82 _eglInitImage(_EGLImage *img, _EGLDisplay *dpy)
83 {
84 _eglInitResource(&img->Resource, sizeof(*img), dpy);
85
86 return EGL_TRUE;
87 }
88
89
90 #endif /* EGL_KHR_image_base */