goldfish-opengl: Protect shared texture objects map
This fixes a crash in libOpenglCodecCommon by protecting
the shared texture objects map with a ReadWriteLock.
BUG=213574323
TEST=dEQP-EGL.functional.sharing.gles2.multithread.*
Change-Id: I61f9fe3c3892c3c482cee7893526f5de854b1c4d
diff --git a/shared/OpenglCodecCommon/TextureSharedData.h b/shared/OpenglCodecCommon/TextureSharedData.h
index 96827ef..aee1996 100644
--- a/shared/OpenglCodecCommon/TextureSharedData.h
+++ b/shared/OpenglCodecCommon/TextureSharedData.h
@@ -19,6 +19,10 @@
#include <GLES/gl.h>
#include <map>
+#include "android/base/synchronization/AndroidLock.h"
+
+using android::base::guest::ReadWriteLock;
+
struct TextureDims {
std::map<GLsizei, GLsizei> widths;
std::map<GLsizei, GLsizei> heights;
@@ -44,6 +48,14 @@
bool hasCubePosZ;
};
-typedef std::map<GLuint, TextureRec*> SharedTextureDataMap;
+struct SharedTextureDataMap {
+ using MapType = std::map<GLuint, TextureRec*>;
+
+ using iterator = MapType::iterator;
+ using const_iterator = MapType::const_iterator;
+
+ MapType map;
+ ReadWriteLock lock;
+};
#endif