From aac7fe282c52d3ed80448fd1f2bcba9bd15fe200 Mon Sep 17 00:00:00 2001 From: Yochai Shefi Simchon Date: Wed, 18 May 2011 15:56:59 +0300 Subject: [PATCH] EglChooseConfig should handle the case where "configs" is NULL. Change-Id: I236afdfc73eb5dd5a3ab19e2b388772ea297bdb4 --- .../host/libs/Translator/EGL/EglDisplay.cpp | 7 +++++-- .../opengl/host/libs/Translator/EGL/EglImp.cpp | 16 +++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp index 31a425f7e..893bd1460 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp @@ -170,10 +170,13 @@ int EglDisplay::getConfigs(EGLConfig* configs,int config_size) { int EglDisplay::chooseConfigs(const EglConfig& dummy,EGLConfig* configs,int config_size) { android::Mutex::Autolock mutex(m_lock); int added = 0; - for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end() && added < config_size;it++) { + for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end() && (added < config_size || !configs);it++) { if( (*it)->choosen(dummy)){ - configs[added++] = static_cast(*it); + if(configs) { + configs[added] = static_cast(*it); + } + added++; } } //no need to sort since the configurations are saved already in sorted maner diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp index e8963465b..0dca2af06 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp @@ -411,14 +411,16 @@ EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay display, const EGLint * i+=2; } if(hasConfigId) { - EglConfig* pConfig = dpy->getConfig(config_id); - if(pConfig) { - configs[0] = static_cast(pConfig); - *num_config = 0; - return EGL_TRUE; - } else { + EglConfig* pConfig = dpy->getConfig(config_id); + if(pConfig) { + if(configs) { + configs[0] = static_cast(pConfig); + } + *num_config = 1; + return EGL_TRUE; + } else { RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } + } } } EGLNativePixelFormatType tmpfrmt = PIXEL_FORMAT_INITIALIZER;