diff options
author | Yahan Zhou <yahan@google.com> | 2016-10-03 13:57:50 -0700 |
---|---|---|
committer | Yahan Zhou <yahan@google.com> | 2016-10-04 11:11:37 -0700 |
commit | 9b3dec2f88a6e2887523293072ac32a85ef38cb2 (patch) | |
tree | 6e2319106006b9e5b26490a32eb7c21ffe7ca3eb | |
parent | e7d5e38fa46f39773f5d9785865f0728e12b520f (diff) | |
download | goldfish-opengl-9b3dec2f88a6e2887523293072ac32a85ef38cb2.tar.gz |
Ignore EGL_SWAP_BEHAVIOR_PRESERVED_BIT on API 16
EGL_SWAP_BEHAVIOR_PRESERVED_BIT is never supported on the host. But API
16 tries using this flag.
This CL erases the flag when in API 16.
Change-Id: I7ad1778d8f24eb142c55cfa40bf01fc82cb41343
-rw-r--r-- | system/egl/egl.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/system/egl/egl.cpp b/system/egl/egl.cpp index 6df3b18e..1e518095 100644 --- a/system/egl/egl.cpp +++ b/system/egl/egl.cpp @@ -756,10 +756,29 @@ EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig attribs_size++; //for the terminating EGL_NONE } + // API 16 passes EGL_SWAP_BEHAVIOR_PRESERVED_BIT to surface type, + // while the host never supports it. + // We remove the bit here. + EGLint* local_attrib_list = NULL; + if (PLATFORM_SDK_VERSION <= 16) { + local_attrib_list = new EGLint[attribs_size]; + memcpy(local_attrib_list, attrib_list, attribs_size * sizeof(EGLint)); + EGLint* local_attrib_p = local_attrib_list; + while (local_attrib_p[0] != EGL_NONE) { + if (local_attrib_p[0] == EGL_SURFACE_TYPE) { + local_attrib_p[1] &= ~(EGLint)EGL_SWAP_BEHAVIOR_PRESERVED_BIT; + } + local_attrib_p += 2; + } + } + uint32_t* tempConfigs[config_size]; DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE); - *num_config = rcEnc->rcChooseConfig(rcEnc, (EGLint*)attrib_list, attribs_size * sizeof(EGLint), (uint32_t*)tempConfigs, config_size); + *num_config = rcEnc->rcChooseConfig(rcEnc, + local_attrib_list ? local_attrib_list:(EGLint*)attrib_list, + attribs_size * sizeof(EGLint), (uint32_t*)tempConfigs, config_size); + if (local_attrib_list) delete [] local_attrib_list; if (*num_config <= 0) { EGLint err = -(*num_config); *num_config = 0; |