Rename DeformEffect to OffscreenEffect

Originally, DeformEffect was meant to be used in effect that deform
windows, but its usage has become wider than anticipated. This change
renames the DeformEffect to OffscreenEffect to accommodate for that.
This commit is contained in:
Vlad Zahorodnii 2022-06-10 20:09:31 +03:00
parent ef1d97ac86
commit f9c20bb83e
13 changed files with 66 additions and 67 deletions

View file

@ -16,7 +16,7 @@
namespace KWin
{
BlendChanges::BlendChanges()
: DeformEffect()
: OffscreenEffect()
{
QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/KWin/BlendChanges"),
QStringLiteral("org.kde.KWin.BlendChanges"),
@ -67,11 +67,11 @@ void BlendChanges::drawWindow(EffectWindow *window, int mask, const QRegion &reg
}
// then the old on top, it works better than changing both alphas with the current blend mode
if (m_state != Off) {
DeformEffect::drawWindow(window, mask, region, data);
OffscreenEffect::drawWindow(window, mask, region, data);
}
}
void BlendChanges::deform(EffectWindow *window, int mask, WindowPaintData &data, WindowQuadList &quads)
void BlendChanges::apply(EffectWindow *window, int mask, WindowPaintData &data, WindowQuadList &quads)
{
Q_UNUSED(window)
Q_UNUSED(mask)

View file

@ -8,13 +8,13 @@
*/
#pragma once
#include <chrono>
#include <kwindeformeffect.h>
#include <kwinoffscreeneffect.h>
#include <kwineffects.h>
namespace KWin
{
class BlendChanges : public DeformEffect
class BlendChanges : public OffscreenEffect
{
Q_OBJECT
@ -28,7 +28,7 @@ public:
void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override;
void postPaintScreen() override;
void drawWindow(EffectWindow *window, int mask, const QRegion &region, WindowPaintData &data) override;
void deform(EffectWindow *window, int mask, WindowPaintData &data, WindowQuadList &quads) override;
void apply(EffectWindow *window, int mask, WindowPaintData &data, WindowQuadList &quads) override;
bool isActive() const override;
public Q_SLOTS:

View file

@ -20,7 +20,7 @@ namespace KWin
bool FallApartEffect::supported()
{
return DeformEffect::supported() && effects->animationsSupported();
return OffscreenEffect::supported() && effects->animationsSupported();
}
FallApartEffect::FallApartEffect()
@ -62,7 +62,7 @@ void FallApartEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data,
effects->prePaintWindow(w, data, presentTime);
}
void FallApartEffect::deform(EffectWindow *w, int mask, WindowPaintData &data, WindowQuadList &quads)
void FallApartEffect::apply(EffectWindow *w, int mask, WindowPaintData &data, WindowQuadList &quads)
{
Q_UNUSED(w)
Q_UNUSED(mask)

View file

@ -10,7 +10,7 @@
#ifndef KWIN_FALLAPART_H
#define KWIN_FALLAPART_H
#include <kwindeformeffect.h>
#include <kwinoffscreeneffect.h>
namespace KWin
{
@ -23,7 +23,7 @@ struct FallApartAnimation
qreal progress = 0;
};
class FallApartEffect : public DeformEffect
class FallApartEffect : public OffscreenEffect
{
Q_OBJECT
Q_PROPERTY(int blockSize READ configuredBlockSize)
@ -49,7 +49,7 @@ public:
static bool supported();
protected:
void deform(EffectWindow *w, int mask, WindowPaintData &data, WindowQuadList &quads) override;
void apply(EffectWindow *w, int mask, WindowPaintData &data, WindowQuadList &quads) override;
public Q_SLOTS:
void slotWindowClosed(KWin::EffectWindow *c);

View file

@ -27,7 +27,7 @@ MagicLampEffect::MagicLampEffect()
bool MagicLampEffect::supported()
{
return DeformEffect::supported() && effects->animationsSupported();
return OffscreenEffect::supported() && effects->animationsSupported();
}
void MagicLampEffect::reconfigure(ReconfigureFlags)
@ -69,7 +69,7 @@ void MagicLampEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data,
effects->prePaintWindow(w, data, presentTime);
}
void MagicLampEffect::deform(EffectWindow *w, int mask, WindowPaintData &data, WindowQuadList &quads)
void MagicLampEffect::apply(EffectWindow *w, int mask, WindowPaintData &data, WindowQuadList &quads)
{
Q_UNUSED(mask)
Q_UNUSED(data)

View file

@ -10,7 +10,7 @@
#ifndef KWIN_MAGICLAMP_H
#define KWIN_MAGICLAMP_H
#include <kwindeformeffect.h>
#include <kwinoffscreeneffect.h>
namespace KWin
{
@ -21,7 +21,7 @@ struct MagicLampAnimation
TimeLine timeLine;
};
class MagicLampEffect : public DeformEffect
class MagicLampEffect : public OffscreenEffect
{
Q_OBJECT
@ -42,7 +42,7 @@ public:
static bool supported();
protected:
void deform(EffectWindow *window, int mask, WindowPaintData &data, WindowQuadList &quads) override;
void apply(EffectWindow *window, int mask, WindowPaintData &data, WindowQuadList &quads) override;
public Q_SLOTS:
void slotWindowDeleted(KWin::EffectWindow *w);

View file

@ -190,7 +190,7 @@ void WobblyWindowsEffect::reconfigure(ReconfigureFlags)
bool WobblyWindowsEffect::supported()
{
return DeformEffect::supported() && effects->animationsSupported();
return OffscreenEffect::supported() && effects->animationsSupported();
}
void WobblyWindowsEffect::setParameterSet(const ParameterSet &pset)
@ -267,7 +267,7 @@ void WobblyWindowsEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &da
effects->prePaintWindow(w, data, presentTime);
}
void WobblyWindowsEffect::deform(EffectWindow *w, int mask, WindowPaintData &data, WindowQuadList &quads)
void WobblyWindowsEffect::apply(EffectWindow *w, int mask, WindowPaintData &data, WindowQuadList &quads)
{
if (!(mask & PAINT_SCREEN_TRANSFORMED) && windows.contains(w)) {
quads = quads.makeRegularGrid(m_xTesselation, m_yTesselation);

View file

@ -11,7 +11,7 @@
#define KWIN_WOBBLYWINDOWS_H
// Include with base class for effects.
#include <kwindeformeffect.h>
#include <kwinoffscreeneffect.h>
namespace KWin
{
@ -21,7 +21,7 @@ struct ParameterSet;
/**
* Effect which wobble windows
*/
class WobblyWindowsEffect : public DeformEffect
class WobblyWindowsEffect : public OffscreenEffect
{
Q_OBJECT
Q_PROPERTY(qreal stiffness READ stiffness)
@ -129,7 +129,7 @@ public:
}
protected:
void deform(EffectWindow *w, int mask, WindowPaintData &data, WindowQuadList &quads) override;
void apply(EffectWindow *w, int mask, WindowPaintData &data, WindowQuadList &quads) override;
public Q_SLOTS:
void slotWindowStartUserMovedResized(KWin::EffectWindow *w);

View file

@ -12,8 +12,8 @@ ecm_setup_version(${PROJECT_VERSION}
set(kwin_EFFECTSLIB_SRCS
anidata.cpp
kwinanimationeffect.cpp
kwindeformeffect.cpp
kwineffects.cpp
kwinoffscreeneffect.cpp
kwinoffscreenquickview.cpp
kwinquickeffect.cpp
logging.cpp
@ -70,13 +70,13 @@ install(FILES
${CMAKE_CURRENT_BINARY_DIR}/kwineffects_export.h
${CMAKE_CURRENT_BINARY_DIR}/kwinglutils_export.h
kwinanimationeffect.h
kwindeformeffect.h
kwineffects.h
kwinglobals.h
kwinglplatform.h
kwingltexture.h
kwinglutils.h
kwinglutils_funcs.h
kwinoffscreeneffect.h
kwinoffscreenquickview.h
kwinquickeffect.h
DESTINATION ${KDE_INSTALL_INCLUDEDIR} COMPONENT Devel)

View file

@ -282,7 +282,7 @@ quint64 AnimationEffect::p_animate(EffectWindow *w, Attribute a, uint meta, int
triggerRepaint();
}
if (shader) {
DeformEffect::redirect(w);
OffscreenEffect::redirect(w);
}
return ret_id;
}

View file

@ -14,7 +14,7 @@
#include <QEasingCurve>
#include <QElapsedTimer>
#include <QtMath>
#include <kwindeformeffect.h>
#include <kwinoffscreeneffect.h>
#include <kwineffects_export.h>
namespace KWin
@ -191,7 +191,7 @@ class AnimationEffectPrivate;
*
* @since 4.8
*/
class KWINEFFECTS_EXPORT AnimationEffect : public DeformEffect
class KWINEFFECTS_EXPORT AnimationEffect : public OffscreenEffect
{
Q_OBJECT

View file

@ -4,14 +4,14 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwindeformeffect.h"
#include "kwinoffscreeneffect.h"
#include "kwingltexture.h"
#include "kwinglutils.h"
namespace KWin
{
struct DeformOffscreenData
struct OffscreenData
{
QScopedPointer<GLTexture> texture;
QScopedPointer<GLFramebuffer> fbo;
@ -19,49 +19,49 @@ struct DeformOffscreenData
GLShader *shader = nullptr;
};
class DeformEffectPrivate
class OffscreenEffectPrivate
{
public:
QHash<EffectWindow *, DeformOffscreenData *> windows;
QHash<EffectWindow *, OffscreenData *> windows;
QMetaObject::Connection windowDamagedConnection;
QMetaObject::Connection windowDeletedConnection;
void paint(EffectWindow *window, GLTexture *texture, const QRegion &region,
const WindowPaintData &data, const WindowQuadList &quads, GLShader *offscreenShader);
GLTexture *maybeRender(EffectWindow *window, DeformOffscreenData *offscreenData);
GLTexture *maybeRender(EffectWindow *window, OffscreenData *offscreenData);
bool live = true;
};
DeformEffect::DeformEffect(QObject *parent)
OffscreenEffect::OffscreenEffect(QObject *parent)
: Effect(parent)
, d(new DeformEffectPrivate)
, d(new OffscreenEffectPrivate)
{
}
DeformEffect::~DeformEffect()
OffscreenEffect::~OffscreenEffect()
{
qDeleteAll(d->windows);
}
bool DeformEffect::supported()
bool OffscreenEffect::supported()
{
return effects->isOpenGLCompositing();
}
void DeformEffect::setLive(bool live)
void OffscreenEffect::setLive(bool live)
{
Q_ASSERT(d->windows.isEmpty());
d->live = live;
}
void DeformEffect::redirect(EffectWindow *window)
void OffscreenEffect::redirect(EffectWindow *window)
{
DeformOffscreenData *&offscreenData = d->windows[window];
OffscreenData *&offscreenData = d->windows[window];
if (offscreenData) {
return;
}
offscreenData = new DeformOffscreenData;
offscreenData = new OffscreenData;
if (d->windows.count() == 1) {
setupConnections();
@ -73,7 +73,7 @@ void DeformEffect::redirect(EffectWindow *window)
}
}
void DeformEffect::unredirect(EffectWindow *window)
void OffscreenEffect::unredirect(EffectWindow *window)
{
delete d->windows.take(window);
if (d->windows.isEmpty()) {
@ -81,7 +81,7 @@ void DeformEffect::unredirect(EffectWindow *window)
}
}
void DeformEffect::deform(EffectWindow *window, int mask, WindowPaintData &data, WindowQuadList &quads)
void OffscreenEffect::apply(EffectWindow *window, int mask, WindowPaintData &data, WindowQuadList &quads)
{
Q_UNUSED(window)
Q_UNUSED(mask)
@ -89,7 +89,7 @@ void DeformEffect::deform(EffectWindow *window, int mask, WindowPaintData &data,
Q_UNUSED(quads)
}
GLTexture *DeformEffectPrivate::maybeRender(EffectWindow *window, DeformOffscreenData *offscreenData)
GLTexture *OffscreenEffectPrivate::maybeRender(EffectWindow *window, OffscreenData *offscreenData)
{
const QRect geometry = window->expandedGeometry();
QSize textureSize = geometry.size();
@ -130,7 +130,7 @@ GLTexture *DeformEffectPrivate::maybeRender(EffectWindow *window, DeformOffscree
return offscreenData->texture.data();
}
void DeformEffectPrivate::paint(EffectWindow *window, GLTexture *texture, const QRegion &region,
void OffscreenEffectPrivate::paint(EffectWindow *window, GLTexture *texture, const QRegion &region,
const WindowPaintData &data, const WindowQuadList &quads, GLShader *offscreenShader)
{
GLShader *shader = offscreenShader ? offscreenShader : ShaderManager::instance()->shader(ShaderTrait::MapTexture | ShaderTrait::Modulate | ShaderTrait::AdjustSaturation);
@ -187,9 +187,9 @@ void DeformEffectPrivate::paint(EffectWindow *window, GLTexture *texture, const
vbo->unbindArrays();
}
void DeformEffect::drawWindow(EffectWindow *window, int mask, const QRegion &region, WindowPaintData &data)
void OffscreenEffect::drawWindow(EffectWindow *window, int mask, const QRegion &region, WindowPaintData &data)
{
DeformOffscreenData *offscreenData = d->windows.value(window);
OffscreenData *offscreenData = d->windows.value(window);
if (!offscreenData) {
effects->drawWindow(window, mask, region, data);
return;
@ -208,36 +208,36 @@ void DeformEffect::drawWindow(EffectWindow *window, int mask, const QRegion &reg
WindowQuadList quads;
quads.append(quad);
deform(window, mask, data, quads);
apply(window, mask, data, quads);
GLTexture *texture = d->maybeRender(window, offscreenData);
d->paint(window, texture, region, data, quads, offscreenData->shader);
}
void DeformEffect::handleWindowDamaged(EffectWindow *window)
void OffscreenEffect::handleWindowDamaged(EffectWindow *window)
{
DeformOffscreenData *offscreenData = d->windows.value(window);
OffscreenData *offscreenData = d->windows.value(window);
if (offscreenData) {
offscreenData->isDirty = true;
}
}
void DeformEffect::handleWindowDeleted(EffectWindow *window)
void OffscreenEffect::handleWindowDeleted(EffectWindow *window)
{
unredirect(window);
}
void DeformEffect::setupConnections()
void OffscreenEffect::setupConnections()
{
if (d->live) {
d->windowDamagedConnection =
connect(effects, &EffectsHandler::windowDamaged, this, &DeformEffect::handleWindowDamaged);
connect(effects, &EffectsHandler::windowDamaged, this, &OffscreenEffect::handleWindowDamaged);
}
d->windowDeletedConnection =
connect(effects, &EffectsHandler::windowDeleted, this, &DeformEffect::handleWindowDeleted);
connect(effects, &EffectsHandler::windowDeleted, this, &OffscreenEffect::handleWindowDeleted);
}
void DeformEffect::destroyConnections()
void OffscreenEffect::destroyConnections()
{
disconnect(d->windowDamagedConnection);
disconnect(d->windowDeletedConnection);
@ -246,9 +246,9 @@ void DeformEffect::destroyConnections()
d->windowDeletedConnection = {};
}
void DeformEffect::setShader(EffectWindow *window, GLShader *shader)
void OffscreenEffect::setShader(EffectWindow *window, GLShader *shader)
{
DeformOffscreenData *offscreenData = d->windows.value(window);
OffscreenData *offscreenData = d->windows.value(window);
if (offscreenData) {
offscreenData->shader = shader;
}

View file

@ -11,29 +11,28 @@
namespace KWin
{
class DeformEffectPrivate;
class OffscreenEffectPrivate;
/**
* The DeformEffect class is the base class for effects that paint deformed windows.
* The OffscreenEffect class is the base class for effects that paint deformed windows.
*
* Under the hood, the DeformEffect will paint the window into an offscreen texture,
* which will be mapped onto transformed window quad grid later on.
* Under the hood, the OffscreenEffect will paint the window into an offscreen texture
* and the offscreen texture will be transformed afterwards.
*
* The redirect() function must be called when the effect wants to transform a window.
* Once the effect is no longer interested in the window, the unredirect() function
* must be called.
*
* If a window is redirected into offscreen texture, the deform() function will be
* called with the window quads that can be mutated by the effect. The effect can
* sub-divide, remove, or transform the window quads.
* called to transform the offscreen texture.
*/
class KWINEFFECTS_EXPORT DeformEffect : public Effect
class KWINEFFECTS_EXPORT OffscreenEffect : public Effect
{
Q_OBJECT
public:
explicit DeformEffect(QObject *parent = nullptr);
~DeformEffect() override;
explicit OffscreenEffect(QObject *parent = nullptr);
~OffscreenEffect() override;
static bool supported();
@ -59,9 +58,9 @@ protected:
void unredirect(EffectWindow *window);
/**
* Override this function to transform the window quad grid of the given window.
* Override this function to transform the window.
*/
virtual void deform(EffectWindow *window, int mask, WindowPaintData &data, WindowQuadList &quads);
virtual void apply(EffectWindow *window, int mask, WindowPaintData &data, WindowQuadList &quads);
/**
* Allows to specify a @p shader to draw the redirected texture for @p window.
@ -78,7 +77,7 @@ private:
void setupConnections();
void destroyConnections();
QScopedPointer<DeformEffectPrivate> d;
QScopedPointer<OffscreenEffectPrivate> d;
};
} // namespace KWin