Drop explosion effect

It has been unmaintained and mostly broken for years.

BUG: 312176
FIXED-IN: 4.11
REVIEW: 110513
This commit is contained in:
Martin Gräßlin 2013-05-18 20:35:19 +02:00
parent 7e1386f415
commit ca5032e9d6
8 changed files with 0 additions and 526 deletions

View file

@ -146,7 +146,6 @@ include( screenshot/CMakeLists.txt )
if( NOT KWIN_MOBILE_EFFECTS )
include( coverswitch/CMakeLists.txt )
include( cube/CMakeLists.txt )
include( explosion/CMakeLists.txt )
include( flipswitch/CMakeLists.txt )
include( glide/CMakeLists.txt )
include( invert/CMakeLists.txt )

View file

@ -1,19 +0,0 @@
#######################################
# Effect
# Source files
set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
explosion/explosion.cpp
)
# .desktop files
install( FILES
explosion/explosion.desktop
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
# Data files
install( FILES
explosion/data/explosion-end.png
explosion/data/explosion-start.png
explosion/data/explosion.frag
DESTINATION ${DATA_INSTALL_DIR}/kwin )

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

View file

@ -1,53 +0,0 @@
uniform sampler2D sampler;
uniform sampler2D startOffsetTexture;
uniform sampler2D endOffsetTexture;
uniform float factor;
uniform float scale;
uniform vec2 windowSize;
const float regionTexSize = 512.0;
varying vec2 varyingTexCoords;
vec2 getOffset(sampler2D texture, vec2 pos)
{
return (texture2D(texture, pos / regionTexSize).xy - 0.5) / (5.0 / 256.0);
}
vec2 pix2tex( vec2 pix )
{
return pix/windowSize;
}
void main()
{
// Original (unscaled) position in pixels
// ### FIXME: Use a custom vertex shader that outputs the untransformed texcoords
vec2 origpos = varyingTexCoords * windowSize;
// Position in pixels on the scaled window
vec2 pos = origpos * scale;
// Start/end position of current region
vec2 rstart = origpos + getOffset(startOffsetTexture, origpos);
vec2 rend = origpos + getOffset(endOffsetTexture, origpos);
float alpha = texture2D(startOffsetTexture, origpos / regionTexSize).b;
// Distance from the start of the region
vec2 dist = pos - rstart*scale;
#if 0
// crashes kwin on nouveau
if(any(greaterThan(dist, rend-rstart)))
discard;//alpha = 0.0;
#endif
vec2 transformedtexcoord = pix2tex(rstart + dist);
vec3 tex = texture2D(sampler, transformedtexcoord).rgb;
#if 0
// ATM we ignore custom opacity values because Fade effect fades out the
// window which results in the explosion being way too quick. Once there's
// a way to suppress Fade effect when ExplosionEffect is active, we can
// use the custom opacity again
gl_FragColor = vec4(tex, (1.0 - factor*factor) * alpha * opacity);
#else
gl_FragColor = vec4(tex, (1.0 - factor*factor) * alpha);
#endif
}

View file

@ -1,213 +0,0 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "explosion.h"
#include <kwinglutils.h>
#include <kwinglplatform.h>
#include <QMatrix4x4>
#include <QVector2D>
#include <KDE/KGlobal>
#include <KStandardDirs>
#include <kdebug.h>
#include <math.h>
namespace KWin
{
KWIN_EFFECT(explosion, ExplosionEffect)
KWIN_EFFECT_SUPPORTED(explosion, ExplosionEffect::supported())
ExplosionEffect::ExplosionEffect() : Effect()
{
mShader = 0;
mStartOffsetTex = 0;
mEndOffsetTex = 0;
mActiveAnimations = 0;
mValid = true;
mInited = false;
connect(effects, SIGNAL(windowClosed(KWin::EffectWindow*)), this, SLOT(slotWindowClosed(KWin::EffectWindow*)));
connect(effects, SIGNAL(windowDeleted(KWin::EffectWindow*)), this, SLOT(slotWindowDeleted(KWin::EffectWindow*)));
}
ExplosionEffect::~ExplosionEffect()
{
delete mShader;
delete mStartOffsetTex;
delete mEndOffsetTex;
}
bool ExplosionEffect::supported()
{
return effects->compositingType() == OpenGL2Compositing;
}
bool ExplosionEffect::loadData()
{
mInited = true;
QString shadername("explosion");
const QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/explosion.frag");
QString starttexture = KGlobal::dirs()->findResource("data", "kwin/explosion-start.png");
QString endtexture = KGlobal::dirs()->findResource("data", "kwin/explosion-end.png");
if (starttexture.isEmpty() || endtexture.isEmpty()) {
kError(1212) << "Couldn't locate texture files" << endl;
return false;
}
mShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader);
if (!mShader->isValid()) {
kError(1212) << "The shader failed to load!" << endl;
return false;
} else {
ShaderBinder binder(mShader);
mShader->setUniform("startOffsetTexture", 4);
mShader->setUniform("endOffsetTexture", 5);
}
mStartOffsetTex = new GLTexture(starttexture);
mEndOffsetTex = new GLTexture(endtexture);
if (mStartOffsetTex->isNull() || mEndOffsetTex->isNull()) {
kError(1212) << "The textures failed to load!" << endl;
return false;
} else {
mStartOffsetTex->setFilter(GL_LINEAR);
mEndOffsetTex->setFilter(GL_LINEAR);
}
return true;
}
void ExplosionEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
if (mActiveAnimations > 0)
// We need to mark the screen as transformed. Otherwise the whole screen
// won't be repainted, resulting in artefacts
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
effects->prePaintScreen(data, time);
}
void ExplosionEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if (mWindows.contains(w)) {
if (mValid) {
mWindows[ w ] += time / animationTime(700.0); // complete change in 700ms
if (mWindows[ w ] < 1) {
data.setTranslucent();
data.setTransformed();
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
} else {
mWindows.remove(w);
w->unrefWindow();
mActiveAnimations--;
}
}
}
effects->prePaintWindow(w, data, time);
}
void ExplosionEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
// Make sure we have OpenGL compositing and the window is vidible and not a
// special window
bool useshader = (mValid && mWindows.contains(w));
if (useshader) {
double maxscaleadd = 1.5f;
double scale = 1 + maxscaleadd * mWindows[w];
data.setXScale(scale);
data.setYScale(scale);
data.translate(int(w->width() / 2 * (1 - scale)), int(w->height() / 2 * (1 - scale)));
data.multiplyOpacity(0.99); // Force blending
ShaderManager *manager = ShaderManager::instance();
GLShader *shader = manager->pushShader(ShaderManager::GenericShader);
QMatrix4x4 screenTransformation = shader->getUniformMatrix4x4("screenTransformation");
manager->popShader();
ShaderManager::instance()->pushShader(mShader);
mShader->setUniform("screenTransformation", screenTransformation);
mShader->setUniform("factor", (float)mWindows[w]);
mShader->setUniform("scale", (float)scale);
mShader->setUniform("windowSize", QVector2D(w->width(), w->height()));
glActiveTexture(GL_TEXTURE4);
mStartOffsetTex->bind();
glActiveTexture(GL_TEXTURE5);
mEndOffsetTex->bind();
glActiveTexture(GL_TEXTURE0);
data.shader = mShader;
}
// Call the next effect.
effects->paintWindow(w, mask, region, data);
if (useshader) {
ShaderManager::instance()->popShader();
glActiveTexture(GL_TEXTURE4);
mStartOffsetTex->unbind();
glActiveTexture(GL_TEXTURE5);
mEndOffsetTex->unbind();
glActiveTexture(GL_TEXTURE0);
}
}
void ExplosionEffect::postPaintScreen()
{
if (mActiveAnimations > 0)
effects->addRepaintFull();
// Call the next effect.
effects->postPaintScreen();
}
void ExplosionEffect::slotWindowClosed(EffectWindow* c)
{
const void* e = c->data(WindowClosedGrabRole).value<void*>();
if (e && e != this)
return;
if (c->isOnCurrentDesktop() && !c->isMinimized()) {
if (mValid && !mInited)
mValid = loadData();
if (!mValid) {
// don't add to list as we cannot animate this window;
return;
}
mWindows[ c ] = 0; // count up to 1
c->addRepaintFull();
c->refWindow();
mActiveAnimations++;
}
}
void ExplosionEffect::slotWindowDeleted(EffectWindow* c)
{
mWindows.remove(c);
}
bool ExplosionEffect::isActive() const
{
return mActiveAnimations > 0;
}
} // namespace

View file

@ -1,167 +0,0 @@
[Desktop Entry]
Name=Explosion
Name[af]=Ontploffing
Name[ar]=انفجار
Name[ast]=Españíu
Name[be@latin]=Vybuch
Name[bg]=Експлозия
Name[bn]=ি
Name[br]=Tarzhad
Name[bs]=Eksplozija
Name[ca]=Explosió
Name[ca@valencia]=Explosió
Name[cs]=Exploze
Name[csb]=Wëbùch
Name[da]=Eksplosion
Name[de]=Explosion
Name[el]=Έκρηξη
Name[en_GB]=Explosion
Name[eo]=Eksplodo
Name[es]=Explosión
Name[et]=Plahvatus
Name[eu]=Leherketa
Name[fa]=انفجار
Name[fi]=Räjähdys
Name[fr]=Explosion
Name[fy]=Ekplosy
Name[ga]=Explosion
Name[gl]=Explosión
Name[gu]=
Name[he]=התפוצצות
Name[hi]=ि
Name[hne]=ि
Name[hr]=Eksplozija
Name[hu]=Robbanás
Name[ia]=Explosion
Name[id]=Ledakan
Name[is]=Sprenging
Name[it]=Esplosione
Name[ja]=
Name[kk]=Жарылыс
Name[km]=
Name[kn]=
Name[ko]=
Name[ku]=Teqîn
Name[lt]=Sprogimas
Name[lv]=Eksplozija
Name[mai]=ि
Name[mk]=Експлозија
Name[ml]=ിി
Name[mr]=ि
Name[nb]=Eksplosjon
Name[nds]=Exploschoon
Name[ne]=ि
Name[nl]=Explosie
Name[nn]=Eksplosjon
Name[pa]=
Name[pl]=Wybuch
Name[pt]=Explosão
Name[pt_BR]=Explosão
Name[ro]=Explozie
Name[ru]=Взрыв
Name[se]=Eksplošuvdna
Name[si]=
Name[sk]=Explózia
Name[sl]=Eksplozija
Name[sr]=Експлозија
Name[sr@ijekavian]=Експлозија
Name[sr@ijekavianlatin]=Eksplozija
Name[sr@latin]=Eksplozija
Name[sv]=Explosion
Name[ta]=ி
Name[te]=
Name[tg]=Таркиш
Name[th]=
Name[tr]=Patlama
Name[ug]=پارتلاش شەكلى
Name[uk]=Вибух
Name[vi]=N bung
Name[wa]=Esplôzaedje
Name[x-test]=xxExplosionxx
Name[zh_CN]=
Name[zh_TW]=
Icon=preferences-system-windows-effect-explosion
Comment=Make windows explode when they are closed
Comment[ar]=يفجّر النافذة عند إغلاقها
Comment[ast]=Fai que les ventanes españen al zarrales
Comment[be@latin]=Vokny začyniajucca z vybucham.
Comment[bg]=Създава ефект на експлозия при затваряне на прозорците
Comment[bs]=Prozor eksplodiraju kada se zatvore
Comment[ca]=Provoca l'explosió de les finestres quan es tanquen
Comment[ca@valencia]=Provoca l'explosió de les finestres quan es tanquen
Comment[cs]=Nechá okna explodovat, pokud jsou uzavřena
Comment[da]=Få vinduer til at eksplodere når de lukkes
Comment[de]=Lässt Fenster beim Schließen explodieren.
Comment[el]=Έκρηξη των παραθύρων κατά το κλείσιμό τους
Comment[en_GB]=Make windows explode when they are closed
Comment[eo]=Eksplodigas la fenestrojn dum ili fermiĝas
Comment[es]=Hace que las ventanas exploten al cerrarlas
Comment[et]=Paneb aknad sulgemisel plahvatama
Comment[eu]=Leihoak ixtean lehertzen ditu
Comment[fi]=Räjäyttää ikkunat suljettaessa
Comment[fr]=Fait exploser les fenêtres lorsqu'elle sont fermées
Comment[fy]=Lit finsters eksplodearje as se sluten wurde
Comment[ga]=Leis seo, pléascfaidh fuinneoga nuair a dhúntar iad
Comment[gl]=Estoupa as xanelas cando se pechan
Comment[gu]= િ
Comment[he]=מפוצץ חלונות בעת סגירתם
Comment[hi]=ि ि ि
Comment[hne]=ि ि
Comment[hr]=Prozori eksplodiraju kad ih se zatvori
Comment[hu]=Bezáráskor az ablakok "felrobbannak"
Comment[ia]=Face que fenestras explode quando los es claudite
Comment[id]=Buat jendela meledak ketika jendela ditutup
Comment[is]=Lætur glugga springa í tætlur þegar þeim er lokað
Comment[it]=Fai esplodere le finestre alla chiusura
Comment[ja]=
Comment[kk]=Жабылатын терезе жарылып кетіріледі
Comment[km]=
Comment[kn]=ಿಿ ಿ ಿಿ
Comment[ko]=
Comment[lt]=Išsprogdina langus juos užveriant
Comment[lv]=Liek logiem eksplodēt, kad tos aizver
Comment[mk]=Прави прозорците да експлодираат кога се затвораат
Comment[ml]= ിി.
Comment[mr]= ि
Comment[nb]=Gjør at vinduer som lukkes, eksploderer
Comment[nds]=Finstern bi't Tomaken exploderen laten
Comment[nl]=Laat vensters uit elkaar spatten als ze worden gesloten
Comment[nn]=Eksploderer vindauge når dei vert lukka
Comment[pa]= ਿ
Comment[pl]=Wybuchanie okien przy ich zamykaniu
Comment[pt]=Fazer as janelas explodir ao serem fechadas
Comment[pt_BR]=Faz as janelas explodirem quando são fechadas
Comment[ro]=Face ferestrele să explodeze cînd sînt închise
Comment[ru]=Эффект взрыва окна при его закрытии
Comment[si]=
Comment[sk]=Okná explodujú pri zatvorení
Comment[sl]=Ko se okna zaprejo, eksplodirajo
Comment[sr]=Прозор експлодирају када се затворе
Comment[sr@ijekavian]=Прозор експлодирају када се затворе
Comment[sr@ijekavianlatin]=Prozor eksplodiraju kada se zatvore
Comment[sr@latin]=Prozor eksplodiraju kada se zatvore
Comment[sv]=Gör att fönster exploderar när de stängs
Comment[ta]=Make windows explode when they are closed
Comment[th]=
Comment[tr]=Kapatılırken pencerelere patlama efekti ver
Comment[ug]=كۆزنەك يېپىلغاندا پارتلاش ئۈنۈمىنى كۆرسەت
Comment[uk]=Вибух вікон після закриття
Comment[vi]=Làm ca s n bung khi chúng đưc đóng
Comment[wa]=Fé peter les fniesses cwand ele sont cloyowes
Comment[x-test]=xxMake windows explode when they are closedxx
Comment[zh_CN]=使
Comment[zh_TW]=
Type=Service
X-KDE-ServiceTypes=KWin/Effect
X-KDE-PluginInfo-Author=Rivo Laks
X-KDE-PluginInfo-Email=rivolaks@hot.ee
X-KDE-PluginInfo-Name=kwin4_effect_explosion
X-KDE-PluginInfo-Version=0.1.0
X-KDE-PluginInfo-Category=Appearance
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=false
X-KDE-Library=kwin4_effect_builtins
X-KDE-Ordering=70
X-KWin-Requires-OpenGL2=true

View file

@ -1,73 +0,0 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef KWIN_EXPLOSIONEFFECT_H
#define KWIN_EXPLOSIONEFFECT_H
// Include with base class for effects.
#include <kwineffects.h>
#include <QMap>
namespace KWin
{
class GLShader;
class GLTexture;
/**
* Makes windows explode into small pieces when they're closed
**/
class ExplosionEffect
: public Effect
{
Q_OBJECT
public:
ExplosionEffect();
~ExplosionEffect();
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintScreen();
virtual bool isActive() const;
static bool supported();
public Q_SLOTS:
void slotWindowClosed(KWin::EffectWindow *c);
void slotWindowDeleted(KWin::EffectWindow *w);
protected:
bool loadData();
private:
GLShader* mShader;
GLTexture* mStartOffsetTex;
GLTexture* mEndOffsetTex;
QMap< const EffectWindow*, double > mWindows;
int mActiveAnimations;
bool mValid;
bool mInited;
};
} // namespace
#endif