EglChooseConfig should handle the case where "configs" is NULL.

Change-Id: I236afdfc73eb5dd5a3ab19e2b388772ea297bdb4
This commit is contained in:
Yochai Shefi Simchon
2011-05-18 15:56:59 +03:00
parent bf483268fc
commit aac7fe282c
2 changed files with 14 additions and 9 deletions

View File

@@ -170,10 +170,13 @@ int EglDisplay::getConfigs(EGLConfig* configs,int config_size) {
int EglDisplay::chooseConfigs(const EglConfig& dummy,EGLConfig* configs,int config_size) { int EglDisplay::chooseConfigs(const EglConfig& dummy,EGLConfig* configs,int config_size) {
android::Mutex::Autolock mutex(m_lock); android::Mutex::Autolock mutex(m_lock);
int added = 0; 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)){ if( (*it)->choosen(dummy)){
configs[added++] = static_cast<EGLConfig>(*it); if(configs) {
configs[added] = static_cast<EGLConfig>(*it);
}
added++;
} }
} }
//no need to sort since the configurations are saved already in sorted maner //no need to sort since the configurations are saved already in sorted maner

View File

@@ -411,14 +411,16 @@ EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay display, const EGLint *
i+=2; i+=2;
} }
if(hasConfigId) { if(hasConfigId) {
EglConfig* pConfig = dpy->getConfig(config_id); EglConfig* pConfig = dpy->getConfig(config_id);
if(pConfig) { if(pConfig) {
configs[0] = static_cast<EGLConfig>(pConfig); if(configs) {
*num_config = 0; configs[0] = static_cast<EGLConfig>(pConfig);
return EGL_TRUE; }
} else { *num_config = 1;
return EGL_TRUE;
} else {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
} }
} }
} }
EGLNativePixelFormatType tmpfrmt = PIXEL_FORMAT_INITIALIZER; EGLNativePixelFormatType tmpfrmt = PIXEL_FORMAT_INITIALIZER;