1 /* 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef EGLUtils_h 21 #define EGLUtils_h 22 23 #include <egl.h> 24 #include <wtf/Assertions.h> 25 26 static inline const char* toEGLErrorConstant(EGLint error) 27 { 28 switch (error) { 29 case EGL_NOT_INITIALIZED: 30 return "EGL_NOT_INITIALIZED"; 31 case EGL_BAD_ACCESS: 32 return "EGL_BAD_ACCESS"; 33 case EGL_BAD_ALLOC: 34 return "EGL_BAD_ALLOC"; 35 case EGL_BAD_ATTRIBUTE: 36 return "EGL_BAD_ATTRIBUTE"; 37 case EGL_BAD_CONTEXT: 38 return "EGL_BAD_CONTEXT"; 39 case EGL_BAD_CONFIG: 40 return "EGL_BAD_CONFIG"; 41 case EGL_BAD_CURRENT_SURFACE: 42 return "EGL_BAD_CURRENT_SURFACE"; 43 case EGL_BAD_DISPLAY: 44 return "EGL_BAD_DISPLAY"; 45 case EGL_BAD_SURFACE: 46 return "EGL_BAD_SURFACE"; 47 case EGL_BAD_MATCH: 48 return "EGL_BAD_MATCH"; 49 case EGL_BAD_PARAMETER: 50 return "EGL_BAD_PARAMETER"; 51 case EGL_BAD_NATIVE_PIXMAP: 52 return "EGL_BAD_NATIVE_PIXMAP"; 53 case EGL_BAD_NATIVE_WINDOW: 54 return "EGL_BAD_NATIVE_WINDOW"; 55 case EGL_CONTEXT_LOST: 56 return "EGL_CONTEXT_LOST"; 57 default: 58 return "UNKNOWN_ERROR"; 59 } 60 } 61 62 #if ASSERT_DISABLED 63 #define ASSERT_EGL_NO_ERROR() ((void)0) 64 #else 65 #define ASSERT_EGL_NO_ERROR() do { \ 66 EGLint eglErrorCode = eglGetError(); \ 67 ASSERT_WITH_MESSAGE(eglErrorCode == EGL_SUCCESS, "Found %s", toEGLErrorConstant(eglErrorCode)); \ 68 } while (0) 69 #endif 70 71 #endif 72