KWin
Loading...
Searching...
No Matches
glframebuffer.h
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-2007 Rivo Laks <rivolaks@hot.ee>
6 SPDX-FileCopyrightText: 2010, 2011 Martin Gräßlin <mgraesslin@kde.org>
7 SPDX-FileCopyrightText: 2023 Xaver Hugl <xaver.hugl@kde.org>
8
9 SPDX-License-Identifier: GPL-2.0-or-later
10*/
11#pragma once
12#include "kwin_export.h"
13
14#include <QRect>
15#include <QStack>
16#include <epoxy/gl.h>
17
18namespace KWin
19{
20
21class GLTexture;
22class RenderTarget;
23class RenderViewport;
24
25// Cleans up all resources hold by the GL Context
26void KWIN_EXPORT cleanupGL();
27
36class KWIN_EXPORT GLFramebuffer
37{
38public:
43
48 explicit GLFramebuffer();
49
56 explicit GLFramebuffer(GLTexture *colorAttachment, Attachment attachment = NoAttachment);
57
62 GLFramebuffer(GLuint handle, const QSize &size);
64
68 GLuint handle() const
69 {
70 return m_handle;
71 }
75 QSize size() const
76 {
77 return m_size;
78 }
79 bool valid() const
80 {
81 return m_valid;
82 }
83
84 static void initStatic();
85 static bool supported()
86 {
87 return s_supported;
88 }
89
93 static GLFramebuffer *currentFramebuffer();
94
95 static void pushFramebuffer(GLFramebuffer *fbo);
96 static GLFramebuffer *popFramebuffer();
104 static bool blitSupported();
105
119 void blitFromFramebuffer(const QRect &source = QRect(), const QRect &destination = QRect(), GLenum filter = GL_LINEAR, bool flipX = false, bool flipY = false);
120
125 bool blitFromRenderTarget(const RenderTarget &sourceRenderTarget, const RenderViewport &sourceViewport, const QRect &source, const QRect &destination);
126
130 GLTexture *colorAttachment() const;
131
132protected:
133 void initColorAttachment(GLTexture *colorAttachment);
134 void initDepthStencilAttachment();
135
136private:
137 bool bind();
138
139 friend void KWin::cleanupGL();
140 static void cleanup();
141 inline static bool s_supported = false;
142 inline static bool s_supportsPackedDepthStencil = false;
143 inline static bool s_supportsDepth24 = false;
144 inline static bool s_blitSupported = false;
145 inline static QStack<GLFramebuffer *> s_fbos;
146
147 GLuint m_handle = 0;
148 GLuint m_depthBuffer = 0;
149 GLuint m_stencilBuffer = 0;
150 QSize m_size;
151 bool m_valid = false;
152 bool m_foreign = false;
153 GLTexture *const m_colorAttachment;
154};
155
156}
OpenGL framebuffer object.
QSize size() const
static bool supported()
GLuint handle() const
void KWIN_EXPORT cleanupGL()
Definition glutils.cpp:122