diff options
author | Jesse Hall <jessehall@google.com> | 2013-09-27 22:10:47 -0700 |
---|---|---|
committer | Jesse Hall <jessehall@google.com> | 2013-09-30 10:49:16 -0700 |
commit | b65f32ebe2c86869b07ac1c986660dfb2187b7d3 (patch) | |
tree | df8a549a979c6c612b1af3170a99173dd251784b /services | |
parent | 86206b41b2ff000e086301c6bafb8da577e563b2 (diff) | |
download | frameworks_native-b65f32ebe2c86869b07ac1c986660dfb2187b7d3.zip frameworks_native-b65f32ebe2c86869b07ac1c986660dfb2187b7d3.tar.gz frameworks_native-b65f32ebe2c86869b07ac1c986660dfb2187b7d3.tar.bz2 |
Fix two EGLConfig selection bugs
This fixes two bugs introduced by
Change-Id: Ia8cc084c02a0e3de910def024da8a08d02bbd89d
(a) There is no invalid EGLConfig value, in particular zero is valid.
Checking return values of eglGetConfigs and eglChooseConfig is the
only way to determine success.
(b) The "simple" EGLConfig query used as the emulator fallback should
not include EGL_RECORDABLE; the emulator doesn't have it.
Bug: 10935622
Change-Id: Ib798a24e7cf06a679811c46eaa45d39174a715ec
Diffstat (limited to 'services')
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 39 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 4 |
2 files changed, 20 insertions, 23 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index f83cc06..4f139fe 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -366,12 +366,10 @@ public: operator EGLint const* () const { return &mList.keyAt(0).v; } }; -EGLConfig SurfaceFlinger::selectEGLConfig(EGLDisplay display, EGLint nativeVisualId, - EGLint renderableType) { +status_t SurfaceFlinger::selectEGLConfig(EGLDisplay display, EGLint nativeVisualId, + EGLint renderableType, EGLConfig* config) { // select our EGLConfig. It must support EGL_RECORDABLE_ANDROID if // it is to be used with WIFI displays - EGLConfig config; - EGLint dummy; status_t err; EGLint wantedAttribute; EGLint wantedAttributeValue; @@ -390,22 +388,18 @@ EGLConfig SurfaceFlinger::selectEGLConfig(EGLDisplay display, EGLint nativeVisua } else { // if no renderable type specified, fallback to a simplified query - attribs[EGL_RECORDABLE_ANDROID] = EGL_TRUE; wantedAttribute = EGL_NATIVE_VISUAL_ID; wantedAttributeValue = nativeVisualId; } err = selectConfigForAttribute(display, attribs, wantedAttribute, - wantedAttributeValue, &config); - if (!err) - goto success; - - return 0; - -success: - if (eglGetConfigAttrib(display, config, EGL_CONFIG_CAVEAT, &dummy)) - ALOGW_IF(dummy == EGL_SLOW_CONFIG, "EGL_SLOW_CONFIG selected!"); - return config; + wantedAttributeValue, config); + if (err == NO_ERROR) { + EGLint caveat; + if (eglGetConfigAttrib(display, *config, EGL_CONFIG_CAVEAT, &caveat)) + ALOGW_IF(caveat == EGL_SLOW_CONFIG, "EGL_SLOW_CONFIG selected!"); + } + return err; } void SurfaceFlinger::init() { @@ -413,6 +407,7 @@ void SurfaceFlinger::init() { ALOGI( "SurfaceFlinger's main thread ready to run. " "Initializing graphics H/W..."); + status_t err; Mutex::Autolock _l(mStateLock); // initialize EGL for the default display @@ -425,21 +420,23 @@ void SurfaceFlinger::init() { *static_cast<HWComposer::EventHandler *>(this)); // 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 - 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... // try a simplified 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 LOG_ALWAYS_FATAL("no suitable EGLConfig found, giving up"); } diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 989e439..0e9955c 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -317,8 +317,8 @@ private: */ static status_t selectConfigForAttribute(EGLDisplay dpy, EGLint const* attrs, EGLint attribute, EGLint value, EGLConfig* outConfig); - static EGLConfig selectEGLConfig(EGLDisplay disp, EGLint visualId, - EGLint renderableType); + static status_t selectEGLConfig(EGLDisplay disp, EGLint visualId, + EGLint renderableType, EGLConfig* config); size_t getMaxTextureSize() const; size_t getMaxViewportDims() const; |