Support having multiple rendertarget-using effects active at once

svn path=/branches/work/kwin_composite/; revision=656210
This commit is contained in:
Rivo Laks 2007-04-20 15:53:30 +00:00
parent 1adecf7737
commit 7250a8edcd
5 changed files with 38 additions and 4 deletions

View file

@ -16,6 +16,7 @@ License. See the file "COPYING" for the exact licensing terms.
#include "scene_xrender.h"
#include "scene_opengl.h"
#include "workspace.h"
#include "kwinglutils.h"
#include <QFile>
@ -393,6 +394,27 @@ EffectWindow* EffectsHandlerImpl::currentTabBoxWindow() const
return NULL;
}
void EffectsHandlerImpl::pushRenderTarget(GLRenderTarget* target)
{
#ifdef HAVE_OPENGL
target->enable();
render_targets.push(target);
#endif
}
GLRenderTarget* EffectsHandlerImpl::popRenderTarget()
{
#ifdef HAVE_OPENGL
GLRenderTarget* ret = render_targets.pop();
ret->disable();
if( !render_targets.isEmpty() )
render_targets.top()->enable();
return ret;
#else
return 0;
#endif
}
void EffectsHandlerImpl::addRepaintFull()
{
Workspace::self()->addRepaintFull();

View file

@ -15,6 +15,8 @@ License. See the file "COPYING" for the exact licensing terms.
#include "scene.h"
#include <QStack>
namespace KWin
@ -60,6 +62,9 @@ class EffectsHandlerImpl : public EffectsHandler
virtual int currentTabBoxDesktop() const;
virtual EffectWindow* currentTabBoxWindow() const;
virtual void pushRenderTarget(GLRenderTarget* target);
virtual GLRenderTarget* popRenderTarget();
virtual void addRepaintFull();
virtual void addRepaint( const QRect& r );
virtual void addRepaint( int x, int y, int w, int h );
@ -107,6 +112,7 @@ class EffectsHandlerImpl : public EffectsHandler
protected:
KLibrary* findEffectLibrary( const QString& effectname );
Effect* keyboard_grab_effect;
QStack<GLRenderTarget*> render_targets;
};
class EffectWindowImpl : public EffectWindow

View file

@ -17,6 +17,7 @@ License. See the file "COPYING" for the exact licensing terms.
#include <KStandardDirs>
#include <kdebug.h>
#include <assert.h>
namespace KWin
@ -79,7 +80,7 @@ void LiquidEffect::prePaintScreen( int* mask, QRegion* region, int time )
{
*mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
// Start rendering to texture
mRenderTarget->enable();
effects->pushRenderTarget(mRenderTarget);
}
effects->prePaintScreen(mask, region, time);
@ -93,7 +94,7 @@ void LiquidEffect::postPaintScreen()
if(mValid)
{
// Disable render texture
mRenderTarget->disable();
assert( effects->popRenderTarget() == mRenderTarget );
mTexture->bind();
// Use the shader

View file

@ -13,6 +13,7 @@ License. See the file "COPYING" for the exact licensing terms.
#include <kwinglutils.h>
#include <assert.h>
namespace KWin
{
@ -47,7 +48,7 @@ void TestFBOEffect::prePaintScreen( int* mask, QRegion* region, int time )
{
*mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
// Start rendering to texture
mRenderTarget->enable();
effects->pushRenderTarget(mRenderTarget);
}
effects->prePaintScreen(mask, region, time);
@ -61,7 +62,7 @@ void TestFBOEffect::postPaintScreen()
if(mValid)
{
// Disable render texture
mRenderTarget->disable();
assert( effects->popRenderTarget() == mRenderTarget );
mTexture->bind();
// Render fullscreen quad with screen contents

View file

@ -36,6 +36,7 @@ class EffectWindow;
class EffectWindowGroup;
class Effect;
class Vertex;
class GLRenderTarget;
typedef QPair< QString, Effect* > EffectPair;
typedef QPair< Effect*, Window > InputWindowPair;
@ -208,6 +209,9 @@ class KWIN_EXPORT EffectsHandler
virtual int currentTabBoxDesktop() const = 0;
virtual EffectWindow* currentTabBoxWindow() const = 0;
virtual void pushRenderTarget(GLRenderTarget* target) = 0;
virtual GLRenderTarget* popRenderTarget() = 0;
// Repaints the entire workspace
virtual void addRepaintFull() = 0;
virtual void addRepaint( const QRect& r ) = 0;