1 /* 2 SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 3 4 SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 7 #pragma once 8 9 #include "kwineffects.h" 10 11 namespace KWin 12 { 13 14 class DeformEffectPrivate; 15 16 /** 17 * The DeformEffect class is the base class for effects that paint deformed windows. 18 * 19 * Under the hood, the DeformEffect will paint the window into an offscreen texture, 20 * which will be mapped onto transformed window quad grid later on. 21 * 22 * The redirect() function must be called when the effect wants to transform a window. 23 * Once the effect is no longer interested in the window, the unredirect() function 24 * must be called. 25 * 26 * If a window is redirected into offscreen texture, the deform() function will be 27 * called with the window quads that can be mutated by the effect. The effect can 28 * sub-divide, remove, or transform the window quads. 29 */ 30 class KWINEFFECTS_EXPORT DeformEffect : public Effect 31 { 32 Q_OBJECT 33 34 public: 35 explicit DeformEffect(QObject *parent = nullptr); 36 ~DeformEffect() override; 37 38 static bool supported(); 39 40 private: 41 void drawWindow(EffectWindow *window, int mask, const QRegion& region, WindowPaintData &data) override; 42 43 protected: 44 /** 45 * This function must be called when the effect wants to animate the specified 46 * @a window. 47 */ 48 void redirect(EffectWindow *window); 49 /** 50 * This function must be called when the effect is done animating the specified 51 * @a window. The window will be automatically unredirected if it's deleted. 52 */ 53 void unredirect(EffectWindow *window); 54 55 /** 56 * Override this function to transform the window quad grid of the given window. 57 */ 58 virtual void deform(EffectWindow *window, int mask, WindowPaintData &data, WindowQuadList &quads); 59 60 private Q_SLOTS: 61 void handleWindowDamaged(EffectWindow *window); 62 void handleWindowDeleted(EffectWindow *window); 63 64 private: 65 void setupConnections(); 66 void destroyConnections(); 67 68 QScopedPointer<DeformEffectPrivate> d; 69 }; 70 71 } // namespace KWin 72