egluConfigFilter.hpp revision 3c827367444ee418f129b2c238299f49d3264554
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
32namespace eglu
33{
34
35class ConfigInfo;
36
37class ConfigFilter
38{
39public:
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
50	ConfigFilter (EGLint attribute, EGLint value, Filter rule)
51		: m_attribute	(attribute)
52		, m_value		(value)
53		, m_rule		(rule)
54	{
55	}
56
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
68private:
69	EGLint		m_attribute;
70	EGLint		m_value;
71	Filter		m_rule;
72};
73
74template <EGLint Attribute>
75class FilterTemplate
76{
77public:
78					FilterTemplate			(void) {}
79					~FilterTemplate			(void) {}
80
81	ConfigFilter	operator==				(EGLint value) const	{ return ConfigFilter(Attribute, value, ConfigFilter::FILTER_EQUAL);			}
82	ConfigFilter	operator>=				(EGLint value) const	{ return ConfigFilter(Attribute, value, ConfigFilter::FILTER_GREATER_OR_EQUAL);	}
83	ConfigFilter	operator&				(EGLint value) const	{ return ConfigFilter(Attribute, value, ConfigFilter::FILTER_AND);				}
84	ConfigFilter	operator^				(EGLint value) const	{ return ConfigFilter(Attribute, value, ConfigFilter::FILTER_NOT_SET);			}
85};
86
87// Helpers for filters
88typedef FilterTemplate<EGL_CONFIG_ID>		ConfigId;
89typedef FilterTemplate<EGL_RED_SIZE>		ConfigRedSize;
90typedef FilterTemplate<EGL_GREEN_SIZE>		ConfigGreenSize;
91typedef FilterTemplate<EGL_BLUE_SIZE>		ConfigBlueSize;
92typedef FilterTemplate<EGL_ALPHA_SIZE>		ConfigAlphaSize;
93typedef FilterTemplate<EGL_DEPTH_SIZE>		ConfigDepthSize;
94typedef FilterTemplate<EGL_STENCIL_SIZE>	ConfigStencilSize;
95typedef FilterTemplate<EGL_RENDERABLE_TYPE>	ConfigRenderableType;
96typedef FilterTemplate<EGL_SURFACE_TYPE>	ConfigSurfaceType;
97typedef FilterTemplate<EGL_SAMPLES>			ConfigSamples;
98
99class FilterList
100{
101public:
102								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
111private:
112	std::vector<ConfigFilter>	m_rules;
113};
114
115class ConfigColorBits
116{
117public:
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