st/xa: Fix crosscompile builds with nonstandard ld locations
[mesa.git] / src / egl / main / eglimage.c
1 #include <assert.h>
2 #include <string.h>
3
4 #include "eglimage.h"
5 #include "egllog.h"
6
7
8 #ifdef EGL_KHR_image_base
9
10
11 /**
12 * Parse the list of image attributes and return the proper error code.
13 */
14 EGLint
15 _eglParseImageAttribList(_EGLImageAttribs *attrs, _EGLDisplay *dpy,
16 const EGLint *attrib_list)
17 {
18 EGLint i, err = EGL_SUCCESS;
19
20 (void) dpy;
21
22 memset(attrs, 0, sizeof(attrs));
23 attrs->ImagePreserved = EGL_FALSE;
24 attrs->GLTextureLevel = 0;
25 attrs->GLTextureZOffset = 0;
26
27 if (!attrib_list)
28 return err;
29
30 for (i = 0; attrib_list[i] != EGL_NONE; i++) {
31 EGLint attr = attrib_list[i++];
32 EGLint val = attrib_list[i];
33
34 switch (attr) {
35 /* EGL_KHR_image_base */
36 case EGL_IMAGE_PRESERVED_KHR:
37 attrs->ImagePreserved = val;
38 break;
39
40 /* EGL_KHR_gl_image */
41 case EGL_GL_TEXTURE_LEVEL_KHR:
42 attrs->GLTextureLevel = val;
43 break;
44 case EGL_GL_TEXTURE_ZOFFSET_KHR:
45 attrs->GLTextureZOffset = val;
46 break;
47
48 /* EGL_MESA_drm_image */
49 case EGL_WIDTH:
50 attrs->Width = val;
51 break;
52 case EGL_HEIGHT:
53 attrs->Height = val;
54 break;
55 case EGL_DRM_BUFFER_FORMAT_MESA:
56 attrs->DRMBufferFormatMESA = val;
57 break;
58 case EGL_DRM_BUFFER_USE_MESA:
59 attrs->DRMBufferUseMESA = val;
60 break;
61 case EGL_DRM_BUFFER_STRIDE_MESA:
62 attrs->DRMBufferStrideMESA = val;
63 break;
64
65 default:
66 /* unknown attrs are ignored */
67 break;
68 }
69
70 if (err != EGL_SUCCESS) {
71 _eglLog(_EGL_DEBUG, "bad image attribute 0x%04x", attr);
72 break;
73 }
74 }
75
76 return err;
77 }
78
79
80 EGLBoolean
81 _eglInitImage(_EGLImage *img, _EGLDisplay *dpy)
82 {
83 _eglInitResource(&img->Resource, sizeof(*img), dpy);
84
85 return EGL_TRUE;
86 }
87
88
89 #endif /* EGL_KHR_image_base */