1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program Tester Core
3 * ----------------------------------------
5 * Copyright 2014 The Android Open Source Project
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * \brief EGL Config selection helper.
22 *//*--------------------------------------------------------------------*/
24 #include "egluConfigFilter.hpp"
25 #include "egluUtil.hpp"
26 #include "egluConfigInfo.hpp"
27 #include "eglwEnums.hpp"
39 CandidateConfig::CandidateConfig (const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLConfig config)
40 : m_type(TYPE_EGL_OBJECT)
42 m_cfg.object.egl = &egl;
43 m_cfg.object.display = display;
44 m_cfg.object.config = config;
47 CandidateConfig::CandidateConfig (const ConfigInfo& configInfo)
48 : m_type(TYPE_CONFIG_INFO)
50 m_cfg.configInfo = &configInfo;
53 int CandidateConfig::get (deUint32 attrib) const
55 if (m_type == TYPE_CONFIG_INFO)
56 return m_cfg.configInfo->getAttribute(attrib);
58 return getConfigAttribInt(*m_cfg.object.egl, m_cfg.object.display, m_cfg.object.config, attrib);
61 int CandidateConfig::id (void) const { return get(EGL_CONFIG_ID); }
62 int CandidateConfig::redSize (void) const { return get(EGL_RED_SIZE); }
63 int CandidateConfig::greenSize (void) const { return get(EGL_GREEN_SIZE); }
64 int CandidateConfig::blueSize (void) const { return get(EGL_BLUE_SIZE); }
65 int CandidateConfig::alphaSize (void) const { return get(EGL_ALPHA_SIZE); }
66 int CandidateConfig::depthSize (void) const { return get(EGL_DEPTH_SIZE); }
67 int CandidateConfig::stencilSize (void) const { return get(EGL_STENCIL_SIZE); }
68 int CandidateConfig::samples (void) const { return get(EGL_SAMPLES); }
69 deUint32 CandidateConfig::renderableType (void) const { return (deUint32)get(EGL_RENDERABLE_TYPE); }
70 deUint32 CandidateConfig::surfaceType (void) const { return (deUint32)get(EGL_SURFACE_TYPE); }
72 FilterList& FilterList::operator<< (ConfigFilter filter)
74 m_rules.push_back(filter);
78 FilterList& FilterList::operator<< (const FilterList& other)
80 size_t oldEnd = m_rules.size();
81 m_rules.resize(m_rules.size()+other.m_rules.size());
82 std::copy(other.m_rules.begin(), other.m_rules.end(), m_rules.begin()+oldEnd);
86 bool FilterList::match (const Library& egl, EGLDisplay display, EGLConfig config) const
88 return match(CandidateConfig(egl, display, config));
91 bool FilterList::match (const ConfigInfo& configInfo) const
93 return match(CandidateConfig(configInfo));
96 bool FilterList::match (const CandidateConfig& candidate) const
98 for (vector<ConfigFilter>::const_iterator filterIter = m_rules.begin(); filterIter != m_rules.end(); filterIter++)
100 ConfigFilter filter = *filterIter;
102 if (!filter(candidate))