1/********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5Copyright (C) 2010 by Fredrik Höglund <fredrik@kde.org>
6Copyright (C) 2010 Martin Gräßlin <mgraesslin@kde.org>
7
8This program is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 2 of the License, or
11(at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along 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
33namespace KWin
34{
35
36class EffectWindow;
37class EffectWindowImpl;
38class WindowPaintData;
39class GLTexture;
40class GLRenderTarget;
41class GLShader;
42
43class LanczosFilter
44 : public QObject
45{
46 Q_OBJECT
47
48public:
49 explicit LanczosFilter(QObject* parent = 0);
50 ~LanczosFilter();
51 void performPaint(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data);
52
53protected:
54 virtual void timerEvent(QTimerEvent*);
55private:
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