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 @@
namespace KWin
{
LanczosFilter::LanczosFilter(QObject* parent)
LanczosFilter::LanczosFilter(Scene *parent)
: QObject(parent)
, m_offscreenTex(nullptr)
, m_offscreenTarget(nullptr)
......@@ -40,6 +40,7 @@ LanczosFilter::LanczosFilter(QObject* parent)
, m_shader(nullptr)
, m_uOffsets(0)
, m_uKernel(0)
, m_scene(parent)
{
}
......@@ -379,6 +380,8 @@ void LanczosFilter::timerEvent(QTimerEvent *event)
if (event->timerId() == m_timer.timerId()) {
m_timer.stop();
m_scene->makeOpenGLContextCurrent();
delete m_offscreenTarget;
delete m_offscreenTex;
m_offscreenTarget = nullptr;
......@@ -387,6 +390,8 @@ void LanczosFilter::timerEvent(QTimerEvent *event)
workspace()->forEachToplevel([this](Toplevel *toplevel) {
discardCacheTexture(toplevel->effectWindow());
});
m_scene->doneOpenGLContextCurrent();
}
}
......
......@@ -26,13 +26,14 @@ class WindowPaintData;
class GLTexture;
class GLRenderTarget;
class GLShader;
class Scene;
class LanczosFilter : public QObject
{
Q_OBJECT
public:
explicit LanczosFilter(QObject* parent = nullptr);
explicit LanczosFilter(Scene *parent);
~LanczosFilter() override;
void performPaint(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data);
......@@ -55,6 +56,7 @@ private:
int m_uKernel;
QVector2D m_offsets[16];
QVector4D m_kernel[16];
Scene *m_scene;
};
} // 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