eglimage.c revision 25328509c90dc205b9561b5265e478af2873438b
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 */ 15EGLint 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 81EGLBoolean 82_eglInitImage(_EGLImage *img, _EGLDisplay *dpy) 83{ 84 memset(img, 0, sizeof(_EGLImage)); 85 img->Resource.Display = dpy; 86 87 return EGL_TRUE; 88} 89 90 91#endif /* EGL_KHR_image_base */ 92