EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) { CLIENT_THREAD_STATE_T *thread; CLIENT_PROCESS_STATE_T *process; EGLBoolean result; if (CLIENT_LOCK_AND_GET_STATES(dpy, &thread, &process)) { if (!num_config) { thread->error = EGL_BAD_PARAMETER; result = EGL_FALSE; } else if (!configs) { thread->error = EGL_SUCCESS; *num_config = EGL_MAX_CONFIGS; result = EGL_TRUE; } else { int i; for (i = 0; i < EGL_MAX_CONFIGS && i < config_size; i++) configs[i] = egl_config_from_id(i); thread->error = EGL_SUCCESS; *num_config = i; result = EGL_TRUE; } CLIENT_UNLOCK(); } else result = EGL_FALSE; return result; }
EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig_inner(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config, bool sane) { CLIENT_THREAD_STATE_T *thread; CLIENT_PROCESS_STATE_T *process; EGLBoolean result; if (CLIENT_LOCK_AND_GET_STATES(dpy, &thread, &process)) { if (!num_config) { thread->error = EGL_BAD_PARAMETER; result = EGL_FALSE; } else { /* check for invalid attributes, and find color components for which we have expressed a preference */ bool use_red = false; bool use_green = false; bool use_blue = false; bool use_alpha = false; if (!egl_config_check_attribs(attrib_list, &use_red, &use_green, &use_blue, &use_alpha)) { thread->error = EGL_BAD_ATTRIBUTE; result = EGL_FALSE; } else { /* sort configs */ int ids[EGL_MAX_CONFIGS]; int i, j; for (i = 0; i < EGL_MAX_CONFIGS; i++) ids[i] = i; // egl_config_sort(ids, use_red, use_green, use_blue, use_alpha); egl_config_sort(ids, !sane && use_red, !sane && use_green, !sane && use_blue, !sane && use_alpha); /* return configs */ j = 0; for (i = 0; i < EGL_MAX_CONFIGS; i++) { if (egl_config_filter(ids[i], attrib_list)) { if (configs && j < config_size) { configs[j] = egl_config_from_id(ids[i]); j++; } else if (!configs) { // If configs==NULL then we count all configs // Otherwise we only count the configs we return j++; } } } thread->error = EGL_SUCCESS; *num_config = j; result = EGL_TRUE; } } CLIENT_UNLOCK(); } else result = EGL_FALSE; return result; }
bool egl_config_get_attrib(int id, EGLint attrib, EGLint *value) { FEATURES_T features = formats[id].features; switch (attrib) { case EGL_BUFFER_SIZE: *value = FEATURES_UNPACK_COLOR(features); return true; case EGL_RED_SIZE: *value = FEATURES_UNPACK_RED(features); return true; case EGL_GREEN_SIZE: *value = FEATURES_UNPACK_GREEN(features); return true; case EGL_BLUE_SIZE: *value = FEATURES_UNPACK_BLUE(features); return true; case EGL_LUMINANCE_SIZE: *value = 0; return true; case EGL_ALPHA_SIZE: *value = FEATURES_UNPACK_ALPHA(features); return true; case EGL_ALPHA_MASK_SIZE: *value = FEATURES_UNPACK_MASK(features); return true; case EGL_BIND_TO_TEXTURE_RGB: *value = bindable_rgb(features); return true; case EGL_BIND_TO_TEXTURE_RGBA: *value = bindable_rgba(features); return true; case EGL_COLOR_BUFFER_TYPE: *value = EGL_RGB_BUFFER; return true; case EGL_CONFIG_CAVEAT: *value = EGL_NONE; return true; case EGL_CONFIG_ID: *value = (EGLint)(uintptr_t)egl_config_from_id(id); return true; case EGL_CONFORMANT: *value = egl_config_get_api_conformance(id); return true; case EGL_DEPTH_SIZE: *value = FEATURES_UNPACK_DEPTH(features); return true; case EGL_LEVEL: *value = 0; return true; case EGL_MATCH_NATIVE_PIXMAP: *value = 0; return true; case EGL_MAX_PBUFFER_WIDTH: *value = EGL_CONFIG_MAX_WIDTH; return true; case EGL_MAX_PBUFFER_HEIGHT: *value = EGL_CONFIG_MAX_HEIGHT; return true; case EGL_MAX_PBUFFER_PIXELS: *value = EGL_CONFIG_MAX_WIDTH * EGL_CONFIG_MAX_HEIGHT; return true; case EGL_MAX_SWAP_INTERVAL: *value = EGL_CONFIG_MAX_SWAP_INTERVAL; return true; case EGL_MIN_SWAP_INTERVAL: *value = EGL_CONFIG_MIN_SWAP_INTERVAL; return true; case EGL_NATIVE_RENDERABLE: *value = EGL_TRUE; return true; case EGL_NATIVE_VISUAL_ID: *value = platform_get_color_format(egl_config_get_color_format(id)); return true; case EGL_NATIVE_VISUAL_TYPE: *value = EGL_NONE; return true; case EGL_RENDERABLE_TYPE: *value = egl_config_get_api_support(id); return true; case EGL_SAMPLE_BUFFERS: *value = FEATURES_UNPACK_MULTI(features); return true; case EGL_SAMPLES: *value = FEATURES_UNPACK_MULTI(features) * 4; return true; case EGL_STENCIL_SIZE: *value = FEATURES_UNPACK_STENCIL(features); return true; case EGL_SURFACE_TYPE: *value = (EGLint)(EGL_PBUFFER_BIT | EGL_PIXMAP_BIT | EGL_WINDOW_BIT | EGL_VG_COLORSPACE_LINEAR_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT | EGL_MULTISAMPLE_RESOLVE_BOX_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT); #if EGL_KHR_lock_surface if (egl_config_is_lockable(id)) { *value |= EGL_LOCK_SURFACE_BIT_KHR; if (egl_config_get_mapped_format(id) == egl_config_get_color_format(id)) *value |= EGL_OPTIMAL_FORMAT_BIT_KHR; /* Considered optimal if no format conversion needs doing. Currently all lockable surfaces are optimal */ } #endif return true; case EGL_TRANSPARENT_TYPE: *value = EGL_NONE; return true; case EGL_TRANSPARENT_RED_VALUE: case EGL_TRANSPARENT_GREEN_VALUE: case EGL_TRANSPARENT_BLUE_VALUE: *value = 0; return true; #if EGL_KHR_lock_surface case EGL_MATCH_FORMAT_KHR: if (!egl_config_is_lockable(id)) *value = EGL_NONE; else { switch (egl_config_get_mapped_format(id)) { case RGB_565_RSO: *value = EGL_FORMAT_RGB_565_EXACT_KHR; break; case ARGB_8888_RSO: *value = EGL_FORMAT_RGBA_8888_EXACT_KHR; break; default: UNREACHABLE(); } } return true; #endif #if EGL_ANDROID_recordable case EGL_RECORDABLE_ANDROID: *value = EGL_TRUE; return true; #endif default: return false; } }