Warning, /sdk/licensedigger/autotests/testdata_conversionexamples/blur.h.origfile is written in an unsupported language. File is not indexed.
0001 /*
0002 * Copyright © 2010 Fredrik Höglund <fredrik@kde.org>
0003 *
0004 * This program is free software; you can redistribute it and/or modify
0005 * it under the terms of the GNU General Public License as published by
0006 * the Free Software Foundation; either version 2 of the License, or
0007 * (at your option) any later version.
0008 *
0009 * This program is distributed in the hope that it will be useful,
0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0012 * General Public License for more details.
0013 *
0014 * You should have received a copy of the GNU General Public License
0015 * along with this program; see the file COPYING. if not, write to
0016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017 * Boston, MA 02110-1301, USA.
0018 */
0019
0020 #ifndef BLUR_H
0021 #define BLUR_H
0022
0023 #include <kwineffects.h>
0024 #include <kwinglplatform.h>
0025 #include <kwinglutils.h>
0026
0027 #include <QVector>
0028 #include <QVector2D>
0029
0030 namespace KWin
0031 {
0032
0033 class BlurShader;
0034
0035 class BlurEffect : public KWin::Effect
0036 {
0037 Q_OBJECT
0038 Q_PROPERTY(int blurRadius READ blurRadius)
0039 Q_PROPERTY(bool cacheTexture READ isCacheTexture)
0040 public:
0041 BlurEffect();
0042 ~BlurEffect();
0043
0044 static bool supported();
0045 static bool enabledByDefault();
0046
0047 void reconfigure(ReconfigureFlags flags);
0048 void prePaintScreen(ScreenPrePaintData &data, int time);
0049 void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
0050 void drawWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data);
0051 void paintEffectFrame(EffectFrame *frame, QRegion region, double opacity, double frameOpacity);
0052
0053 // for dynamic setting extraction
0054 int blurRadius() const;
0055 bool isCacheTexture() const {
0056 return m_shouldCache;
0057 }
0058 virtual bool provides(Feature feature);
0059
0060 int requestedEffectChainPosition() const override {
0061 return 75;
0062 }
0063
0064 public Q_SLOTS:
0065 void slotWindowAdded(KWin::EffectWindow *w);
0066 void slotWindowDeleted(KWin::EffectWindow *w);
0067 void slotPropertyNotify(KWin::EffectWindow *w, long atom);
0068 void slotScreenGeometryChanged();
0069
0070 private:
0071 QRect expand(const QRect &rect) const;
0072 QRegion expand(const QRegion ®ion) const;
0073 QRegion blurRegion(const EffectWindow *w) const;
0074 bool shouldBlur(const EffectWindow *w, int mask, const WindowPaintData &data) const;
0075 void updateBlurRegion(EffectWindow *w) const;
0076 void doBlur(const QRegion &shape, const QRect &screen, const float opacity);
0077 void doCachedBlur(EffectWindow *w, const QRegion& region, const float opacity);
0078 void uploadRegion(QVector2D *&map, const QRegion ®ion);
0079 void uploadGeometry(GLVertexBuffer *vbo, const QRegion &horizontal, const QRegion &vertical);
0080
0081 private:
0082 BlurShader *shader;
0083 GLRenderTarget *target;
0084 GLTexture tex;
0085 long net_wm_blur_region;
0086 QRegion m_damagedArea; // keeps track of the area which has been damaged (from bottom to top)
0087 QRegion m_paintedArea; // actually painted area which is greater than m_damagedArea
0088 QRegion m_currentBlur; // keeps track of the currently blured area of non-caching windows(from bottom to top)
0089 bool m_shouldCache;
0090
0091 struct BlurWindowInfo {
0092 GLTexture blurredBackground; // keeps the horizontally blurred background
0093 QRegion damagedRegion;
0094 QPoint windowPos;
0095 bool dropCache;
0096 };
0097
0098 QHash< const EffectWindow*, BlurWindowInfo > windows;
0099 typedef QHash<const EffectWindow*, BlurWindowInfo>::iterator CacheEntry;
0100 };
0101
0102 inline
0103 bool BlurEffect::provides(Effect::Feature feature)
0104 {
0105 if (feature == Blur) {
0106 return true;
0107 }
0108 return KWin::Effect::provides(feature);
0109 }
0110
0111
0112 } // namespace KWin
0113
0114 #endif
0115