Add GLShader dtor (fixes memory leak).
Also fix multiple memory leaks in effects. svn path=/branches/work/kwin_composite/; revision=658761icc-effect-5.14.5
parent
e85930ce1e
commit
24c8663923
|
@ -29,9 +29,19 @@ KWIN_EFFECT_SUPPORTED( Demo_Liquid, LiquidEffect::supported() );
|
||||||
|
|
||||||
LiquidEffect::LiquidEffect() : Effect()
|
LiquidEffect::LiquidEffect() : Effect()
|
||||||
{
|
{
|
||||||
|
mTexture = 0;
|
||||||
|
mRenderTarget = 0;
|
||||||
|
mShader = 0;
|
||||||
|
|
||||||
mTime = 0.0f;
|
mTime = 0.0f;
|
||||||
mValid = loadData();
|
mValid = loadData();
|
||||||
}
|
}
|
||||||
|
LiquidEffect::~LiquidEffect()
|
||||||
|
{
|
||||||
|
delete mTexture;
|
||||||
|
delete mRenderTarget;
|
||||||
|
delete mShader;
|
||||||
|
}
|
||||||
|
|
||||||
bool LiquidEffect::loadData()
|
bool LiquidEffect::loadData()
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,7 @@ class LiquidEffect : public Effect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LiquidEffect();
|
LiquidEffect();
|
||||||
|
~LiquidEffect();
|
||||||
|
|
||||||
virtual void prePaintScreen( int* mask, QRegion* region, int time );
|
virtual void prePaintScreen( int* mask, QRegion* region, int time );
|
||||||
virtual void postPaintScreen();
|
virtual void postPaintScreen();
|
||||||
|
|
|
@ -28,11 +28,22 @@ KWIN_EFFECT_SUPPORTED( Explosion, ExplosionEffect::supported() );
|
||||||
|
|
||||||
ExplosionEffect::ExplosionEffect() : Effect()
|
ExplosionEffect::ExplosionEffect() : Effect()
|
||||||
{
|
{
|
||||||
|
mShader = 0;
|
||||||
|
mStartOffsetTex = 0;
|
||||||
|
mEndOffsetTex = 0;
|
||||||
|
|
||||||
mActiveAnimations = 0;
|
mActiveAnimations = 0;
|
||||||
mValid = true;
|
mValid = true;
|
||||||
mInited = false;
|
mInited = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExplosionEffect::~ExplosionEffect()
|
||||||
|
{
|
||||||
|
delete mShader;
|
||||||
|
delete mStartOffsetTex;
|
||||||
|
delete mEndOffsetTex;
|
||||||
|
}
|
||||||
|
|
||||||
bool ExplosionEffect::supported()
|
bool ExplosionEffect::supported()
|
||||||
{
|
{
|
||||||
return GLShader::fragmentShaderSupported() &&
|
return GLShader::fragmentShaderSupported() &&
|
||||||
|
|
|
@ -30,6 +30,7 @@ class ExplosionEffect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ExplosionEffect();
|
ExplosionEffect();
|
||||||
|
~ExplosionEffect();
|
||||||
|
|
||||||
virtual void prePaintScreen( int* mask, QRegion* region, int time );
|
virtual void prePaintScreen( int* mask, QRegion* region, int time );
|
||||||
virtual void prePaintWindow( EffectWindow* w, int* mask, QRegion* paint, QRegion* clip, int time );
|
virtual void prePaintWindow( EffectWindow* w, int* mask, QRegion* paint, QRegion* clip, int time );
|
||||||
|
|
|
@ -495,10 +495,25 @@ GLShader::GLShader(const QString& vertexfile, const QString& fragmentfile)
|
||||||
{
|
{
|
||||||
mValid = false;
|
mValid = false;
|
||||||
mVariableLocations = 0;
|
mVariableLocations = 0;
|
||||||
|
mProgram = 0;
|
||||||
|
|
||||||
loadFromFiles(vertexfile, fragmentfile);
|
loadFromFiles(vertexfile, fragmentfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLShader::~GLShader()
|
||||||
|
{
|
||||||
|
if(mVariableLocations)
|
||||||
|
{
|
||||||
|
mVariableLocations->clear();
|
||||||
|
delete mVariableLocations;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mProgram)
|
||||||
|
{
|
||||||
|
glDeleteProgram(mProgram);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool GLShader::loadFromFiles(const QString& vertexfile, const QString& fragmentfile)
|
bool GLShader::loadFromFiles(const QString& vertexfile, const QString& fragmentfile)
|
||||||
{
|
{
|
||||||
QFile vf(vertexfile);
|
QFile vf(vertexfile);
|
||||||
|
|
|
@ -132,6 +132,7 @@ class KWIN_EXPORT GLShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GLShader(const QString& vertexfile, const QString& fragmentfile);
|
GLShader(const QString& vertexfile, const QString& fragmentfile);
|
||||||
|
~GLShader();
|
||||||
|
|
||||||
bool isValid() const { return mValid; }
|
bool isValid() const { return mValid; }
|
||||||
void bind();
|
void bind();
|
||||||
|
|
Loading…
Reference in New Issue