Implement eglQueryContext.

Bug b/37991302

Change-Id: I8a1c28d4a9c8968be3a04da64a19ddd3f5274dd6
Reviewed-on: https://swiftshader-review.googlesource.com/9768
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/libGLES_CM/Context.cpp b/src/OpenGL/libGLES_CM/Context.cpp
index 1a4ed35..78fcec5 100644
--- a/src/OpenGL/libGLES_CM/Context.cpp
+++ b/src/OpenGL/libGLES_CM/Context.cpp
@@ -37,8 +37,8 @@
 
 namespace es1
 {
-Context::Context(egl::Display *const display, const Context *shareContext)
-	: egl::Context(display),
+Context::Context(egl::Display *const display, const Context *shareContext, const egl::Config *config)
+	: egl::Context(display), config(config),
 	  modelViewStack(MAX_MODELVIEW_STACK_DEPTH),
 	  projectionStack(MAX_PROJECTION_STACK_DEPTH),
 	  textureStack0(MAX_TEXTURE_STACK_DEPTH),
@@ -321,11 +321,16 @@
 	markAllStateDirty();
 }
 
-int Context::getClientVersion() const
+EGLint Context::getClientVersion() const
 {
 	return 1;
 }
 
+EGLint Context::getConfigID() const
+{
+	return config->mConfigID;
+}
+
 // This function will set all of the state-related dirty flags, so that all state is set during next pre-draw.
 void Context::markAllStateDirty()
 {
@@ -3470,8 +3475,8 @@
 
 }
 
-egl::Context *es1CreateContext(egl::Display *display, const egl::Context *shareContext)
+egl::Context *es1CreateContext(egl::Display *display, const egl::Context *shareContext, const egl::Config *config)
 {
 	ASSERT(!shareContext || shareContext->getClientVersion() == 1);   // Should be checked by eglCreateContext
-	return new es1::Context(display, static_cast<const es1::Context*>(shareContext));
+	return new es1::Context(display, static_cast<const es1::Context*>(shareContext), config);
 }
diff --git a/src/OpenGL/libGLES_CM/Context.h b/src/OpenGL/libGLES_CM/Context.h
index 24e5a08..63efb74 100644
--- a/src/OpenGL/libGLES_CM/Context.h
+++ b/src/OpenGL/libGLES_CM/Context.h
@@ -291,14 +291,16 @@
 	TextureUnit textureUnit[MAX_TEXTURE_UNITS];
 };
 
-class Context : public egl::Context
+class [[clang::lto_visibility_public]] Context : public egl::Context
 {
 public:
-	Context(egl::Display *display, const Context *shareContext);
+	Context(egl::Display *display, const Context *shareContext, const egl::Config *config);
 
-	virtual void makeCurrent(egl::Surface *surface);
-	virtual int getClientVersion() const;
-	virtual void finish();
+	void makeCurrent(egl::Surface *surface) override;
+	EGLint getClientVersion() const override;
+	EGLint getConfigID() const override;
+
+	void finish() override;
 
 	void markAllStateDirty();
 
@@ -594,6 +596,8 @@
 	bool cullSkipsDraw(GLenum drawMode);
 	bool isTriangleMode(GLenum drawMode);
 
+	const egl::Config *const config;
+
 	State mState;
 
 	gl::BindingPointer<Texture2D> mTexture2DZero;
diff --git a/src/OpenGL/libGLES_CM/libGLES_CM.hpp b/src/OpenGL/libGLES_CM/libGLES_CM.hpp
index 08644c6..1c66f18 100644
--- a/src/OpenGL/libGLES_CM/libGLES_CM.hpp
+++ b/src/OpenGL/libGLES_CM/libGLES_CM.hpp
@@ -219,7 +219,7 @@
 	void (*glDrawTexfOES)(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
 	void (*glDrawTexfvOES)(const GLfloat *coords);
 
-	egl::Context *(*es1CreateContext)(egl::Display *display, const egl::Context *shareContext);
+	egl::Context *(*es1CreateContext)(egl::Display *display, const egl::Context *shareContext, const egl::Config *config);
 	__eglMustCastToProperFunctionPointerType (*es1GetProcAddress)(const char *procname);
 	egl::Image *(*createBackBuffer)(int width, int height, const egl::Config *config);
 	egl::Image *(*createDepthStencil)(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard);
diff --git a/src/OpenGL/libGLES_CM/main.cpp b/src/OpenGL/libGLES_CM/main.cpp
index 4840522..036147f 100644
--- a/src/OpenGL/libGLES_CM/main.cpp
+++ b/src/OpenGL/libGLES_CM/main.cpp
@@ -330,7 +330,7 @@
 void DrawTexfvOES(const GLfloat *coords);
 }
 
-egl::Context *es1CreateContext(egl::Display *display, const egl::Context *shareContext);
+egl::Context *es1CreateContext(egl::Display *display, const egl::Context *shareContext, const egl::Config *config);
 extern "C" __eglMustCastToProperFunctionPointerType es1GetProcAddress(const char *procname);
 egl::Image *createBackBuffer(int width, int height, const egl::Config *config);
 egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard);