1 #ifndef _EGLUCONFIGFILTER_HPP 2 #define _EGLUCONFIGFILTER_HPP 3 /*------------------------------------------------------------------------- 4 * drawElements Quality Program Tester Core 5 * ---------------------------------------- 6 * 7 * Copyright 2014 The Android Open Source Project 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 * 21 *//*! 22 * \file 23 * \brief EGL Config selection helper. 24 *//*--------------------------------------------------------------------*/ 25 26 #include "tcuDefs.hpp" 27 #include "egluHeaderWrapper.hpp" 28 #include "tcuRGBA.hpp" 29 30 #include <vector> 31 32 namespace eglu 33 { 34 35 class ConfigInfo; 36 37 class ConfigFilter 38 { 39 public: 40 enum Filter 41 { 42 FILTER_EQUAL = 0, 43 FILTER_GREATER_OR_EQUAL, 44 FILTER_AND, 45 FILTER_NOT_SET, 46 47 FILTER_LAST 48 }; 49 ConfigFilter(EGLint attribute,EGLint value,Filter rule)50 ConfigFilter (EGLint attribute, EGLint value, Filter rule) 51 : m_attribute (attribute) 52 , m_value (value) 53 , m_rule (rule) 54 { 55 } 56 ConfigFilter(void)57 ConfigFilter (void) 58 : m_attribute (0) 59 , m_value (0) 60 , m_rule (FILTER_LAST) 61 { 62 } 63 64 bool match (EGLDisplay display, EGLConfig config) const; 65 66 bool match (const ConfigInfo& configInfo) const; 67 68 private: 69 EGLint m_attribute; 70 EGLint m_value; 71 Filter m_rule; 72 }; 73 74 template <EGLint Attribute> 75 class FilterTemplate 76 { 77 public: FilterTemplate(void)78 FilterTemplate (void) {} ~FilterTemplate(void)79 ~FilterTemplate (void) {} 80 operator ==(EGLint value) const81 ConfigFilter operator== (EGLint value) const { return ConfigFilter(Attribute, value, ConfigFilter::FILTER_EQUAL); } operator >=(EGLint value) const82 ConfigFilter operator>= (EGLint value) const { return ConfigFilter(Attribute, value, ConfigFilter::FILTER_GREATER_OR_EQUAL); } operator &(EGLint value) const83 ConfigFilter operator& (EGLint value) const { return ConfigFilter(Attribute, value, ConfigFilter::FILTER_AND); } operator ^(EGLint value) const84 ConfigFilter operator^ (EGLint value) const { return ConfigFilter(Attribute, value, ConfigFilter::FILTER_NOT_SET); } 85 }; 86 87 // Helpers for filters 88 typedef FilterTemplate<EGL_CONFIG_ID> ConfigId; 89 typedef FilterTemplate<EGL_RED_SIZE> ConfigRedSize; 90 typedef FilterTemplate<EGL_GREEN_SIZE> ConfigGreenSize; 91 typedef FilterTemplate<EGL_BLUE_SIZE> ConfigBlueSize; 92 typedef FilterTemplate<EGL_ALPHA_SIZE> ConfigAlphaSize; 93 typedef FilterTemplate<EGL_DEPTH_SIZE> ConfigDepthSize; 94 typedef FilterTemplate<EGL_STENCIL_SIZE> ConfigStencilSize; 95 typedef FilterTemplate<EGL_RENDERABLE_TYPE> ConfigRenderableType; 96 typedef FilterTemplate<EGL_SURFACE_TYPE> ConfigSurfaceType; 97 typedef FilterTemplate<EGL_SAMPLES> ConfigSamples; 98 99 class FilterList 100 { 101 public: FilterList(void)102 FilterList (void) {} ~FilterList(void)103 ~FilterList (void) {} 104 105 FilterList& operator<< (const ConfigFilter& rule); 106 FilterList& operator<< (const FilterList& other); 107 108 bool match (const EGLDisplay display, EGLConfig config) const; 109 bool match (const ConfigInfo& configInfo) const; 110 111 private: 112 std::vector<ConfigFilter> m_rules; 113 }; 114 115 class ConfigColorBits 116 { 117 public: ConfigColorBits(void)118 ConfigColorBits (void) {}; 119 120 FilterList operator== (tcu::RGBA bits) const; 121 FilterList operator>= (tcu::RGBA bits) const; 122 }; 123 124 } // eglu 125 126 #endif // _EGLUCONFIGFILTER_HPP 127