KWin
Loading...
Searching...
No Matches
egl_context_attribute_builder.cpp
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2017 Martin Flöser <mgraesslin@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
10#include <epoxy/egl.h>
11
12namespace KWin
13{
14std::vector<int> EglContextAttributeBuilder::build() const
15{
16 std::vector<int> attribs;
17 if (isVersionRequested()) {
18 attribs.emplace_back(EGL_CONTEXT_MAJOR_VERSION_KHR);
19 attribs.emplace_back(majorVersion());
20 attribs.emplace_back(EGL_CONTEXT_MINOR_VERSION_KHR);
21 attribs.emplace_back(minorVersion());
22 }
23 int contextFlags = 0;
24 if (isRobust()) {
25 attribs.emplace_back(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR);
26 attribs.emplace_back(EGL_LOSE_CONTEXT_ON_RESET_KHR);
27 contextFlags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
29 attribs.emplace_back(EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV);
30 attribs.emplace_back(GL_TRUE);
31 }
32 }
33 if (isForwardCompatible()) {
34 contextFlags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
35 }
36 if (contextFlags != 0) {
37 attribs.emplace_back(EGL_CONTEXT_FLAGS_KHR);
38 attribs.emplace_back(contextFlags);
39 }
41 attribs.emplace_back(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR);
42 if (isCoreProfile()) {
43 attribs.emplace_back(EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR);
44 } else if (isCompatibilityProfile()) {
45 attribs.emplace_back(EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR);
46 }
47 }
48 if (isHighPriority()) {
49 attribs.emplace_back(EGL_CONTEXT_PRIORITY_LEVEL_IMG);
50 attribs.emplace_back(EGL_CONTEXT_PRIORITY_HIGH_IMG);
51 }
52 attribs.emplace_back(EGL_NONE);
53 return attribs;
54}
55
57{
58 std::vector<int> attribs;
59 attribs.emplace_back(EGL_CONTEXT_CLIENT_VERSION);
60 attribs.emplace_back(majorVersion());
61 if (isRobust()) {
62 attribs.emplace_back(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT);
63 attribs.emplace_back(EGL_TRUE);
64 attribs.emplace_back(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT);
65 attribs.emplace_back(EGL_LOSE_CONTEXT_ON_RESET_EXT);
67 attribs.emplace_back(EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV);
68 attribs.emplace_back(GL_TRUE);
69 }
70 }
71 if (isHighPriority()) {
72 attribs.emplace_back(EGL_CONTEXT_PRIORITY_LEVEL_IMG);
73 attribs.emplace_back(EGL_CONTEXT_PRIORITY_HIGH_IMG);
74 }
75 attribs.emplace_back(EGL_NONE);
76 return attribs;
77}
78
79}
std::vector< int > build() const override