lanczosfilter.h 1.42 KB
Newer Older
Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
1
2
3
/*
    KWin - the KDE window manager
    This file is part of the KDE project.
4

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
5
6
    SPDX-FileCopyrightText: 2010 Fredrik Höglund <fredrik@kde.org>
    SPDX-FileCopyrightText: 2010 Martin Gräßlin <mgraesslin@kde.org>
7

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
8
9
    SPDX-License-Identifier: GPL-2.0-or-later
*/
10
11
12
13
14
15
16
17
18
19
20
21
22

#ifndef KWIN_LANCZOSFILTER_P_H
#define KWIN_LANCZOSFILTER_P_H

#include <QObject>
#include <QBasicTimer>
#include <QVector>
#include <QVector2D>
#include <QVector4D>

namespace KWin
{

23
class EffectWindow;
24
25
26
27
28
class EffectWindowImpl;
class WindowPaintData;
class GLTexture;
class GLRenderTarget;
class GLShader;
29
class Scene;
30

31
class LanczosFilter : public QObject
32
33
34
{
    Q_OBJECT

35
public:
36
    explicit LanczosFilter(Scene *parent);
37
    ~LanczosFilter() override;
38
39
40
    void performPaint(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data);

protected:
41
    void timerEvent(QTimerEvent*) override;
42
43
44
45
private:
    void init();
    void updateOffscreenSurfaces();
    void setUniforms();
46
    void discardCacheTexture(EffectWindow *w);
47
48
49

    void createKernel(float delta, int *kernelSize);
    void createOffsets(int count, float width, Qt::Orientation direction);
50
51
52
53
54
    GLTexture *m_offscreenTex;
    GLRenderTarget *m_offscreenTarget;
    QBasicTimer m_timer;
    bool m_inited;
    QScopedPointer<GLShader> m_shader;
55
56
57
58
    int m_uOffsets;
    int m_uKernel;
    QVector2D m_offsets[16];
    QVector4D m_kernel[16];
59
    Scene *m_scene;
60
61
62
63
64
};

} // namespace

#endif // KWIN_LANCZOSFILTER_P_H