am b65f32eb: Fix two EGLConfig selection bugs

* commit 'b65f32ebe2c86869b07ac1c986660dfb2187b7d3':
  Fix two EGLConfig selection bugs
This commit is contained in:
Jesse Hall 2013-09-30 21:38:40 -07:00 committed by Android Git Automerger
commit 92d7c3ee03
2 changed files with 20 additions and 23 deletions

View File

@ -366,12 +366,10 @@ public:
operator EGLint const* () const { return &mList.keyAt(0).v; } operator EGLint const* () const { return &mList.keyAt(0).v; }
}; };
EGLConfig SurfaceFlinger::selectEGLConfig(EGLDisplay display, EGLint nativeVisualId, status_t SurfaceFlinger::selectEGLConfig(EGLDisplay display, EGLint nativeVisualId,
EGLint renderableType) { EGLint renderableType, EGLConfig* config) {
// select our EGLConfig. It must support EGL_RECORDABLE_ANDROID if // select our EGLConfig. It must support EGL_RECORDABLE_ANDROID if
// it is to be used with WIFI displays // it is to be used with WIFI displays
EGLConfig config;
EGLint dummy;
status_t err; status_t err;
EGLint wantedAttribute; EGLint wantedAttribute;
EGLint wantedAttributeValue; EGLint wantedAttributeValue;
@ -390,22 +388,18 @@ EGLConfig SurfaceFlinger::selectEGLConfig(EGLDisplay display, EGLint nativeVisua
} else { } else {
// if no renderable type specified, fallback to a simplified query // if no renderable type specified, fallback to a simplified query
attribs[EGL_RECORDABLE_ANDROID] = EGL_TRUE;
wantedAttribute = EGL_NATIVE_VISUAL_ID; wantedAttribute = EGL_NATIVE_VISUAL_ID;
wantedAttributeValue = nativeVisualId; wantedAttributeValue = nativeVisualId;
} }
err = selectConfigForAttribute(display, attribs, wantedAttribute, err = selectConfigForAttribute(display, attribs, wantedAttribute,
wantedAttributeValue, &config); wantedAttributeValue, config);
if (!err) if (err == NO_ERROR) {
goto success; EGLint caveat;
if (eglGetConfigAttrib(display, *config, EGL_CONFIG_CAVEAT, &caveat))
return 0; ALOGW_IF(caveat == EGL_SLOW_CONFIG, "EGL_SLOW_CONFIG selected!");
}
success: return err;
if (eglGetConfigAttrib(display, config, EGL_CONFIG_CAVEAT, &dummy))
ALOGW_IF(dummy == EGL_SLOW_CONFIG, "EGL_SLOW_CONFIG selected!");
return config;
} }
void SurfaceFlinger::init() { void SurfaceFlinger::init() {
@ -413,6 +407,7 @@ void SurfaceFlinger::init() {
ALOGI( "SurfaceFlinger's main thread ready to run. " ALOGI( "SurfaceFlinger's main thread ready to run. "
"Initializing graphics H/W..."); "Initializing graphics H/W...");
status_t err;
Mutex::Autolock _l(mStateLock); Mutex::Autolock _l(mStateLock);
// initialize EGL for the default display // initialize EGL for the default display
@ -425,21 +420,23 @@ void SurfaceFlinger::init() {
*static_cast<HWComposer::EventHandler *>(this)); *static_cast<HWComposer::EventHandler *>(this));
// First try to get an ES2 config // First try to get an ES2 config
mEGLConfig = selectEGLConfig(mEGLDisplay, mHwc->getVisualID(), EGL_OPENGL_ES2_BIT); err = selectEGLConfig(mEGLDisplay, mHwc->getVisualID(), EGL_OPENGL_ES2_BIT,
&mEGLConfig);
if (!mEGLConfig) { if (err != NO_ERROR) {
// If ES2 fails, try ES1 // If ES2 fails, try ES1
mEGLConfig = selectEGLConfig(mEGLDisplay, mHwc->getVisualID(), EGL_OPENGL_ES_BIT); err = selectEGLConfig(mEGLDisplay, mHwc->getVisualID(),
EGL_OPENGL_ES_BIT, &mEGLConfig);
} }
if (!mEGLConfig) { if (err != NO_ERROR) {
// still didn't work, probably because we're on the emulator... // still didn't work, probably because we're on the emulator...
// try a simplified query // try a simplified query
ALOGW("no suitable EGLConfig found, trying a simpler query"); ALOGW("no suitable EGLConfig found, trying a simpler query");
mEGLConfig = selectEGLConfig(mEGLDisplay, mHwc->getVisualID(), 0); err = selectEGLConfig(mEGLDisplay, mHwc->getVisualID(), 0, &mEGLConfig);
} }
if (!mEGLConfig) { if (err != NO_ERROR) {
// this EGL is too lame for android // this EGL is too lame for android
LOG_ALWAYS_FATAL("no suitable EGLConfig found, giving up"); LOG_ALWAYS_FATAL("no suitable EGLConfig found, giving up");
} }

View File

@ -317,8 +317,8 @@ private:
*/ */
static status_t selectConfigForAttribute(EGLDisplay dpy, static status_t selectConfigForAttribute(EGLDisplay dpy,
EGLint const* attrs, EGLint attribute, EGLint value, EGLConfig* outConfig); EGLint const* attrs, EGLint attribute, EGLint value, EGLConfig* outConfig);
static EGLConfig selectEGLConfig(EGLDisplay disp, EGLint visualId, static status_t selectEGLConfig(EGLDisplay disp, EGLint visualId,
EGLint renderableType); EGLint renderableType, EGLConfig* config);
size_t getMaxTextureSize() const; size_t getMaxTextureSize() const;
size_t getMaxViewportDims() const; size_t getMaxViewportDims() const;