1 | /******************************************************************** |
2 | KWin - the KDE window manager |
3 | This file is part of the KDE project. |
4 | |
5 | Copyright (C) 2010 by Fredrik Höglund <fredrik@kde.org> |
6 | Copyright (C) 2010 Martin Gräßlin <mgraesslin@kde.org> |
7 | |
8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | *********************************************************************/ |
21 | |
22 | #ifndef KWIN_LANCZOSFILTER_P_H |
23 | #define KWIN_LANCZOSFILTER_P_H |
24 | |
25 | #include <QObject> |
26 | #include <QBasicTimer> |
27 | #include <QVector> |
28 | #include <QVector2D> |
29 | #include <QVector4D> |
30 | |
31 | #include <kwinconfig.h> |
32 | |
33 | namespace KWin |
34 | { |
35 | |
36 | class EffectWindow; |
37 | class EffectWindowImpl; |
38 | class WindowPaintData; |
39 | class GLTexture; |
40 | class GLRenderTarget; |
41 | class GLShader; |
42 | |
43 | class LanczosFilter |
44 | : public QObject |
45 | { |
46 | Q_OBJECT |
47 | |
48 | public: |
49 | explicit LanczosFilter(QObject* parent = 0); |
50 | ~LanczosFilter(); |
51 | void performPaint(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data); |
52 | |
53 | protected: |
54 | virtual void timerEvent(QTimerEvent*); |
55 | private: |
56 | void init(); |
57 | void updateOffscreenSurfaces(); |
58 | void setUniforms(); |
59 | void discardCacheTexture(EffectWindow *w); |
60 | |
61 | void createKernel(float delta, int *kernelSize); |
62 | void createOffsets(int count, float width, Qt::Orientation direction); |
63 | GLTexture *m_offscreenTex; |
64 | GLRenderTarget *m_offscreenTarget; |
65 | QBasicTimer m_timer; |
66 | bool m_inited; |
67 | QScopedPointer<GLShader> m_shader; |
68 | int m_uTexUnit; |
69 | int m_uOffsets; |
70 | int m_uKernel; |
71 | QVector2D m_offsets[16]; |
72 | QVector4D m_kernel[16]; |
73 | }; |
74 | |
75 | } // namespace |
76 | |
77 | #endif // KWIN_LANCZOSFILTER_P_H |
78 | |