Path: blob/main_old/src/libANGLE/AttributeMap.h
1693 views
//1// Copyright 2014 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//56#ifndef LIBANGLE_ATTRIBUTEMAP_H_7#define LIBANGLE_ATTRIBUTEMAP_H_89#include "common/PackedEnums.h"1011#include <EGL/egl.h>1213#include <map>14#include <vector>1516namespace egl17{1819class AttributeMap final20{21public:22AttributeMap();23AttributeMap(const AttributeMap &other);24AttributeMap &operator=(const AttributeMap &other);25~AttributeMap();2627void insert(EGLAttrib key, EGLAttrib value);28bool contains(EGLAttrib key) const;2930EGLAttrib get(EGLAttrib key) const;31EGLAttrib get(EGLAttrib key, EGLAttrib defaultValue) const;32EGLint getAsInt(EGLAttrib key) const;33EGLint getAsInt(EGLAttrib key, EGLint defaultValue) const;3435template <typename PackedEnumT>36PackedEnumT getAsPackedEnum(EGLAttrib key) const37{38return FromEGLenum<PackedEnumT>(static_cast<EGLenum>(get(key)));39}4041template <typename PackedEnumT>42PackedEnumT getAsPackedEnum(EGLAttrib key, PackedEnumT defaultValue) const43{44auto iter = mAttributes.find(key);45return (mAttributes.find(key) != mAttributes.end())46? FromEGLenum<PackedEnumT>(static_cast<EGLenum>(iter->second))47: defaultValue;48}4950bool isEmpty() const;51std::vector<EGLint> toIntVector() const;5253typedef std::map<EGLAttrib, EGLAttrib>::const_iterator const_iterator;5455const_iterator begin() const;56const_iterator end() const;5758static AttributeMap CreateFromIntArray(const EGLint *attributes);59static AttributeMap CreateFromAttribArray(const EGLAttrib *attributes);6061private:62std::map<EGLAttrib, EGLAttrib> mAttributes;63};64} // namespace egl6566#endif // LIBANGLE_ATTRIBUTEMAP_H_676869