KWin
Loading...
Searching...
No Matches
src
platformsupport
scenes
opengl
openglbackend.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: 2006 Lubos Lunak <l.lunak@kde.org>
6
SPDX-FileCopyrightText: 2009, 2010, 2011 Martin Gräßlin <mgraesslin@kde.org>
7
8
SPDX-License-Identifier: GPL-2.0-or-later
9
*/
10
#include "
platformsupport/scenes/opengl/openglbackend.h
"
11
#include "
opengl/glutils_funcs.h
"
12
13
#include "
utils/common.h
"
14
15
#include <QElapsedTimer>
16
17
#include <unistd.h>
18
19
namespace
KWin
20
{
21
22
OpenGLBackend::OpenGLBackend
()
23
: m_haveBufferAge(false)
24
, m_failed(false)
25
{
26
}
27
28
OpenGLBackend::~OpenGLBackend
()
29
{
30
}
31
32
CompositingType
OpenGLBackend::compositingType
()
const
33
{
34
return
OpenGLCompositing
;
35
}
36
37
void
OpenGLBackend::setFailed
(
const
QString &reason)
38
{
39
qCWarning(KWIN_OPENGL) <<
"Creating the OpenGL rendering failed: "
<< reason;
40
m_failed =
true
;
41
}
42
43
void
OpenGLBackend::copyPixels
(
const
QRegion ®ion,
const
QSize &screenSize)
44
{
45
const
int
height = screenSize.height();
46
for
(
const
QRect &r : region) {
47
const
int
x0 = r.x();
48
const
int
y0 = height - r.y() - r.height();
49
const
int
x1 = r.x() + r.width();
50
const
int
y1 = height - r.y();
51
52
glBlitFramebuffer(x0, y0, x1, y1, x0, y0, x1, y1, GL_COLOR_BUFFER_BIT, GL_NEAREST);
53
}
54
}
55
56
std::pair<std::shared_ptr<KWin::GLTexture>,
ColorDescription
>
OpenGLBackend::textureForOutput
(
Output
*output)
const
57
{
58
return
{
nullptr
,
ColorDescription::sRGB
};
59
}
60
61
bool
OpenGLBackend::checkGraphicsReset
()
62
{
63
const
GLenum status =
KWin::glGetGraphicsResetStatus
();
64
if
(Q_LIKELY(status == GL_NO_ERROR)) {
65
return
false
;
66
}
67
68
switch
(status) {
69
case
GL_GUILTY_CONTEXT_RESET:
70
qCWarning(KWIN_OPENGL) <<
"A graphics reset attributable to the current GL context occurred."
;
71
break
;
72
case
GL_INNOCENT_CONTEXT_RESET:
73
qCWarning(KWIN_OPENGL) <<
"A graphics reset not attributable to the current GL context occurred."
;
74
break
;
75
case
GL_UNKNOWN_CONTEXT_RESET:
76
qCWarning(KWIN_OPENGL) <<
"A graphics reset of an unknown cause occurred."
;
77
break
;
78
default
:
79
break
;
80
}
81
82
QElapsedTimer timer;
83
timer.start();
84
85
// Wait until the reset is completed or max one second
86
while
(timer.elapsed() < 10000 &&
KWin::glGetGraphicsResetStatus
() != GL_NO_ERROR) {
87
usleep(50);
88
}
89
if
(timer.elapsed() >= 10000) {
90
qCWarning(KWIN_OPENGL) <<
"Waiting for glGetGraphicsResetStatus to return GL_NO_ERROR timed out!"
;
91
}
92
93
return
true
;
94
}
95
96
}
97
98
#include "moc_openglbackend.cpp"
KWin::ColorDescription
Definition
colorspace.h:103
KWin::ColorDescription::sRGB
static const ColorDescription sRGB
Definition
colorspace.h:132
KWin::OpenGLBackend::compositingType
CompositingType compositingType() const override final
Definition
openglbackend.cpp:32
KWin::OpenGLBackend::~OpenGLBackend
virtual ~OpenGLBackend()
Definition
openglbackend.cpp:28
KWin::OpenGLBackend::checkGraphicsReset
bool checkGraphicsReset() override final
Definition
openglbackend.cpp:61
KWin::OpenGLBackend::textureForOutput
virtual std::pair< std::shared_ptr< GLTexture >, ColorDescription > textureForOutput(Output *output) const
Definition
openglbackend.cpp:56
KWin::OpenGLBackend::setFailed
void setFailed(const QString &reason)
Sets the backend initialization to failed.
Definition
openglbackend.cpp:37
KWin::OpenGLBackend::copyPixels
void copyPixels(const QRegion ®ion, const QSize &screenSize)
Definition
openglbackend.cpp:43
KWin::OpenGLBackend::OpenGLBackend
OpenGLBackend()
Definition
openglbackend.cpp:22
KWin::Output
Definition
output.h:132
common.h
glutils_funcs.h
KWin
Definition
activation_test.cpp:20
KWin::CompositingType
CompositingType
Definition
globals.h:28
KWin::OpenGLCompositing
@ OpenGLCompositing
Definition
globals.h:37
KWin::glGetGraphicsResetStatus
glGetGraphicsResetStatus_func glGetGraphicsResetStatus
Definition
glutils_funcs.cpp:27
openglbackend.h
Generated on Sat Feb 17 2024 01:42:09 for KWin by
1.10.0