1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program EGL Utilities
3 * ------------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief EGL call wrapper for logging.
22 *//*--------------------------------------------------------------------*/
24 #include "egluCallLogWrapper.hpp"
25 #include "egluStrUtil.hpp"
26 #include "eglwLibrary.hpp"
27 #include "eglwEnums.hpp"
28 #include "deStringUtil.hpp"
37 CallLogWrapper::CallLogWrapper (const eglw::Library& egl, TestLog& log)
44 CallLogWrapper::~CallLogWrapper (void)
57 PointerFmt (const T* arr_, deUint32 size_) : arr(arr_), size(size_) {}
61 std::ostream& operator<< (std::ostream& str, PointerFmt<T> fmt)
63 if (fmt.arr != DE_NULL)
66 for (deUint32 ndx = 0; ndx < fmt.size; ndx++)
76 return str << "(null)";
80 inline PointerFmt<T> getPointerStr (const T* arr, deUint32 size)
82 return PointerFmt<T>(arr, size);
85 typedef const char* (*GetEnumNameFunc) (int value);
87 // Enum pointer formatter.
93 GetEnumNameFunc getName;
95 EnumPointerFmt (const int* value_, GetEnumNameFunc getName_) : value(value_), getName(getName_) {}
98 inline std::ostream& operator<< (std::ostream& str, EnumPointerFmt fmt)
101 return str << tcu::Format::Enum<int, 2>(fmt.getName, *fmt.value);
103 return str << "(null)";
106 inline EnumPointerFmt getEnumPointerStr (const int* value, GetEnumNameFunc getName)
108 return EnumPointerFmt(value, getName);
117 StringFmt (const char* str_) : str(str_) {}
120 inline std::ostream& operator<< (std::ostream& str, StringFmt fmt)
122 return str << (fmt.str ? fmt.str : "NULL");
125 inline StringFmt getStringStr (const char* value) { return StringFmt(value); }
127 // Config attrib pointer formatter
129 class ConfigAttribValuePointerFmt
134 ConfigAttribValuePointerFmt (deUint32 attrib_, const int* value_) : attrib(attrib_), value(value_) {}
137 inline ConfigAttribValuePointerFmt getConfigAttribValuePointerStr (deUint32 attrib, const int* value) { return ConfigAttribValuePointerFmt(attrib, value); }
139 inline std::ostream& operator<< (std::ostream& str, const ConfigAttribValuePointerFmt& fmt)
142 return str << getConfigAttribValueStr(fmt.attrib, *fmt.value);
144 return str << "NULL";
147 // Context attrib pointer formatter
149 class ContextAttribValuePointerFmt
154 ContextAttribValuePointerFmt (deUint32 attrib_, const int* value_) : attrib(attrib_), value(value_) {}
157 inline ContextAttribValuePointerFmt getContextAttribValuePointerStr (deUint32 attrib, const int* value) { return ContextAttribValuePointerFmt(attrib, value); }
159 inline std::ostream& operator<< (std::ostream& str, const ContextAttribValuePointerFmt& fmt)
162 return str << getContextAttribValueStr(fmt.attrib, *fmt.value);
164 return str << "NULL";
167 // Surface attrib pointer formatter
169 class SurfaceAttribValuePointerFmt
174 SurfaceAttribValuePointerFmt (deUint32 attrib_, const int* value_) : attrib(attrib_), value(value_) {}
177 inline SurfaceAttribValuePointerFmt getSurfaceAttribValuePointerStr (deUint32 attrib, const int* value) { return SurfaceAttribValuePointerFmt(attrib, value); }
179 inline std::ostream& operator<< (std::ostream& str, const SurfaceAttribValuePointerFmt& fmt)
182 return str << getSurfaceAttribValueStr(fmt.attrib, *fmt.value);
184 return str << "NULL";
187 // EGLDisplay formatter
192 eglw::EGLDisplay display;
193 EGLDisplayFmt (eglw::EGLDisplay display_) : display(display_) {}
196 inline EGLDisplayFmt getEGLDisplayStr (eglw::EGLDisplay display) { return EGLDisplayFmt(display); }
198 inline std::ostream& operator<< (std::ostream& str, const EGLDisplayFmt& fmt)
200 if (fmt.display == EGL_NO_DISPLAY)
201 return str << "EGL_NO_DISPLAY";
203 return str << toHex(fmt.display);
206 // EGLSurface formatter
211 eglw::EGLSurface surface;
212 EGLSurfaceFmt (eglw::EGLSurface surface_) : surface(surface_) {}
215 inline EGLSurfaceFmt getEGLSurfaceStr (eglw::EGLSurface surface) { return EGLSurfaceFmt(surface); }
217 inline std::ostream& operator<< (std::ostream& str, const EGLSurfaceFmt& fmt)
219 if (fmt.surface == EGL_NO_SURFACE)
220 return str << "EGL_NO_SURFACE";
222 return str << toHex(fmt.surface);
225 // EGLContext formatter
230 eglw::EGLContext context;
231 EGLContextFmt (eglw::EGLContext context_) : context(context_) {}
234 inline EGLContextFmt getEGLContextStr (eglw::EGLContext context) { return EGLContextFmt(context); }
236 inline std::ostream& operator<< (std::ostream& str, const EGLContextFmt& fmt)
238 if (fmt.context == EGL_NO_CONTEXT)
239 return str << "EGL_NO_CONTEXT";
241 return str << toHex(fmt.context);
244 // API entry-point implementations are auto-generated
245 #include "egluCallLogWrapper.inl"