From 63046e2ba238b5ba2124ce47df656c6d60c7ecb5 Mon Sep 17 00:00:00 2001 From: Geoff Lang Date: Tue, 21 Jul 2015 12:43:50 -0400 Subject: [PATCH] Add helpers for checking EGL extension availablity in tests. Also make sure that EGL_EGLEXT_PROTOTYPES is always defined so that extension functions can be used without loading them. BUG=angleproject:970 Change-Id: I33fa3e8ed68aeda55ad69e1bc7826646f5e3ce29 Reviewed-on: https://chromium-review.googlesource.com/287161 Reviewed-by: Corentin Wallez Tested-by: Geoff Lang --- src/tests/test_utils/ANGLETest.cpp | 19 +++++++++++++++++-- src/tests/test_utils/ANGLETest.h | 5 +++++ util/EGLWindow.h | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/tests/test_utils/ANGLETest.cpp b/src/tests/test_utils/ANGLETest.cpp index 7aa6c8ca0..5221a6ab0 100644 --- a/src/tests/test_utils/ANGLETest.cpp +++ b/src/tests/test_utils/ANGLETest.cpp @@ -121,10 +121,25 @@ GLuint ANGLETest::compileShader(GLenum type, const std::string &source) return shader; } +static bool checkExtensionExists(const char *allExtensions, const std::string &extName) +{ + return strstr(allExtensions, extName.c_str()) != nullptr; +} + bool ANGLETest::extensionEnabled(const std::string &extName) { - const char* extString = reinterpret_cast(glGetString(GL_EXTENSIONS)); - return strstr(extString, extName.c_str()) != NULL; + return checkExtensionExists(reinterpret_cast(glGetString(GL_EXTENSIONS)), + extName); +} + +bool ANGLETest::eglDisplayExtensionEnabled(EGLDisplay display, const std::string &extName) +{ + return checkExtensionExists(eglQueryString(display, EGL_EXTENSIONS), extName); +} + +bool ANGLETest::eglClientExtensionEnabled(const std::string &extName) +{ + return checkExtensionExists(eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS), extName); } void ANGLETest::setWindowWidth(int width) diff --git a/src/tests/test_utils/ANGLETest.h b/src/tests/test_utils/ANGLETest.h index 95de91a28..5897670c5 100644 --- a/src/tests/test_utils/ANGLETest.h +++ b/src/tests/test_utils/ANGLETest.h @@ -7,6 +7,9 @@ #ifndef ANGLE_TESTS_ANGLE_TEST_H_ #define ANGLE_TESTS_ANGLE_TEST_H_ +#define GL_GLEXT_PROTOTYPES +#define EGL_EGLEXT_PROTOTYPES + #include #include @@ -76,6 +79,8 @@ class ANGLETest : public ::testing::TestWithParam static void drawQuad(GLuint program, const std::string& positionAttribName, GLfloat quadDepth, GLfloat quadScale = 1.0f); static GLuint compileShader(GLenum type, const std::string &source); static bool extensionEnabled(const std::string &extName); + static bool eglDisplayExtensionEnabled(EGLDisplay display, const std::string &extName); + static bool eglClientExtensionEnabled(const std::string &extName); void setWindowWidth(int width); void setWindowHeight(int height); diff --git a/util/EGLWindow.h b/util/EGLWindow.h index 6a5fc5fb9..5da5993ec 100644 --- a/util/EGLWindow.h +++ b/util/EGLWindow.h @@ -8,6 +8,7 @@ #define UTIL_EGLWINDOW_H_ #define GL_GLEXT_PROTOTYPES +#define EGL_EGLEXT_PROTOTYPES #include #include