Fix support of different attrib_list in eglGetPlatformDisplay
Regression was introduced by ag/5161774, where different
EGLDisplay(s) with the same display type but different
attrib_list(s) would share the same egl_display_t object.
Only the first EGLDisplay associated with the egl_display_t
would be initialized.
Bug: 162381841
Test: Run android.graphics.cts.EGL15Test in CtsGraphicsTestCases
Change-Id: I4419e0f9f0d0f6491e7fae397b6c8926405ca836
diff --git a/opengl/libs/EGL/egl_display.h b/opengl/libs/EGL/egl_display.h
index 0155133..87c2176 100644
--- a/opengl/libs/EGL/egl_display.h
+++ b/opengl/libs/EGL/egl_display.h
@@ -23,6 +23,8 @@
#include <stdint.h>
#include <condition_variable>
+#include <map>
+#include <memory>
#include <mutex>
#include <string>
#include <unordered_set>
@@ -40,9 +42,11 @@
bool needsAndroidPEglMitigation();
class EGLAPI egl_display_t { // marked as EGLAPI for testing purposes
- static egl_display_t sDisplay[NUM_DISPLAYS];
+ static std::map<EGLDisplay, std::unique_ptr<egl_display_t>> displayMap;
+ static std::mutex displayMapLock;
EGLDisplay getDisplay(EGLNativeDisplayType display);
- EGLDisplay getPlatformDisplay(EGLNativeDisplayType display, const EGLAttrib* attrib_list);
+ static EGLDisplay getPlatformDisplay(EGLNativeDisplayType display,
+ const EGLAttrib* attrib_list);
void loseCurrentImpl(egl_context_t* cur_c);
public: