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 "deStringUtil.hpp"
35 CallLogWrapper::CallLogWrapper (TestLog& log)
41 CallLogWrapper::~CallLogWrapper (void)
54 PointerFmt (const T* arr_, deUint32 size_) : arr(arr_), size(size_) {}
58 std::ostream& operator<< (std::ostream& str, PointerFmt<T> fmt)
60 if (fmt.arr != DE_NULL)
63 for (deUint32 ndx = 0; ndx < fmt.size; ndx++)
73 return str << "(null)";
77 inline PointerFmt<T> getPointerStr (const T* arr, deUint32 size)
79 return PointerFmt<T>(arr, size);
82 typedef const char* (*GetEnumNameFunc) (int value);
84 // Enum pointer formatter.
90 GetEnumNameFunc getName;
92 EnumPointerFmt (const int* value_, GetEnumNameFunc getName_) : value(value_), getName(getName_) {}
95 inline std::ostream& operator<< (std::ostream& str, EnumPointerFmt fmt)
98 return str << tcu::Format::Enum(fmt.getName, *fmt.value);
100 return str << "(null)";
103 inline EnumPointerFmt getEnumPointerStr (const int* value, GetEnumNameFunc getName)
105 return EnumPointerFmt(value, getName);
114 StringFmt (const char* str_) : str(str_) {}
117 inline std::ostream& operator<< (std::ostream& str, StringFmt fmt)
119 return str << (fmt.str ? fmt.str : "NULL");
122 inline StringFmt getStringStr (const char* value) { return StringFmt(value); }
124 // Config attrib pointer formatter
126 class ConfigAttribValuePointerFmt
131 ConfigAttribValuePointerFmt (deUint32 attrib_, const int* value_) : attrib(attrib_), value(value_) {}
134 inline ConfigAttribValuePointerFmt getConfigAttribValuePointerStr (deUint32 attrib, const int* value) { return ConfigAttribValuePointerFmt(attrib, value); }
136 inline std::ostream& operator<< (std::ostream& str, const ConfigAttribValuePointerFmt& fmt)
139 return str << getConfigAttribValueStr(fmt.attrib, *fmt.value);
141 return str << "NULL";
144 // Context attrib pointer formatter
146 class ContextAttribValuePointerFmt
151 ContextAttribValuePointerFmt (deUint32 attrib_, const int* value_) : attrib(attrib_), value(value_) {}
154 inline ContextAttribValuePointerFmt getContextAttribValuePointerStr (deUint32 attrib, const int* value) { return ContextAttribValuePointerFmt(attrib, value); }
156 inline std::ostream& operator<< (std::ostream& str, const ContextAttribValuePointerFmt& fmt)
159 return str << getContextAttribValueStr(fmt.attrib, *fmt.value);
161 return str << "NULL";
164 // Surface attrib pointer formatter
166 class SurfaceAttribValuePointerFmt
171 SurfaceAttribValuePointerFmt (deUint32 attrib_, const int* value_) : attrib(attrib_), value(value_) {}
174 inline SurfaceAttribValuePointerFmt getSurfaceAttribValuePointerStr (deUint32 attrib, const int* value) { return SurfaceAttribValuePointerFmt(attrib, value); }
176 inline std::ostream& operator<< (std::ostream& str, const SurfaceAttribValuePointerFmt& fmt)
179 return str << getSurfaceAttribValueStr(fmt.attrib, *fmt.value);
181 return str << "NULL";
184 // EGLDisplay formatter
190 EGLDisplayFmt (EGLDisplay display_) : display(display_) {}
193 inline EGLDisplayFmt getEGLDisplayStr (EGLDisplay display) { return EGLDisplayFmt(display); }
195 inline std::ostream& operator<< (std::ostream& str, const EGLDisplayFmt& fmt)
197 if (fmt.display == EGL_NO_DISPLAY)
198 return str << "EGL_NO_DISPLAY";
200 return str << toHex(fmt.display);
203 // EGLSurface formatter
209 EGLSurfaceFmt (EGLSurface display_) : display(display_) {}
212 inline EGLSurfaceFmt getEGLSurfaceStr (EGLSurface display) { return EGLSurfaceFmt(display); }
214 inline std::ostream& operator<< (std::ostream& str, const EGLSurfaceFmt& fmt)
216 if (fmt.display == EGL_NO_SURFACE)
217 return str << "EGL_NO_SURFACE";
219 return str << toHex(fmt.display);
222 // EGLContext formatter
228 EGLContextFmt (EGLContext display_) : display(display_) {}
231 inline EGLContextFmt getEGLContextStr (EGLContext display) { return EGLContextFmt(display); }
233 inline std::ostream& operator<< (std::ostream& str, const EGLContextFmt& fmt)
235 if (fmt.display == EGL_NO_CONTEXT)
236 return str << "EGL_NO_CONTEXT";
238 return str << toHex(fmt.display);
241 // API entry-point implementations are auto-generated
242 #include "egluCallLogWrapper.inl"