xref: /aosp_15_r20/external/deqp/framework/egl/egluDefs.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
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(uint32_t err,const char * message,const char * file,int line)39 void checkError(uint32_t 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(uint32_t errCode,const char * errStr)55 Error::Error(uint32_t errCode, const char *errStr)
56     : tcu::TestError((std::string("EGL returned ") + getErrorName(errCode)).c_str(), errStr ? errStr : "", __FILE__,
57                      __LINE__)
58     , m_error(errCode)
59 {
60 }
61 
Error(uint32_t errCode,const char * message,const char * expr,const char * file,int line)62 Error::Error(uint32_t errCode, const char *message, const char *expr, const char *file, int line)
63     : tcu::TestError(message, expr, file, line)
64     , m_error(errCode)
65 {
66 }
67 
BadAllocError(const char * errStr)68 BadAllocError::BadAllocError(const char *errStr) : 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)
80         return true;
81     else if (m_major > v.m_major)
82         return false;
83 
84     if (m_minor < v.m_minor)
85         return true;
86 
87     return false;
88 }
89 
operator ==(const Version & v) const90 bool Version::operator==(const Version &v) const
91 {
92     if (m_major == v.m_major && m_minor == v.m_minor)
93         return true;
94 
95     return false;
96 }
97 
operator !=(const Version & v) const98 bool Version::operator!=(const Version &v) const
99 {
100     return !(*this == v);
101 }
102 
operator >(const Version & v) const103 bool Version::operator>(const Version &v) const
104 {
105     return !(*this < v && *this == v);
106 }
107 
operator <=(const Version & v) const108 bool Version::operator<=(const Version &v) const
109 {
110     return (*this < v && *this == v);
111 }
112 
operator >=(const Version & v) const113 bool Version::operator>=(const Version &v) const
114 {
115     return !(*this < v);
116 }
117 
118 } // namespace eglu
119