diff options
Diffstat (limited to 'opengl')
| -rw-r--r-- | opengl/Android.bp | 24 | ||||
| -rw-r--r-- | opengl/libs/Android.bp | 2 | ||||
| -rw-r--r-- | opengl/libs/EGL/eglApi.cpp | 2 | ||||
| -rw-r--r-- | opengl/libs/libEGL.map.txt | 2 | ||||
| -rw-r--r-- | opengl/tests/gl2_basic/gl2_basic.cpp | 2 | ||||
| -rw-r--r-- | opengl/tests/hwc/hwcRects.cpp | 4 | ||||
| -rw-r--r-- | opengl/tests/lib/include/EGLUtils.h | 178 |
7 files changed, 202 insertions, 12 deletions
diff --git a/opengl/Android.bp b/opengl/Android.bp index aec5a95628..9ca8b0b0fd 100644 --- a/opengl/Android.bp +++ b/opengl/Android.bp @@ -52,6 +52,30 @@ ndk_headers { license: "include/KHR/NOTICE", } +llndk_library { + name: "libEGL", + symbol_file: "libs/libEGL.map.txt", + export_include_dirs: ["include"], +} + +llndk_library { + name: "libGLESv1_CM", + symbol_file: "libs/libGLESv1_CM.map.txt", + export_include_dirs: ["include"], +} + +llndk_library { + name: "libGLESv2", + symbol_file: "libs/libGLESv2.map.txt", + export_include_dirs: ["include"], +} + +llndk_library { + name: "libGLESv3", + symbol_file: "libs/libGLESv3.map.txt", + export_include_dirs: ["include"], +} + cc_library_headers { name: "gl_headers", vendor_available: true, diff --git a/opengl/libs/Android.bp b/opengl/libs/Android.bp index b4cc2113e9..802b3b46e0 100644 --- a/opengl/libs/Android.bp +++ b/opengl/libs/Android.bp @@ -85,7 +85,6 @@ cc_defaults { cc_defaults { name: "egl_libs_defaults", defaults: ["gl_libs_defaults"], - vendor_available: true, cflags: [ "-DLOG_TAG=\"libEGL\"", ], @@ -152,7 +151,6 @@ cc_test { cc_defaults { name: "gles_libs_defaults", defaults: ["gl_libs_defaults"], - vendor_available: true, arch: { arm: { instruction_set: "arm", diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp index 0214b0eb56..94dfe6a9de 100644 --- a/opengl/libs/EGL/eglApi.cpp +++ b/opengl/libs/EGL/eglApi.cpp @@ -1447,7 +1447,7 @@ const char* eglQueryString(EGLDisplay dpy, EGLint name) return setError(EGL_BAD_PARAMETER, (const char *)0); } -EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name) +extern "C" EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name) { clearError(); diff --git a/opengl/libs/libEGL.map.txt b/opengl/libs/libEGL.map.txt index 89269a0231..fa26e33f39 100644 --- a/opengl/libs/libEGL.map.txt +++ b/opengl/libs/libEGL.map.txt @@ -21,6 +21,7 @@ LIBEGL { eglDestroyStreamKHR; # introduced=23 eglDestroySurface; eglDestroySyncKHR; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21 + eglDupNativeFenceFDANDROID; # vndk eglGetConfigAttrib; eglGetConfigs; eglGetCurrentContext; @@ -44,6 +45,7 @@ LIBEGL { eglQueryStreamTimeKHR; # introduced=23 eglQueryStreamu64KHR; # introduced=23 eglQueryString; + eglQueryStringImplementationANDROID; # vndk eglQuerySurface; eglReleaseTexImage; eglReleaseThread; diff --git a/opengl/tests/gl2_basic/gl2_basic.cpp b/opengl/tests/gl2_basic/gl2_basic.cpp index ee88667328..67c0969e21 100644 --- a/opengl/tests/gl2_basic/gl2_basic.cpp +++ b/opengl/tests/gl2_basic/gl2_basic.cpp @@ -30,7 +30,7 @@ #include <EGLUtils.h> using namespace android; -EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name); +extern "C" EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name); static void printGLString(const char *name, GLenum s) { // fprintf(stderr, "printGLString %s, %d\n", name, s); diff --git a/opengl/tests/hwc/hwcRects.cpp b/opengl/tests/hwc/hwcRects.cpp index 69e56ff59b..5956366809 100644 --- a/opengl/tests/hwc/hwcRects.cpp +++ b/opengl/tests/hwc/hwcRects.cpp @@ -170,7 +170,7 @@ static EGLSurface surface; static EGLint width, height; // Function prototypes -static Rectangle parseRect(string rectStr); +static Rectangle parseRect(const string& rectStr); void init(void); void printSyntax(const char *cmd); @@ -358,7 +358,7 @@ main(int argc, char *argv[]) // Parse string description of rectangle and add it to list of rectangles // to be rendered. -static Rectangle parseRect(string rectStr) +static Rectangle parseRect(const string& rectStr) { int rv; string str; diff --git a/opengl/tests/lib/include/EGLUtils.h b/opengl/tests/lib/include/EGLUtils.h index 014c2611ae..9dc6bcf56a 100644 --- a/opengl/tests/lib/include/EGLUtils.h +++ b/opengl/tests/lib/include/EGLUtils.h @@ -20,11 +20,16 @@ #include <stdint.h> #include <stdlib.h> +#include <vector> +#include <EGL/egl.h> +#include <EGL/eglext.h> +#include <GLES2/gl2.h> #include <system/window.h> #include <utils/Errors.h> -#include <EGL/egl.h> +#include <utils/String8.h> +extern "C" EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name); // ---------------------------------------------------------------------------- namespace android { @@ -47,6 +52,17 @@ public: EGLint const* attrs, EGLNativeWindowType window, EGLConfig* outConfig); + + static inline String8 printGLString(const char* name, GLenum s); + static inline String8 printEGLString(EGLDisplay dpy, const char* name, GLenum s); + static inline String8 checkEglError(const char* op, EGLBoolean returnVal); + static inline String8 checkGlError(const char* op); + static inline String8 printEGLConfiguration(EGLDisplay dpy, EGLConfig config); + static inline bool printEGLConfigurations(EGLDisplay dpy, String8& msg); + static inline bool printEGLConfigurations(FILE* output, EGLDisplay dpy); + static inline String8 decodeColorSpace(EGLint colorSpace); + static inline bool hasEglExtension(EGLDisplay dpy, const char* name); + static inline bool hasExtension(const char* exts, const char* name); }; // ---------------------------------------------------------------------------- @@ -91,9 +107,8 @@ status_t EGLUtils::selectConfigForPixelFormat( if (eglGetConfigs(dpy, NULL, 0, &numConfigs) == EGL_FALSE) return BAD_VALUE; - EGLConfig* const configs = (EGLConfig*)malloc(sizeof(EGLConfig)*numConfigs); - if (eglChooseConfig(dpy, attrs, configs, numConfigs, &n) == EGL_FALSE) { - free(configs); + std::vector<EGLConfig> configs(numConfigs); + if (eglChooseConfig(dpy, attrs, configs.data(), numConfigs, &n) == EGL_FALSE) { return BAD_VALUE; } @@ -108,8 +123,6 @@ status_t EGLUtils::selectConfigForPixelFormat( } } - free(configs); - if (i<n) { *outConfig = config; return NO_ERROR; @@ -137,6 +150,159 @@ status_t EGLUtils::selectConfigForNativeWindow( return selectConfigForPixelFormat(dpy, attrs, format, outConfig); } +String8 EGLUtils::printGLString(const char* name, GLenum s) { + String8 msg; + const char* v = reinterpret_cast<const char*>(glGetString(s)); + msg.appendFormat("GL %s = %s\n", name, v); + return msg; +} + +String8 EGLUtils::printEGLString(EGLDisplay dpy, const char* name, GLenum s) { + String8 msg; + const char* v = static_cast<const char*>(eglQueryString(dpy, s)); + msg.appendFormat("GL %s = %s\n", name, v); + const char* va = (const char*)eglQueryStringImplementationANDROID(dpy, s); + msg.appendFormat("ImplementationANDROID: %s = %s\n", name, va); + return msg; +} + +String8 EGLUtils::checkEglError(const char* op, EGLBoolean returnVal = EGL_TRUE) { + String8 msg; + if (returnVal != EGL_TRUE) { + msg.appendFormat("%s() returned %d\n", op, returnVal); + } + + for (EGLint error = eglGetError(); error != EGL_SUCCESS; error = eglGetError()) { + msg.appendFormat("after %s() eglError %s (0x%x)\n", op, EGLUtils::strerror(error), error); + } + return msg; +} + +String8 EGLUtils::checkGlError(const char* op) { + String8 msg; + for (GLint error = glGetError(); error != GL_NO_ERROR; error = glGetError()) { + msg.appendFormat("after %s() glError (0x%x)\n", op, error); + } + return msg; +} + +String8 EGLUtils::printEGLConfiguration(EGLDisplay dpy, EGLConfig config) { +#define X(VAL) \ + { VAL, #VAL } + struct { + EGLint attribute; + const char* name; + } names[] = { + X(EGL_BUFFER_SIZE), + X(EGL_ALPHA_SIZE), + X(EGL_BLUE_SIZE), + X(EGL_GREEN_SIZE), + X(EGL_RED_SIZE), + X(EGL_DEPTH_SIZE), + X(EGL_STENCIL_SIZE), + X(EGL_CONFIG_CAVEAT), + X(EGL_CONFIG_ID), + X(EGL_LEVEL), + X(EGL_MAX_PBUFFER_HEIGHT), + X(EGL_MAX_PBUFFER_PIXELS), + X(EGL_MAX_PBUFFER_WIDTH), + X(EGL_NATIVE_RENDERABLE), + X(EGL_NATIVE_VISUAL_ID), + X(EGL_NATIVE_VISUAL_TYPE), + X(EGL_SAMPLES), + X(EGL_SAMPLE_BUFFERS), + X(EGL_SURFACE_TYPE), + X(EGL_TRANSPARENT_TYPE), + X(EGL_TRANSPARENT_RED_VALUE), + X(EGL_TRANSPARENT_GREEN_VALUE), + X(EGL_TRANSPARENT_BLUE_VALUE), + X(EGL_BIND_TO_TEXTURE_RGB), + X(EGL_BIND_TO_TEXTURE_RGBA), + X(EGL_MIN_SWAP_INTERVAL), + X(EGL_MAX_SWAP_INTERVAL), + X(EGL_LUMINANCE_SIZE), + X(EGL_ALPHA_MASK_SIZE), + X(EGL_COLOR_BUFFER_TYPE), + X(EGL_RENDERABLE_TYPE), + X(EGL_CONFORMANT), + }; +#undef X + + String8 msg; + for (size_t j = 0; j < sizeof(names) / sizeof(names[0]); j++) { + EGLint value = -1; + EGLint returnVal = eglGetConfigAttrib(dpy, config, names[j].attribute, &value); + EGLint error = eglGetError(); + if (returnVal && error == EGL_SUCCESS) { + msg.appendFormat(" %s: %d (0x%x)", names[j].name, value, value); + } + } + msg.append("\n"); + return msg; +} + +bool EGLUtils::printEGLConfigurations(EGLDisplay dpy, String8& msg) { + EGLint numConfig = 0; + EGLint returnVal = eglGetConfigs(dpy, NULL, 0, &numConfig); + msg.append(checkEglError("eglGetConfigs", returnVal)); + if (!returnVal) { + return false; + } + + msg.appendFormat("Number of EGL configuration: %d\n", numConfig); + + std::vector<EGLConfig> configs(numConfig); + + returnVal = eglGetConfigs(dpy, configs.data(), numConfig, &numConfig); + msg.append(checkEglError("eglGetConfigs", returnVal)); + if (!returnVal) { + return false; + } + + for (int i = 0; i < numConfig; i++) { + msg.appendFormat("Configuration %d\n", i); + msg.append(printEGLConfiguration(dpy, configs[i])); + } + + return true; +} + +bool EGLUtils::printEGLConfigurations(FILE* output, EGLDisplay dpy) { + String8 msg; + bool status = printEGLConfigurations(dpy, msg); + fprintf(output, "%s", msg.c_str()); + return status; +} + +String8 EGLUtils::decodeColorSpace(EGLint colorSpace) { + switch (colorSpace) { + case EGL_GL_COLORSPACE_SRGB_KHR: + return String8("EGL_GL_COLORSPACE_SRGB_KHR"); + case EGL_GL_COLORSPACE_DISPLAY_P3_EXT: + return String8("EGL_GL_COLORSPACE_DISPLAY_P3_EXT"); + case EGL_GL_COLORSPACE_LINEAR_KHR: + return String8("EGL_GL_COLORSPACE_LINEAR_KHR"); + default: + return String8::format("UNKNOWN ColorSpace %d", colorSpace); + } +} + +bool EGLUtils::hasExtension(const char* exts, const char* name) { + size_t nameLen = strlen(name); + if (exts) { + for (const char* match = strstr(exts, name); match; match = strstr(match + nameLen, name)) { + if (match[nameLen] == '\0' || match[nameLen] == ' ') { + return true; + } + } + } + return false; +} + +bool EGLUtils::hasEglExtension(EGLDisplay dpy, const char* name) { + return hasExtension(eglQueryString(dpy, EGL_EXTENSIONS), name); +} + // ---------------------------------------------------------------------------- }; // namespace android // ---------------------------------------------------------------------------- |