| Louis Huemiller | 734d8d8 | 2011-01-05 18:53:47 -0800 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright (C) 2011 The Android Open Source Project | 
 | 3 |  * | 
 | 4 |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
 | 5 |  * you may not use this file except in compliance with the License. | 
 | 6 |  * You may obtain a copy of the License at | 
 | 7 |  * | 
 | 8 |  *      http://www.apache.org/licenses/LICENSE-2.0 | 
 | 9 |  * | 
 | 10 |  * Unless required by applicable law or agreed to in writing, software | 
 | 11 |  * distributed under the License is distributed on an "AS IS" BASIS, | 
 | 12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
 | 13 |  * See the License for the specific language governing permissions and | 
 | 14 |  * limitations under the License. | 
 | 15 |  * | 
 | 16 |  */ | 
 | 17 |  | 
 | 18 | /* | 
 | 19 |  * Graphics Test Library | 
 | 20 |  */ | 
 | 21 |  | 
 | 22 | #include <glTestLib.h> | 
 | 23 |  | 
 | 24 | #include <EGL/egl.h> | 
 | 25 | #include <EGL/eglext.h> | 
 | 26 | #include <GLES2/gl2.h> | 
 | 27 | #include <GLES2/gl2ext.h> | 
 | 28 |  | 
| Mathias Agopian | 870b8aa | 2012-02-24 16:42:46 -0800 | [diff] [blame] | 29 | #include "EGLUtils.h" | 
| Louis Huemiller | 734d8d8 | 2011-01-05 18:53:47 -0800 | [diff] [blame] | 30 |  | 
 | 31 | #include <utils/Log.h> | 
 | 32 | #include <testUtil.h> | 
 | 33 |  | 
| Louis Huemiller | 734d8d8 | 2011-01-05 18:53:47 -0800 | [diff] [blame] | 34 | using namespace android; | 
 | 35 |  | 
 | 36 | void glTestPrintGLString(const char *name, GLenum s) | 
 | 37 | { | 
 | 38 |     const char *v = (const char *) glGetString(s); | 
 | 39 |  | 
 | 40 |     if (v == NULL) { | 
 | 41 |         testPrintI("GL %s unknown", name); | 
 | 42 |     } else { | 
 | 43 |         testPrintI("GL %s = %s", name, v); | 
 | 44 |     } | 
 | 45 | } | 
 | 46 |  | 
 | 47 | void glTestCheckEglError(const char* op, EGLBoolean returnVal) | 
 | 48 | { | 
 | 49 |     if (returnVal != EGL_TRUE) { | 
 | 50 |         testPrintE("%s() returned %d", op, returnVal); | 
 | 51 |     } | 
 | 52 |  | 
 | 53 |     for (EGLint error = eglGetError(); error != EGL_SUCCESS; error | 
 | 54 |             = eglGetError()) { | 
 | 55 |         testPrintE("after %s() eglError %s (0x%x)", | 
 | 56 |                    op, EGLUtils::strerror(error), error); | 
 | 57 |     } | 
 | 58 | } | 
 | 59 |  | 
 | 60 | void glTestCheckGlError(const char* op) | 
 | 61 | { | 
 | 62 |     for (GLint error = glGetError(); error; error | 
 | 63 |             = glGetError()) { | 
 | 64 |         testPrintE("after %s() glError (0x%x)", op, error); | 
 | 65 |     } | 
 | 66 | } | 
 | 67 |  | 
 | 68 | void glTestPrintEGLConfiguration(EGLDisplay dpy, EGLConfig config) | 
 | 69 | { | 
 | 70 |  | 
 | 71 | #define X(VAL) {VAL, #VAL} | 
 | 72 |     struct {EGLint attribute; const char* name;} names[] = { | 
 | 73 |     X(EGL_BUFFER_SIZE), | 
 | 74 |     X(EGL_ALPHA_SIZE), | 
 | 75 |     X(EGL_BLUE_SIZE), | 
 | 76 |     X(EGL_GREEN_SIZE), | 
 | 77 |     X(EGL_RED_SIZE), | 
 | 78 |     X(EGL_DEPTH_SIZE), | 
 | 79 |     X(EGL_STENCIL_SIZE), | 
 | 80 |     X(EGL_CONFIG_CAVEAT), | 
 | 81 |     X(EGL_CONFIG_ID), | 
 | 82 |     X(EGL_LEVEL), | 
 | 83 |     X(EGL_MAX_PBUFFER_HEIGHT), | 
 | 84 |     X(EGL_MAX_PBUFFER_PIXELS), | 
 | 85 |     X(EGL_MAX_PBUFFER_WIDTH), | 
 | 86 |     X(EGL_NATIVE_RENDERABLE), | 
 | 87 |     X(EGL_NATIVE_VISUAL_ID), | 
 | 88 |     X(EGL_NATIVE_VISUAL_TYPE), | 
 | 89 |     X(EGL_SAMPLES), | 
 | 90 |     X(EGL_SAMPLE_BUFFERS), | 
 | 91 |     X(EGL_SURFACE_TYPE), | 
 | 92 |     X(EGL_TRANSPARENT_TYPE), | 
 | 93 |     X(EGL_TRANSPARENT_RED_VALUE), | 
 | 94 |     X(EGL_TRANSPARENT_GREEN_VALUE), | 
 | 95 |     X(EGL_TRANSPARENT_BLUE_VALUE), | 
 | 96 |     X(EGL_BIND_TO_TEXTURE_RGB), | 
 | 97 |     X(EGL_BIND_TO_TEXTURE_RGBA), | 
 | 98 |     X(EGL_MIN_SWAP_INTERVAL), | 
 | 99 |     X(EGL_MAX_SWAP_INTERVAL), | 
 | 100 |     X(EGL_LUMINANCE_SIZE), | 
 | 101 |     X(EGL_ALPHA_MASK_SIZE), | 
 | 102 |     X(EGL_COLOR_BUFFER_TYPE), | 
 | 103 |     X(EGL_RENDERABLE_TYPE), | 
 | 104 |     X(EGL_CONFORMANT), | 
 | 105 |    }; | 
 | 106 | #undef X | 
 | 107 |  | 
 | 108 |     for (size_t j = 0; j < sizeof(names) / sizeof(names[0]); j++) { | 
 | 109 |         EGLint value = -1; | 
 | 110 |         EGLint returnVal = eglGetConfigAttrib(dpy, config, names[j].attribute, | 
 | 111 |                                               &value); | 
 | 112 |         EGLint error = eglGetError(); | 
 | 113 |         if (returnVal && error == EGL_SUCCESS) { | 
 | 114 |             testPrintI(" %s: %d (%#x)", names[j].name, value, value); | 
 | 115 |         } | 
 | 116 |     } | 
 | 117 |     testPrintI(""); | 
 | 118 | } |