Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/libANGLE/AttributeMap.h
1693 views
1
//
2
// Copyright 2014 The ANGLE Project Authors. All rights reserved.
3
// Use of this source code is governed by a BSD-style license that can be
4
// found in the LICENSE file.
5
//
6
7
#ifndef LIBANGLE_ATTRIBUTEMAP_H_
8
#define LIBANGLE_ATTRIBUTEMAP_H_
9
10
#include "common/PackedEnums.h"
11
12
#include <EGL/egl.h>
13
14
#include <map>
15
#include <vector>
16
17
namespace egl
18
{
19
20
class AttributeMap final
21
{
22
public:
23
AttributeMap();
24
AttributeMap(const AttributeMap &other);
25
AttributeMap &operator=(const AttributeMap &other);
26
~AttributeMap();
27
28
void insert(EGLAttrib key, EGLAttrib value);
29
bool contains(EGLAttrib key) const;
30
31
EGLAttrib get(EGLAttrib key) const;
32
EGLAttrib get(EGLAttrib key, EGLAttrib defaultValue) const;
33
EGLint getAsInt(EGLAttrib key) const;
34
EGLint getAsInt(EGLAttrib key, EGLint defaultValue) const;
35
36
template <typename PackedEnumT>
37
PackedEnumT getAsPackedEnum(EGLAttrib key) const
38
{
39
return FromEGLenum<PackedEnumT>(static_cast<EGLenum>(get(key)));
40
}
41
42
template <typename PackedEnumT>
43
PackedEnumT getAsPackedEnum(EGLAttrib key, PackedEnumT defaultValue) const
44
{
45
auto iter = mAttributes.find(key);
46
return (mAttributes.find(key) != mAttributes.end())
47
? FromEGLenum<PackedEnumT>(static_cast<EGLenum>(iter->second))
48
: defaultValue;
49
}
50
51
bool isEmpty() const;
52
std::vector<EGLint> toIntVector() const;
53
54
typedef std::map<EGLAttrib, EGLAttrib>::const_iterator const_iterator;
55
56
const_iterator begin() const;
57
const_iterator end() const;
58
59
static AttributeMap CreateFromIntArray(const EGLint *attributes);
60
static AttributeMap CreateFromAttribArray(const EGLAttrib *attributes);
61
62
private:
63
std::map<EGLAttrib, EGLAttrib> mAttributes;
64
};
65
} // namespace egl
66
67
#endif // LIBANGLE_ATTRIBUTEMAP_H_
68
69