diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-02-25 08:28:51 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-02-25 08:28:51 +0000 |
commit | e2712e4dc6ac90fe9d2534f2db115ad24c1f5d45 (patch) | |
tree | 14e0eb64f9376a34f31c21fa9fe6cf4927d7458b | |
parent | 4bc749fe8f63772f87543d34728a122430cb6ca7 (diff) | |
parent | a16eb2ef2da86593bad89f82ed8246126a092564 (diff) | |
download | device_generic_goldfish-opengl-e2712e4dc6ac90fe9d2534f2db115ad24c1f5d45.tar.gz device_generic_goldfish-opengl-e2712e4dc6ac90fe9d2534f2db115ad24c1f5d45.tar.bz2 device_generic_goldfish-opengl-e2712e4dc6ac90fe9d2534f2db115ad24c1f5d45.zip |
Snap for 4620899 from a16eb2ef2da86593bad89f82ed8246126a092564 to pi-release
Change-Id: If3e201c77c94f4cbb6e97a03d68aba5df6b5cdd5
-rwxr-xr-x | system/GLESv2_enc/GL2Encoder.cpp | 14 | ||||
-rw-r--r-- | system/GLESv2_enc/GL2Encoder.h | 6 | ||||
-rw-r--r-- | system/egl/egl.cpp | 49 |
3 files changed, 63 insertions, 6 deletions
diff --git a/system/GLESv2_enc/GL2Encoder.cpp b/system/GLESv2_enc/GL2Encoder.cpp index a7ff5c11..31f2c2a4 100755 --- a/system/GLESv2_enc/GL2Encoder.cpp +++ b/system/GLESv2_enc/GL2Encoder.cpp @@ -636,6 +636,9 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr) GLClientState* state = ctx->m_state; switch (param) { + case GL_NUM_EXTENSIONS: + *ptr = (int)ctx->m_currExtensionsArray.size(); + break; case GL_MAJOR_VERSION: *ptr = ctx->m_deviceMajorVersion; break; @@ -3901,7 +3904,7 @@ void GL2Encoder::s_glDrawRangeElements(void* self, GLenum mode, GLuint start, GL const GLubyte* GL2Encoder::s_glGetStringi(void* self, GLenum name, GLuint index) { GL2Encoder *ctx = (GL2Encoder *)self; - GLubyte *retval = (GLubyte *) ""; + const GLubyte *retval = (GLubyte *) ""; RET_AND_SET_ERROR_IF( name != GL_VENDOR && @@ -3915,11 +3918,16 @@ const GLubyte* GL2Encoder::s_glGetStringi(void* self, GLenum name, GLuint index) name == GL_VENDOR || name == GL_RENDERER || name == GL_VERSION || - name == GL_EXTENSIONS && index != 0, GL_INVALID_VALUE, retval); + RET_AND_SET_ERROR_IF( + name == GL_EXTENSIONS && + index >= ctx->m_currExtensionsArray.size(), + GL_INVALID_VALUE, + retval); + switch (name) { case GL_VENDOR: retval = gVendorString; @@ -3931,7 +3939,7 @@ const GLubyte* GL2Encoder::s_glGetStringi(void* self, GLenum name, GLuint index) retval = gVersionString; break; case GL_EXTENSIONS: - retval = gExtensionsString; + retval = (const GLubyte*)(ctx->m_currExtensionsArray[index].c_str()); break; } diff --git a/system/GLESv2_enc/GL2Encoder.h b/system/GLESv2_enc/GL2Encoder.h index 06a07a94..30186226 100644 --- a/system/GLESv2_enc/GL2Encoder.h +++ b/system/GLESv2_enc/GL2Encoder.h @@ -22,6 +22,7 @@ #include "FixedBuffer.h" #include <string> +#include <vector> class GL2Encoder : public gl2_encoder_context_t { public: @@ -59,8 +60,10 @@ public: } int majorVersion() const { return m_currMajorVersion; } int minorVersion() const { return m_currMinorVersion; } - void setExtensions(const char* exts) { + void setExtensions(const char* exts, + const std::vector<std::string>& extArray) { m_currExtensions = std::string(exts); + m_currExtensionsArray = extArray; } bool hasExtension(const char* ext) const { return m_currExtensions.find(ext) != std::string::npos; @@ -93,6 +96,7 @@ private: int m_deviceMajorVersion; int m_deviceMinorVersion; std::string m_currExtensions; + std::vector<std::string> m_currExtensionsArray; bool m_initialized; bool m_noHostError; diff --git a/system/egl/egl.cpp b/system/egl/egl.cpp index 9500fef9..569338fe 100644 --- a/system/egl/egl.cpp +++ b/system/egl/egl.cpp @@ -723,11 +723,56 @@ static const char *getGLString(int glEnum) return hostStr; } +static std::vector<std::string> getExtStringArray() { + std::vector<std::string> res; + + EGLThreadInfo *tInfo = getEGLThreadInfo(); + if (!tInfo || !tInfo->currentContext) { + return res; + } + +#define GL_EXTENSIONS 0x1F03 + + DEFINE_AND_VALIDATE_HOST_CONNECTION(res); + + char *hostStr = NULL; + int n = rcEnc->rcGetGLString(rcEnc, GL_EXTENSIONS, NULL, 0); + if (n < 0) { + hostStr = new char[-n+1]; + n = rcEnc->rcGetGLString(rcEnc, GL_EXTENSIONS, hostStr, -n); + if (n <= 0) { + delete [] hostStr; + hostStr = NULL; + } + } + + if (!hostStr || !strlen(hostStr)) { return res; } + + // find the number of extensions + int extStart = 0; + int extEnd = 0; + int currentExtIndex = 0; + int numExts = 0; + + while (extEnd < strlen(hostStr)) { + if (hostStr[extEnd] == ' ') { + int extSz = extEnd - extStart; + res.push_back(std::string(hostStr + extStart, extSz)); + currentExtIndex++; + extStart = extEnd + 1; + } + extEnd++; + } + + delete [] hostStr; + return res; +} + // ---------------------------------------------------------------------------- static EGLClient_eglInterface s_eglIface = { getThreadInfo: getEGLThreadInfo, - getGLString: getGLString + getGLString: getGLString, }; #define DBG_FUNC DBG("%s\n", __FUNCTION__) @@ -1703,7 +1748,7 @@ EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLC } const char* exts = getGLString(GL_EXTENSIONS); if (exts) { - hostCon->gl2Encoder()->setExtensions(exts); + hostCon->gl2Encoder()->setExtensions(exts, getExtStringArray()); } } else { |