1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program Tester Core
3 * ----------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
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
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
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.
18 *
19 *//*!
20 * \file
21 * \brief EGL common defines and types
22 *//*--------------------------------------------------------------------*/
23
24 #include "egluDefs.hpp"
25 #include "egluStrUtil.hpp"
26 #include "egluConfigInfo.hpp"
27 #include "eglwLibrary.hpp"
28 #include "eglwEnums.hpp"
29 #include "deString.h"
30
31 #include <string>
32 #include <sstream>
33
34 namespace eglu
35 {
36
37 using namespace eglw;
38
checkError(deUint32 err,const char * message,const char * file,int line)39 void checkError (deUint32 err, const char* message, const char* file, int line)
40 {
41 if (err != EGL_SUCCESS)
42 {
43 std::ostringstream desc;
44 desc << "Got " << eglu::getErrorStr(err);
45 if (message)
46 desc << ": " << message;
47
48 if (err == EGL_BAD_ALLOC)
49 throw BadAllocError(desc.str().c_str(), DE_NULL, file, line);
50 else
51 throw Error(err, desc.str().c_str(), DE_NULL, file, line);
52 }
53 }
54
Error(deUint32 errCode,const char * errStr)55 Error::Error (deUint32 errCode, const char* errStr)
56 : tcu::TestError ((std::string("EGL returned ") + getErrorName(errCode)).c_str(), errStr ? errStr : "", __FILE__, __LINE__)
57 , m_error (errCode)
58 {
59 }
60
Error(deUint32 errCode,const char * message,const char * expr,const char * file,int line)61 Error::Error (deUint32 errCode, const char* message, const char* expr, const char* file, int line)
62 : tcu::TestError (message, expr, file, line)
63 , m_error (errCode)
64 {
65 }
66
BadAllocError(const char * errStr)67 BadAllocError::BadAllocError (const char* errStr)
68 : tcu::ResourceError(errStr)
69 {
70 }
71
BadAllocError(const char * message,const char * expr,const char * file,int line)72 BadAllocError::BadAllocError (const char* message, const char* expr, const char* file, int line)
73 : tcu::ResourceError(message, expr, file, line)
74 {
75 }
76
operator <(const Version & v) const77 bool Version::operator< (const Version& v) const
78 {
79 if (m_major < v.m_major) return true;
80 else if (m_major > v.m_major) return false;
81
82 if (m_minor < v.m_minor) return true;
83
84 return false;
85 }
86
operator ==(const Version & v) const87 bool Version::operator== (const Version& v) const
88 {
89 if (m_major == v.m_major && m_minor == v.m_minor) return true;
90
91 return false;
92 }
93
operator !=(const Version & v) const94 bool Version::operator!= (const Version& v) const
95 {
96 return !(*this == v);
97 }
98
operator >(const Version & v) const99 bool Version::operator> (const Version& v) const
100 {
101 return !(*this < v && *this == v);
102 }
103
operator <=(const Version & v) const104 bool Version::operator<= (const Version& v) const
105 {
106 return (*this < v && *this == v);
107 }
108
operator >=(const Version & v) const109 bool Version::operator>= (const Version& v) const
110 {
111 return !(*this < v);
112 }
113
114 } // eglu
115