1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program Tester Core
3*35238bceSAndroid Build Coastguard Worker * ----------------------------------------
4*35238bceSAndroid Build Coastguard Worker *
5*35238bceSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker *
7*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker *
11*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker *
13*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker *
19*35238bceSAndroid Build Coastguard Worker *//*!
20*35238bceSAndroid Build Coastguard Worker * \file
21*35238bceSAndroid Build Coastguard Worker * \brief EGL common defines and types
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "egluDefs.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "egluStrUtil.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "egluConfigInfo.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "eglwLibrary.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "eglwEnums.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "deString.h"
30*35238bceSAndroid Build Coastguard Worker
31*35238bceSAndroid Build Coastguard Worker #include <string>
32*35238bceSAndroid Build Coastguard Worker #include <sstream>
33*35238bceSAndroid Build Coastguard Worker
34*35238bceSAndroid Build Coastguard Worker namespace eglu
35*35238bceSAndroid Build Coastguard Worker {
36*35238bceSAndroid Build Coastguard Worker
37*35238bceSAndroid Build Coastguard Worker using namespace eglw;
38*35238bceSAndroid Build Coastguard Worker
checkError(uint32_t err,const char * message,const char * file,int line)39*35238bceSAndroid Build Coastguard Worker void checkError(uint32_t err, const char *message, const char *file, int line)
40*35238bceSAndroid Build Coastguard Worker {
41*35238bceSAndroid Build Coastguard Worker if (err != EGL_SUCCESS)
42*35238bceSAndroid Build Coastguard Worker {
43*35238bceSAndroid Build Coastguard Worker std::ostringstream desc;
44*35238bceSAndroid Build Coastguard Worker desc << "Got " << eglu::getErrorStr(err);
45*35238bceSAndroid Build Coastguard Worker if (message)
46*35238bceSAndroid Build Coastguard Worker desc << ": " << message;
47*35238bceSAndroid Build Coastguard Worker
48*35238bceSAndroid Build Coastguard Worker if (err == EGL_BAD_ALLOC)
49*35238bceSAndroid Build Coastguard Worker throw BadAllocError(desc.str().c_str(), DE_NULL, file, line);
50*35238bceSAndroid Build Coastguard Worker else
51*35238bceSAndroid Build Coastguard Worker throw Error(err, desc.str().c_str(), DE_NULL, file, line);
52*35238bceSAndroid Build Coastguard Worker }
53*35238bceSAndroid Build Coastguard Worker }
54*35238bceSAndroid Build Coastguard Worker
Error(uint32_t errCode,const char * errStr)55*35238bceSAndroid Build Coastguard Worker Error::Error(uint32_t errCode, const char *errStr)
56*35238bceSAndroid Build Coastguard Worker : tcu::TestError((std::string("EGL returned ") + getErrorName(errCode)).c_str(), errStr ? errStr : "", __FILE__,
57*35238bceSAndroid Build Coastguard Worker __LINE__)
58*35238bceSAndroid Build Coastguard Worker , m_error(errCode)
59*35238bceSAndroid Build Coastguard Worker {
60*35238bceSAndroid Build Coastguard Worker }
61*35238bceSAndroid Build Coastguard Worker
Error(uint32_t errCode,const char * message,const char * expr,const char * file,int line)62*35238bceSAndroid Build Coastguard Worker Error::Error(uint32_t errCode, const char *message, const char *expr, const char *file, int line)
63*35238bceSAndroid Build Coastguard Worker : tcu::TestError(message, expr, file, line)
64*35238bceSAndroid Build Coastguard Worker , m_error(errCode)
65*35238bceSAndroid Build Coastguard Worker {
66*35238bceSAndroid Build Coastguard Worker }
67*35238bceSAndroid Build Coastguard Worker
BadAllocError(const char * errStr)68*35238bceSAndroid Build Coastguard Worker BadAllocError::BadAllocError(const char *errStr) : tcu::ResourceError(errStr)
69*35238bceSAndroid Build Coastguard Worker {
70*35238bceSAndroid Build Coastguard Worker }
71*35238bceSAndroid Build Coastguard Worker
BadAllocError(const char * message,const char * expr,const char * file,int line)72*35238bceSAndroid Build Coastguard Worker BadAllocError::BadAllocError(const char *message, const char *expr, const char *file, int line)
73*35238bceSAndroid Build Coastguard Worker : tcu::ResourceError(message, expr, file, line)
74*35238bceSAndroid Build Coastguard Worker {
75*35238bceSAndroid Build Coastguard Worker }
76*35238bceSAndroid Build Coastguard Worker
operator <(const Version & v) const77*35238bceSAndroid Build Coastguard Worker bool Version::operator<(const Version &v) const
78*35238bceSAndroid Build Coastguard Worker {
79*35238bceSAndroid Build Coastguard Worker if (m_major < v.m_major)
80*35238bceSAndroid Build Coastguard Worker return true;
81*35238bceSAndroid Build Coastguard Worker else if (m_major > v.m_major)
82*35238bceSAndroid Build Coastguard Worker return false;
83*35238bceSAndroid Build Coastguard Worker
84*35238bceSAndroid Build Coastguard Worker if (m_minor < v.m_minor)
85*35238bceSAndroid Build Coastguard Worker return true;
86*35238bceSAndroid Build Coastguard Worker
87*35238bceSAndroid Build Coastguard Worker return false;
88*35238bceSAndroid Build Coastguard Worker }
89*35238bceSAndroid Build Coastguard Worker
operator ==(const Version & v) const90*35238bceSAndroid Build Coastguard Worker bool Version::operator==(const Version &v) const
91*35238bceSAndroid Build Coastguard Worker {
92*35238bceSAndroid Build Coastguard Worker if (m_major == v.m_major && m_minor == v.m_minor)
93*35238bceSAndroid Build Coastguard Worker return true;
94*35238bceSAndroid Build Coastguard Worker
95*35238bceSAndroid Build Coastguard Worker return false;
96*35238bceSAndroid Build Coastguard Worker }
97*35238bceSAndroid Build Coastguard Worker
operator !=(const Version & v) const98*35238bceSAndroid Build Coastguard Worker bool Version::operator!=(const Version &v) const
99*35238bceSAndroid Build Coastguard Worker {
100*35238bceSAndroid Build Coastguard Worker return !(*this == v);
101*35238bceSAndroid Build Coastguard Worker }
102*35238bceSAndroid Build Coastguard Worker
operator >(const Version & v) const103*35238bceSAndroid Build Coastguard Worker bool Version::operator>(const Version &v) const
104*35238bceSAndroid Build Coastguard Worker {
105*35238bceSAndroid Build Coastguard Worker return !(*this < v && *this == v);
106*35238bceSAndroid Build Coastguard Worker }
107*35238bceSAndroid Build Coastguard Worker
operator <=(const Version & v) const108*35238bceSAndroid Build Coastguard Worker bool Version::operator<=(const Version &v) const
109*35238bceSAndroid Build Coastguard Worker {
110*35238bceSAndroid Build Coastguard Worker return (*this < v && *this == v);
111*35238bceSAndroid Build Coastguard Worker }
112*35238bceSAndroid Build Coastguard Worker
operator >=(const Version & v) const113*35238bceSAndroid Build Coastguard Worker bool Version::operator>=(const Version &v) const
114*35238bceSAndroid Build Coastguard Worker {
115*35238bceSAndroid Build Coastguard Worker return !(*this < v);
116*35238bceSAndroid Build Coastguard Worker }
117*35238bceSAndroid Build Coastguard Worker
118*35238bceSAndroid Build Coastguard Worker } // namespace eglu
119