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 **************************************************************************/
38 * Parse the list of image attributes and return the proper error code.
41 _eglParseImageAttribList(_EGLImageAttribs *attrs, _EGLDisplay *dpy,
42 const EGLint *attrib_list)
44 EGLint i, err = EGL_SUCCESS;
48 memset(attrs, 0, sizeof(*attrs));
49 attrs->ImagePreserved = EGL_FALSE;
50 attrs->GLTextureLevel = 0;
51 attrs->GLTextureZOffset = 0;
56 for (i = 0; attrib_list[i] != EGL_NONE; i++) {
57 EGLint attr = attrib_list[i++];
58 EGLint val = attrib_list[i];
61 /* EGL_KHR_image_base */
62 case EGL_IMAGE_PRESERVED_KHR:
63 attrs->ImagePreserved = val;
66 /* EGL_KHR_gl_image */
67 case EGL_GL_TEXTURE_LEVEL_KHR:
68 attrs->GLTextureLevel = val;
70 case EGL_GL_TEXTURE_ZOFFSET_KHR:
71 attrs->GLTextureZOffset = val;
74 /* EGL_MESA_drm_image */
81 case EGL_DRM_BUFFER_FORMAT_MESA:
82 attrs->DRMBufferFormatMESA = val;
84 case EGL_DRM_BUFFER_USE_MESA:
85 attrs->DRMBufferUseMESA = val;
87 case EGL_DRM_BUFFER_STRIDE_MESA:
88 attrs->DRMBufferStrideMESA = val;
92 /* unknown attrs are ignored */
96 if (err != EGL_SUCCESS) {
97 _eglLog(_EGL_DEBUG, "bad image attribute 0x%04x", attr);
107 _eglInitImage(_EGLImage *img, _EGLDisplay *dpy)
109 _eglInitResource(&img->Resource, sizeof(*img), dpy);