1 /**************************************************************************
3 * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
4 * Copyright 2010-2011 LunarG, Inc.
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
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 **************************************************************************/
37 #ifdef EGL_KHR_image_base
41 * Parse the list of image attributes and return the proper error code.
44 _eglParseImageAttribList(_EGLImageAttribs
*attrs
, _EGLDisplay
*dpy
,
45 const EGLint
*attrib_list
)
47 EGLint i
, err
= EGL_SUCCESS
;
51 memset(attrs
, 0, sizeof(*attrs
));
52 attrs
->ImagePreserved
= EGL_FALSE
;
53 attrs
->GLTextureLevel
= 0;
54 attrs
->GLTextureZOffset
= 0;
59 for (i
= 0; attrib_list
[i
] != EGL_NONE
; i
++) {
60 EGLint attr
= attrib_list
[i
++];
61 EGLint val
= attrib_list
[i
];
64 /* EGL_KHR_image_base */
65 case EGL_IMAGE_PRESERVED_KHR
:
66 attrs
->ImagePreserved
= val
;
69 /* EGL_KHR_gl_image */
70 case EGL_GL_TEXTURE_LEVEL_KHR
:
71 attrs
->GLTextureLevel
= val
;
73 case EGL_GL_TEXTURE_ZOFFSET_KHR
:
74 attrs
->GLTextureZOffset
= val
;
77 /* EGL_MESA_drm_image */
84 case EGL_DRM_BUFFER_FORMAT_MESA
:
85 attrs
->DRMBufferFormatMESA
= val
;
87 case EGL_DRM_BUFFER_USE_MESA
:
88 attrs
->DRMBufferUseMESA
= val
;
90 case EGL_DRM_BUFFER_STRIDE_MESA
:
91 attrs
->DRMBufferStrideMESA
= val
;
95 /* unknown attrs are ignored */
99 if (err
!= EGL_SUCCESS
) {
100 _eglLog(_EGL_DEBUG
, "bad image attribute 0x%04x", attr
);
110 _eglInitImage(_EGLImage
*img
, _EGLDisplay
*dpy
)
112 _eglInitResource(&img
->Resource
, sizeof(*img
), dpy
);
118 #endif /* EGL_KHR_image_base */