13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program Tester Core 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ---------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief EGL Config selection helper. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluConfigFilter.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluUtil.hpp" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluConfigInfo.hpp" 277bd8f7c0f982a10c6e7127ce2497ee7e208ea90ePyry Haulos#include "eglwEnums.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <algorithm> 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector; 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace eglu 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 363c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosusing namespace eglw; 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 393c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry HaulosCandidateConfig::CandidateConfig (const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLConfig config) 403c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos : m_type(TYPE_EGL_OBJECT) 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 423c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos m_cfg.object.egl = &egl; 433c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos m_cfg.object.display = display; 443c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos m_cfg.object.config = config; 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 473c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry HaulosCandidateConfig::CandidateConfig (const ConfigInfo& configInfo) 483c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos : m_type(TYPE_CONFIG_INFO) 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 503c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos m_cfg.configInfo = &configInfo; 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 533c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosint CandidateConfig::get (deUint32 attrib) const 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 553c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos if (m_type == TYPE_CONFIG_INFO) 563c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos return m_cfg.configInfo->getAttribute(attrib); 573c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos else 583c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos return getConfigAttribInt(*m_cfg.object.egl, m_cfg.object.display, m_cfg.object.config, attrib); 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 617bd8f7c0f982a10c6e7127ce2497ee7e208ea90ePyry Haulosint CandidateConfig::id (void) const { return get(EGL_CONFIG_ID); } 627bd8f7c0f982a10c6e7127ce2497ee7e208ea90ePyry Haulosint CandidateConfig::redSize (void) const { return get(EGL_RED_SIZE); } 637bd8f7c0f982a10c6e7127ce2497ee7e208ea90ePyry Haulosint CandidateConfig::greenSize (void) const { return get(EGL_GREEN_SIZE); } 647bd8f7c0f982a10c6e7127ce2497ee7e208ea90ePyry Haulosint CandidateConfig::blueSize (void) const { return get(EGL_BLUE_SIZE); } 657bd8f7c0f982a10c6e7127ce2497ee7e208ea90ePyry Haulosint CandidateConfig::alphaSize (void) const { return get(EGL_ALPHA_SIZE); } 667bd8f7c0f982a10c6e7127ce2497ee7e208ea90ePyry Haulosint CandidateConfig::depthSize (void) const { return get(EGL_DEPTH_SIZE); } 677bd8f7c0f982a10c6e7127ce2497ee7e208ea90ePyry Haulosint CandidateConfig::stencilSize (void) const { return get(EGL_STENCIL_SIZE); } 687bd8f7c0f982a10c6e7127ce2497ee7e208ea90ePyry Haulosint CandidateConfig::samples (void) const { return get(EGL_SAMPLES); } 697bd8f7c0f982a10c6e7127ce2497ee7e208ea90ePyry HaulosdeUint32 CandidateConfig::renderableType (void) const { return (deUint32)get(EGL_RENDERABLE_TYPE); } 707bd8f7c0f982a10c6e7127ce2497ee7e208ea90ePyry HaulosdeUint32 CandidateConfig::surfaceType (void) const { return (deUint32)get(EGL_SURFACE_TYPE); } 717bd8f7c0f982a10c6e7127ce2497ee7e208ea90ePyry Haulos 723c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry HaulosFilterList& FilterList::operator<< (ConfigFilter filter) 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 743c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos m_rules.push_back(filter); 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return *this; 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 783c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFilterList& FilterList::operator<< (const FilterList& other) 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry size_t oldEnd = m_rules.size(); 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_rules.resize(m_rules.size()+other.m_rules.size()); 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::copy(other.m_rules.begin(), other.m_rules.end(), m_rules.begin()+oldEnd); 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return *this; 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 863c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosbool FilterList::match (const Library& egl, EGLDisplay display, EGLConfig config) const 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 883c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos return match(CandidateConfig(egl, display, config)); 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool FilterList::match (const ConfigInfo& configInfo) const 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 933c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos return match(CandidateConfig(configInfo)); 943c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos} 953c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos 963c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosbool FilterList::match (const CandidateConfig& candidate) const 973c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos{ 983c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos for (vector<ConfigFilter>::const_iterator filterIter = m_rules.begin(); filterIter != m_rules.end(); filterIter++) 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1003c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos ConfigFilter filter = *filterIter; 1013c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos 1023c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos if (!filter(candidate)) 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1053c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1093c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // eglu 111