[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/kwin_composite
From:       Rivo Laks <rivolaks () hot ! ee>
Date:       2007-04-21 12:57:16
Message-ID: 1177160236.230010.6756.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 656456 by rivol:

Port ExplosionEffect to plugin system

 M  +7 -0      effects.cpp  
 M  +1 -0      effects.h  
 M  +2 -0      effects/CMakeLists.txt  
 A             effects/explosion.desktop  
 M  +26 -23    effects/explosioneffect.cpp  
 M  +5 -1      effects/explosioneffect.h  
 M  +2 -0      lib/kwineffects.h  


--- branches/work/kwin_composite/effects.cpp #656455:656456
@@ -1017,6 +1017,13 @@
     abort(); // TODO
     }
 
+    void EffectWindowImpl::setShader(GLShader* shader)
+    {
+    if( SceneOpenGL::Window* w = dynamic_cast< SceneOpenGL::Window* >( sceneWindow()))
+        return w->setShader(shader);
+    abort(); // TODO
+    }
+
 EffectWindow* effectWindow( Toplevel* w )
     {
     EffectWindowImpl* ret = w->effectWindow();
--- branches/work/kwin_composite/effects.h #656455:656456
@@ -178,6 +178,7 @@
         virtual QVector<Vertex>& vertices();
         virtual void requestVertexGrid(int maxquadsize);
         virtual void markVerticesDirty();
+        virtual void setShader(GLShader* shader);
 
         const Toplevel* window() const;
         Toplevel* window();
--- branches/work/kwin_composite/effects/CMakeLists.txt #656455:656456
@@ -39,6 +39,7 @@
 
 if(OPENGL_FOUND)
     SET(kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
+        explosioneffect.cpp
         magnifier.cpp
         shadow.cpp
         trackmouse.cpp
@@ -50,6 +51,7 @@
         )
 
     install( FILES
+        explosion.desktop
         magnifier.desktop
         shadow.desktop
         trackmouse.desktop
--- branches/work/kwin_composite/effects/explosioneffect.cpp #656455:656456
@@ -11,14 +11,11 @@
 
 #include "explosioneffect.h"
 
-#include <scene_opengl.h>
-#include <workspace.h>
-#include <client.h>
-#include <glutils.h>
-#include <deleted.h>
+#include <kwinglutils.h>
 
 #include <QString>
 #include <KStandardDirs>
+#include <kdebug.h>
 
 #include <math.h>
 
@@ -26,6 +23,9 @@
 namespace KWin
 {
 
+KWIN_EFFECT( Explosion, ExplosionEffect );
+KWIN_EFFECT_SUPPORTED( Explosion, ExplosionEffect::supported() );
+
 ExplosionEffect::ExplosionEffect() : Effect()
     {
     mActiveAnimations = 0;
@@ -33,6 +33,12 @@
     mInited = false;
     }
 
+    bool ExplosionEffect::supported()
+    {
+    return GLShader::fragmentShaderSupported() &&
+            (effects->compositingType() == OpenGLCompositing);
+    }
+
 bool ExplosionEffect::loadData()
 {
     mInited = true;
@@ -88,7 +94,7 @@
     if( mActiveAnimations > 0 )
         // We need to mark the screen as transformed. Otherwise the whole screen
         //  won't be repainted, resulting in artefacts
-        *mask |= Scene::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
+        *mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
 
     effects->prePaintScreen(mask, region, time);
     }
@@ -97,22 +103,21 @@
     {
     if( mWindows.contains( w ))
         {
-        SceneOpenGL::Window* glwin = dynamic_cast< SceneOpenGL::Window* >( w->sceneWindow() );
-        if( mValid && glwin && !mInited )
+        if( mValid && !mInited )
             mValid = loadData();
         if( mValid )
             {
             mWindows[ w  ] += time / 700.0; // complete change in 700ms
             if( mWindows[ w  ] < 1 )
                 {
-                *mask |= Scene::PAINT_WINDOW_TRANSLUCENT | Scene::PAINT_WINDOW_TRANSFORMED;
-                *mask &= ~Scene::PAINT_WINDOW_OPAQUE;
-                w->enablePainting( Scene::Window::PAINT_DISABLED_BY_DELETE );
+                *mask |= PAINT_WINDOW_TRANSLUCENT | PAINT_WINDOW_TRANSFORMED;
+                *mask &= ~PAINT_WINDOW_OPAQUE;
+                w->enablePainting( EffectWindow::PAINT_DISABLED_BY_DELETE );
                 }
             else
                 {
                 mWindows.remove( w );
-                static_cast< Deleted* >( w->window())->unrefWindow();
+                w->unrefWindow();
                 mActiveAnimations--;
                 }
             }
@@ -125,16 +130,15 @@
     {
     // Make sure we have OpenGL compositing and the window is vidible and not a
     //  special window
-    SceneOpenGL::Window* glwin = dynamic_cast< SceneOpenGL::Window* >( w->sceneWindow() );
-    bool useshader = ( mValid && glwin && mWindows.contains( w ) );
+    bool useshader = ( mValid && mWindows.contains( w ) );
     if( useshader )
         {
         float maxscaleadd = 1.5f;
         float scale = 1 + maxscaleadd*mWindows[w];
         data.xScale = scale;
         data.yScale = scale;
-        data.xTranslate += int( w->window()->width() / 2 * ( 1 - scale ));
-        data.yTranslate += int( w->window()->height() / 2 * ( 1 - scale ));
+        data.xTranslate += int( w->width() / 2 * ( 1 - scale ));
+        data.yTranslate += int( w->height() / 2 * ( 1 - scale ));
         data.opacity *= 0.99;  // Force blending
         mShader->bind();
         mShader->setUniform("factor", (float)mWindows[w]);
@@ -144,7 +148,7 @@
         glActiveTexture(GL_TEXTURE5);
         mEndOffsetTex->bind();
         glActiveTexture(GL_TEXTURE0);
-        glwin->setShader(mShader);
+        w->setShader(mShader);
         }
 
     // Call the next effect.
@@ -164,7 +168,7 @@
 void ExplosionEffect::postPaintScreen()
     {
     if( mActiveAnimations > 0 )
-        workspace()->addRepaintFull();
+        effects->addRepaintFull();
 
     // Call the next effect.
     effects->postPaintScreen();
@@ -172,19 +176,18 @@
 
 void ExplosionEffect::windowClosed( EffectWindow* c )
     {
-    Client* cc = dynamic_cast< Client* >( c->window());
-    if( cc == NULL || (cc->isOnCurrentDesktop() && !cc->isMinimized()))
+    if( c->isOnCurrentDesktop() && !c->isMinimized())
         {
         mWindows[ c ] = 0; // count up to 1
-        c->window()->addRepaintFull();
-        static_cast< Deleted* >( c->window())->refWindow();
+        c->addRepaintFull();
+        c->refWindow();
         mActiveAnimations++;
         }
     }
 
 void ExplosionEffect::windowDeleted( EffectWindow* c )
     {
-        mWindows.remove( c );
+    mWindows.remove( c );
     }
 
 } // namespace
--- branches/work/kwin_composite/effects/explosioneffect.h #656455:656456
@@ -12,8 +12,10 @@
 #define KWIN_EXPLOSIONEFFECT_H
 
 // Include with base class for effects.
-#include <effects.h>
+#include <kwineffects.h>
 
+#include <QMap>
+
 namespace KWin
 {
 
@@ -37,7 +39,9 @@
         virtual void windowClosed( EffectWindow* c );
         virtual void windowDeleted( EffectWindow* c );
 
+        static bool supported();
 
+
     protected:
         bool loadData();
 
--- branches/work/kwin_composite/lib/kwineffects.h #656455:656456
@@ -37,6 +37,7 @@
 class Effect;
 class Vertex;
 class GLRenderTarget;
+class GLShader;
 
 typedef QPair< QString, Effect* > EffectPair;
 typedef QPair< Effect*, Window > InputWindowPair;
@@ -322,6 +323,7 @@
         // Marks vertices of the window as dirty. Call this if you change
         //  position of the vertices
         virtual void markVerticesDirty() = 0;
+        virtual void setShader(GLShader* shader) = 0;
     };
 
 class KWIN_EXPORT EffectWindowGroup
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic