Commit 8303a4cd authored by David Edmundson's avatar David Edmundson Committed by Vlad Zahorodnii
Browse files

Make GL Context current when deleting lanczos textures in timer hander.

A timer could have fired at any time. We process mulitple QtQuickViews
on timers which change the GL context.

Deleting a kwin GLTexture calls glDeleteTextures/glDeleteFramebuffers.

Surprisingly I haven't seen a crash report from this, but it doesn't
look right.
parent 0f588c25
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
namespace KWin namespace KWin
{ {
LanczosFilter::LanczosFilter(QObject* parent) LanczosFilter::LanczosFilter(Scene *parent)
: QObject(parent) : QObject(parent)
, m_offscreenTex(nullptr) , m_offscreenTex(nullptr)
, m_offscreenTarget(nullptr) , m_offscreenTarget(nullptr)
...@@ -40,6 +40,7 @@ LanczosFilter::LanczosFilter(QObject* parent) ...@@ -40,6 +40,7 @@ LanczosFilter::LanczosFilter(QObject* parent)
, m_shader(nullptr) , m_shader(nullptr)
, m_uOffsets(0) , m_uOffsets(0)
, m_uKernel(0) , m_uKernel(0)
, m_scene(parent)
{ {
} }
...@@ -379,6 +380,8 @@ void LanczosFilter::timerEvent(QTimerEvent *event) ...@@ -379,6 +380,8 @@ void LanczosFilter::timerEvent(QTimerEvent *event)
if (event->timerId() == m_timer.timerId()) { if (event->timerId() == m_timer.timerId()) {
m_timer.stop(); m_timer.stop();
m_scene->makeOpenGLContextCurrent();
delete m_offscreenTarget; delete m_offscreenTarget;
delete m_offscreenTex; delete m_offscreenTex;
m_offscreenTarget = nullptr; m_offscreenTarget = nullptr;
...@@ -387,6 +390,8 @@ void LanczosFilter::timerEvent(QTimerEvent *event) ...@@ -387,6 +390,8 @@ void LanczosFilter::timerEvent(QTimerEvent *event)
workspace()->forEachToplevel([this](Toplevel *toplevel) { workspace()->forEachToplevel([this](Toplevel *toplevel) {
discardCacheTexture(toplevel->effectWindow()); discardCacheTexture(toplevel->effectWindow());
}); });
m_scene->doneOpenGLContextCurrent();
} }
} }
......
...@@ -26,13 +26,14 @@ class WindowPaintData; ...@@ -26,13 +26,14 @@ class WindowPaintData;
class GLTexture; class GLTexture;
class GLRenderTarget; class GLRenderTarget;
class GLShader; class GLShader;
class Scene;
class LanczosFilter : public QObject class LanczosFilter : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit LanczosFilter(QObject* parent = nullptr); explicit LanczosFilter(Scene *parent);
~LanczosFilter() override; ~LanczosFilter() override;
void performPaint(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data); void performPaint(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data);
...@@ -55,6 +56,7 @@ private: ...@@ -55,6 +56,7 @@ private:
int m_uKernel; int m_uKernel;
QVector2D m_offsets[16]; QVector2D m_offsets[16];
QVector4D m_kernel[16]; QVector4D m_kernel[16];
Scene *m_scene;
}; };
} // namespace } // namespace
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment