Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / mesa / src / egl / main / eglimage.c
blob72c05d9f806e28d8c459658b390269b037cf6789
1 /**************************************************************************
3 * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
4 * Copyright 2010-2011 LunarG, Inc.
5 * All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
17 * of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 * DEALINGS IN THE SOFTWARE.
27 **************************************************************************/
30 #include <assert.h>
31 #include <string.h>
33 #include "eglimage.h"
34 #include "egllog.h"
37 #ifdef EGL_KHR_image_base
40 /**
41 * Parse the list of image attributes and return the proper error code.
43 EGLint
44 _eglParseImageAttribList(_EGLImageAttribs *attrs, _EGLDisplay *dpy,
45 const EGLint *attrib_list)
47 EGLint i, err = EGL_SUCCESS;
49 (void) dpy;
51 memset(attrs, 0, sizeof(*attrs));
52 attrs->ImagePreserved = EGL_FALSE;
53 attrs->GLTextureLevel = 0;
54 attrs->GLTextureZOffset = 0;
56 if (!attrib_list)
57 return err;
59 for (i = 0; attrib_list[i] != EGL_NONE; i++) {
60 EGLint attr = attrib_list[i++];
61 EGLint val = attrib_list[i];
63 switch (attr) {
64 /* EGL_KHR_image_base */
65 case EGL_IMAGE_PRESERVED_KHR:
66 attrs->ImagePreserved = val;
67 break;
69 /* EGL_KHR_gl_image */
70 case EGL_GL_TEXTURE_LEVEL_KHR:
71 attrs->GLTextureLevel = val;
72 break;
73 case EGL_GL_TEXTURE_ZOFFSET_KHR:
74 attrs->GLTextureZOffset = val;
75 break;
77 /* EGL_MESA_drm_image */
78 case EGL_WIDTH:
79 attrs->Width = val;
80 break;
81 case EGL_HEIGHT:
82 attrs->Height = val;
83 break;
84 case EGL_DRM_BUFFER_FORMAT_MESA:
85 attrs->DRMBufferFormatMESA = val;
86 break;
87 case EGL_DRM_BUFFER_USE_MESA:
88 attrs->DRMBufferUseMESA = val;
89 break;
90 case EGL_DRM_BUFFER_STRIDE_MESA:
91 attrs->DRMBufferStrideMESA = val;
92 break;
94 default:
95 /* unknown attrs are ignored */
96 break;
99 if (err != EGL_SUCCESS) {
100 _eglLog(_EGL_DEBUG, "bad image attribute 0x%04x", attr);
101 break;
105 return err;
109 EGLBoolean
110 _eglInitImage(_EGLImage *img, _EGLDisplay *dpy)
112 _eglInitResource(&img->Resource, sizeof(*img), dpy);
114 return EGL_TRUE;
118 #endif /* EGL_KHR_image_base */