Last active
November 23, 2017 20:00
-
-
Save steven676/7276901 to your computer and use it in GitHub Desktop.
[PATCH 1/6] SurfaceFlinger: try dropping features from EGL config query before giving up (against android-4.4_r1.2 frameworks/native)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 2b2472771c934b5f1e58e287335e2b15a5912ea9 Mon Sep 17 00:00:00 2001 | |
From: Steven Luo <steven+android@steven676.net> | |
Date: Fri, 1 Nov 2013 18:35:24 -0700 | |
Subject: [PATCH 1/4] SurfaceFlinger: try dropping features from EGL config | |
query before giving up | |
Change-Id: I914aba2b0404646a29854e8e2ffa708958fb41f1 | |
--- | |
services/surfaceflinger/SurfaceFlinger.cpp | 45 ++++++++++++++++++++++++---- | |
1 file changed, 40 insertions(+), 5 deletions(-) | |
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp | |
index 9d94c87..233b5ea 100644 | |
--- a/services/surfaceflinger/SurfaceFlinger.cpp | |
+++ b/services/surfaceflinger/SurfaceFlinger.cpp | |
@@ -432,12 +432,46 @@ status_t SurfaceFlinger::selectEGLConfig(EGLDisplay display, EGLint nativeVisual | |
err = selectConfigForAttribute(display, attribs, wantedAttribute, | |
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!"); | |
- } | |
+ if (err == NO_ERROR) | |
+ goto success; | |
+ | |
+ // If the above failed on the fallback path, there's nothing more we can do | |
+ if (!renderableType) | |
+ goto out; | |
+ | |
+ // Try again without EGL_FRAMEBUFFER_TARGET_ANDROID | |
+ ALOGW("no suitable EGLConfig found, trying without EGL_FRAMEBUFFER_TARGET_ANDROID"); | |
+ attribs.remove(EGL_FRAMEBUFFER_TARGET_ANDROID); | |
+ err = selectConfigForAttribute(display, attribs, wantedAttribute, wantedAttributeValue, config); | |
+ if (err == NO_ERROR) | |
+ goto success; | |
+ | |
+ // Try again without EGL_RECORDABLE_ANDROID | |
+ ALOGW("no suitable EGLConfig found, trying without EGL_RECORDABLE_ANDROID"); | |
+ attribs.remove(EGL_RECORDABLE_ANDROID); | |
+ err = selectConfigForAttribute(display, attribs, wantedAttribute, wantedAttributeValue, config); | |
+ if (err == NO_ERROR) | |
+ goto success; | |
+ | |
+ // Try again allowing 16-bit color | |
+ ALOGW("no suitable EGLConfig found, trying with 16-bit color allowed"); | |
+ attribs.remove(EGL_RED_SIZE); | |
+ attribs.remove(EGL_GREEN_SIZE); | |
+ attribs.remove(EGL_BLUE_SIZE); | |
+ err = selectConfigForAttribute(display, attribs, wantedAttribute, wantedAttributeValue, config); | |
+ if (err == NO_ERROR) | |
+ goto success; | |
+ | |
+out: | |
+ // Failed to find a config | |
return err; | |
+ | |
+success: | |
+ EGLint caveat; | |
+ if (eglGetConfigAttrib(display, *config, EGL_CONFIG_CAVEAT, &caveat)) | |
+ ALOGW_IF(caveat == EGL_SLOW_CONFIG, "EGL_SLOW_CONFIG selected!"); | |
+ | |
+ return NO_ERROR; | |
} | |
class DispSyncSource : public VSyncSource, private DispSync::Callback { | |
@@ -527,6 +561,7 @@ void SurfaceFlinger::init() { | |
if (err != NO_ERROR) { | |
// If ES2 fails, try ES1 | |
+ ALOGW("no suitable EGLConfig found, trying OpenGL ES 1.1"); | |
err = selectEGLConfig(mEGLDisplay, mHwc->getVisualID(), | |
EGL_OPENGL_ES_BIT, &mEGLConfig); | |
} | |
-- | |
1.7.10.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment