From 5960b2717c0ada29de2c65189aee4da1fec739a2 Mon Sep 17 00:00:00 2001 From: Stas Gurtovoy Date: Sun, 5 Jun 2011 11:36:16 +0300 Subject: [PATCH] emulator opengl: Added support for config_size 0 to FBConfig::chooseConfig Fixed a bug in FBConfig::chooseConfig implementation Change-Id: I4b8e98f43825c012f13d0a0684fe8f918e511400 --- .../opengl/host/libs/libOpenglRender/FBConfig.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp b/tools/emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp index 17a0f871b..fdf5433be 100644 --- a/tools/emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp +++ b/tools/emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp @@ -249,17 +249,16 @@ int FBConfig::chooseConfig(FrameBuffer *fb, EGLint * attribs, uint32_t * configs attrib_p += attribCnt; *attrib_p = EGL_NONE; -#if 1 - DBG("EGLint %d", sizeof(EGLint)); +#if 0 if (newAttribs) { EGLint * attrib_p = newAttribs; while (attrib_p[0] != EGL_NONE) { - DBG("attr: 0x%x %d", attrib_p[0], attrib_p[1]); + DBG("attr: 0x%x %d, ", attrib_p[0], attrib_p[1]); attrib_p += 2; } } - #endif + s_egl.eglChooseConfig(dpy, newAttribs, matchedConfigs, nConfigs, &nConfigs); delete newAttribs; @@ -269,14 +268,17 @@ int FBConfig::chooseConfig(FrameBuffer *fb, EGLint * attribs, uint32_t * configs // uint32_t nVerifiedCfgs = 0; for (int matchedIdx=0; matchedIdx= configs_size) break; //We have enouhgt configs + if ((configs_size > 0) && (nVerifiedCfgs >= configs_size)) break; //We have enouhgt configs int sCfgId; s_egl.eglGetConfigAttrib(dpy, matchedConfigs[matchedIdx], EGL_CONFIG_ID, &sCfgId); for (int fbIdx=0; fbIdxm_attribValues[4]; //CONFIG_ID if (sCfgId == dCfgId) { //This config matches the requested attributes and filtered into fbConfigs, so we're happy with it - configs[nVerifiedCfgs++] = fbIdx; + if (nVerifiedCfgs < configs_size) { + configs[nVerifiedCfgs] = fbIdx; + } + nVerifiedCfgs++; break; } }