/* * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: * DongKyun Yun * SangJin Kim * HyunGoo Kang * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Contributors: * - S-Core Co., Ltd * */ #include "implement.h" struct ConfigExtra configExtraDefault = { EGL_DONT_CARE, (GLXFBConfig)EGL_DONT_CARE, 0, 0, 0, 0, 0, 0, 0, EGL_DONT_CARE, EGL_DONT_CARE, EGL_RGB_BUFFER, EGL_DONT_CARE, EGL_DONT_CARE, 0, 0, 0, 0, 0, EGL_DONT_CARE, EGL_DONT_CARE, EGL_DONT_CARE, EGL_DONT_CARE, EGL_DONT_CARE, EGL_DONT_CARE, 0, 0, 0, EGL_WINDOW_BIT, EGL_NONE, EGL_DONT_CARE, EGL_DONT_CARE, EGL_DONT_CARE, }; EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config) { struct DisplayExtra* pDisplay; struct ConfigExtra configValue; pDisplay = EGLINTER(LookUpDisplay)(dpy); if (pDisplay == NULL) { EGLINTER(SetError)(EGL_BAD_DISPLAY); return EGL_FALSE; } if (pDisplay->bInitialized == EGL_FALSE) { EGLINTER(SetError)(EGL_NOT_INITIALIZED); return EGL_FALSE; } if (num_config == NULL) { EGLINTER(SetError)(EGL_BAD_PARAMETER); return EGL_FALSE; } memcpy(&configValue, &configExtraDefault, sizeof(struct ConfigExtra)); while (attrib_list && *attrib_list != EGL_NONE) { switch (*attrib_list++) { case EGL_CONFIG_ID: configValue.unique = *attrib_list++; break; case EGL_BUFFER_SIZE: configValue.bufferSize = *attrib_list++; break; case EGL_RED_SIZE: configValue.redSize = *attrib_list++; break; case EGL_GREEN_SIZE: configValue.greenSize = *attrib_list++; break; case EGL_BLUE_SIZE: configValue.blueSize = *attrib_list++; break; case EGL_LUMINANCE_SIZE: configValue.luminanceSize = *attrib_list++; break; case EGL_ALPHA_SIZE: configValue.alphaSize = *attrib_list++; break; case EGL_ALPHA_MASK_SIZE: configValue.alphaMaskSize = *attrib_list++; break; case EGL_BIND_TO_TEXTURE_RGB: configValue.bindToTexRGB = *attrib_list++; break; case EGL_BIND_TO_TEXTURE_RGBA: configValue.bindToTexRGBA = *attrib_list++; break; case EGL_COLOR_BUFFER_TYPE: configValue.colorBufferType = *attrib_list++; break; case EGL_CONFIG_CAVEAT: configValue.configCaveat = *attrib_list++; break; case EGL_CONFORMANT: configValue.conformant = *attrib_list++; break; case EGL_DEPTH_SIZE: configValue.depthSize = *attrib_list++; break; case EGL_LEVEL: configValue.level = *attrib_list++; break; case EGL_MAX_PBUFFER_WIDTH: attrib_list++; break; case EGL_MAX_PBUFFER_HEIGHT: attrib_list++; break; case EGL_MAX_PBUFFER_PIXELS: attrib_list++; break; case EGL_MAX_SWAP_INTERVAL: configValue.maxSwapInterval = *attrib_list++; break; case EGL_MIN_SWAP_INTERVAL: configValue.minSwapInterval = *attrib_list++; break; case EGL_NATIVE_RENDERABLE: configValue.nativeRenderable = *attrib_list++; break; case EGL_NATIVE_VISUAL_ID: attrib_list++; break; case EGL_NATIVE_VISUAL_TYPE: configValue.nativeVisualType = *attrib_list++; break; case EGL_RENDERABLE_TYPE: configValue.renderableType = *attrib_list++; break; case EGL_SAMPLE_BUFFERS: configValue.sampleBuffers = *attrib_list++; break; case EGL_SAMPLES: configValue.samples = *attrib_list++; break; case EGL_STENCIL_SIZE: configValue.stencilSize = *attrib_list++; break; case EGL_SURFACE_TYPE: configValue.surfaceType = *attrib_list++; break; case EGL_TRANSPARENT_TYPE: configValue.transparentType = *attrib_list++; break; case EGL_TRANSPARENT_RED_VALUE: configValue.transparentRedValue = *attrib_list++; break; case EGL_TRANSPARENT_GREEN_VALUE: configValue.transparentGreenValue = *attrib_list++; break; case EGL_TRANSPARENT_BLUE_VALUE: configValue.transparentBlueValue = *attrib_list++; break; case EGL_MATCH_NATIVE_PIXMAP: assert(0); break; default: EGLINTER(SetError)(EGL_BAD_ATTRIBUTE); return EGL_FALSE; } } struct ConfigExtra* pUnit = pDisplay->pConfigExtra; int nCount = pDisplay->nConfigExtra; int i; if (configValue.unique != EGL_DONT_CARE) { while (nCount--) { if (pUnit->unique == configValue.unique) { *num_config = 1; if (configs != NULL && config_size > 0) { configs[0] = (EGLConfig)pUnit; } return EGL_TRUE; } pUnit++; } *num_config = 0; return EGL_TRUE; } int nAnswer = 0; EGLConfig* pAnswer = pDisplay->pConfigAnswer; for (; nCount--; pUnit++) { if (pUnit->bufferSize < configValue.bufferSize) continue; if (pUnit->redSize < configValue.redSize) continue; if (pUnit->greenSize < configValue.greenSize) continue; if (pUnit->blueSize < configValue.blueSize) continue; if (pUnit->luminanceSize < configValue.luminanceSize) continue; if (pUnit->alphaSize < configValue.alphaSize) continue; if (pUnit->alphaMaskSize < configValue.alphaMaskSize) continue; if (configValue.bindToTexRGB != EGL_DONT_CARE && pUnit->bindToTexRGB != configValue.bindToTexRGB) continue; if (configValue.bindToTexRGBA != EGL_DONT_CARE && pUnit->bindToTexRGBA != configValue.bindToTexRGBA) continue; if (pUnit->colorBufferType != configValue.colorBufferType) continue; if (configValue.configCaveat != EGL_DONT_CARE && pUnit->configCaveat != configValue.configCaveat) continue; if (configValue.conformant != EGL_DONT_CARE && (pUnit->conformant & configValue.conformant) == 0) continue; if (pUnit->depthSize < configValue.depthSize) continue; if (pUnit->level != configValue.level) continue; if (configValue.maxSwapInterval != EGL_DONT_CARE && pUnit->maxSwapInterval != configValue.maxSwapInterval) continue; if (configValue.minSwapInterval != EGL_DONT_CARE && pUnit->minSwapInterval != configValue.minSwapInterval) continue; if (configValue.nativeRenderable != EGL_DONT_CARE && pUnit->nativeRenderable != configValue.nativeRenderable) continue; if (configValue.renderableType != EGL_DONT_CARE && (pUnit->renderableType & configValue.renderableType) == 0) continue; if (pUnit->sampleBuffers < configValue.sampleBuffers) continue; if (pUnit->samples < configValue.samples) continue; if (pUnit->stencilSize < configValue.stencilSize) continue; if (pUnit->surfaceType & configValue.surfaceType == 0) continue; if (pUnit->transparentType != configValue.transparentType) continue; if (pUnit->transparentType != EGL_NONE && pUnit->transparentRedValue != configValue.transparentRedValue) continue; if (pUnit->transparentType != EGL_NONE && pUnit->transparentGreenValue != configValue.transparentGreenValue) continue; if (pUnit->transparentType != EGL_NONE && pUnit->transparentBlueValue != configValue.transparentBlueValue) continue; *pAnswer++ = pUnit; nAnswer++; } int num = nAnswer; if (configs == NULL) { *num_config = num; } else { if (config_size < num) num = config_size; if (num < 0) num = 0; *num_config = num; memcpy(configs, pDisplay->pConfigAnswer, num * sizeof(EGLConfig)); } return EGL_TRUE; }