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"
28 #include "deSTLUtil.hpp"
40 CandidateConfig::CandidateConfig (const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLConfig config)
41 : m_type(TYPE_EGL_OBJECT)
43 m_cfg.object.egl = &egl;
44 m_cfg.object.display = display;
45 m_cfg.object.config = config;
48 CandidateConfig::CandidateConfig (const ConfigInfo& configInfo)
49 : m_type(TYPE_CONFIG_INFO)
51 m_cfg.configInfo = &configInfo;
54 int CandidateConfig::get (deUint32 attrib) const
56 if (m_type == TYPE_CONFIG_INFO)
57 return m_cfg.configInfo->getAttribute(attrib);
60 if (attrib == EGL_COLOR_COMPONENT_TYPE_EXT)
62 const std::vector<std::string> extensions = getDisplayExtensions(*m_cfg.object.egl, m_cfg.object.display);
64 if (de::contains(extensions.begin(), extensions.end(), "EGL_EXT_pixel_format_float"))
65 return getConfigAttribInt(*m_cfg.object.egl, m_cfg.object.display, m_cfg.object.config, attrib);
67 return EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
70 return getConfigAttribInt(*m_cfg.object.egl, m_cfg.object.display, m_cfg.object.config, attrib);
74 int CandidateConfig::id (void) const { return get(EGL_CONFIG_ID); }
75 int CandidateConfig::redSize (void) const { return get(EGL_RED_SIZE); }
76 int CandidateConfig::greenSize (void) const { return get(EGL_GREEN_SIZE); }
77 int CandidateConfig::blueSize (void) const { return get(EGL_BLUE_SIZE); }
78 int CandidateConfig::alphaSize (void) const { return get(EGL_ALPHA_SIZE); }
79 int CandidateConfig::depthSize (void) const { return get(EGL_DEPTH_SIZE); }
80 int CandidateConfig::stencilSize (void) const { return get(EGL_STENCIL_SIZE); }
81 int CandidateConfig::samples (void) const { return get(EGL_SAMPLES); }
82 deUint32 CandidateConfig::renderableType (void) const { return (deUint32)get(EGL_RENDERABLE_TYPE); }
83 deUint32 CandidateConfig::surfaceType (void) const { return (deUint32)get(EGL_SURFACE_TYPE); }
84 deUint32 CandidateConfig::colorComponentType (void) const { return (deUint32)get(EGL_COLOR_COMPONENT_TYPE_EXT); }
86 FilterList& FilterList::operator<< (ConfigFilter filter)
88 m_rules.push_back(filter);
92 FilterList& FilterList::operator<< (const FilterList& other)
94 size_t oldEnd = m_rules.size();
95 m_rules.resize(m_rules.size()+other.m_rules.size());
96 std::copy(other.m_rules.begin(), other.m_rules.end(), m_rules.begin()+oldEnd);
100 bool FilterList::match (const Library& egl, EGLDisplay display, EGLConfig config) const
102 return match(CandidateConfig(egl, display, config));
105 bool FilterList::match (const ConfigInfo& configInfo) const
107 return match(CandidateConfig(configInfo));
110 bool FilterList::match (const CandidateConfig& candidate) const
112 for (vector<ConfigFilter>::const_iterator filterIter = m_rules.begin(); filterIter != m_rules.end(); filterIter++)
114 ConfigFilter filter = *filterIter;
116 if (!filter(candidate))