diff --git a/effects.cpp b/effects.cpp index b9d0daa01d..7a5b59bd88 100644 --- a/effects.cpp +++ b/effects.cpp @@ -1073,15 +1073,6 @@ EffectWindowList EffectWindowImpl::mainWindows() const return EffectWindowList(); } -void EffectWindowImpl::setShader(GLShader* shader) - { -#ifdef HAVE_OPENGL - if( SceneOpenGL::Window* w = dynamic_cast< SceneOpenGL::Window* >( sceneWindow())) - return w->setShader(shader); -#endif - abort(); // TODO - } - WindowQuadList EffectWindowImpl::buildQuads() const { return sceneWindow()->buildQuads(); diff --git a/effects.h b/effects.h index ab4d5a4ec7..bd1e51e247 100644 --- a/effects.h +++ b/effects.h @@ -190,7 +190,6 @@ class EffectWindowImpl : public EffectWindow virtual EffectWindow* findModal(); virtual EffectWindowList mainWindows() const; - virtual void setShader(GLShader* shader); virtual WindowQuadList buildQuads() const; const Toplevel* window() const; diff --git a/effects/blur.cpp b/effects/blur.cpp index a1c34764a2..83ee8cc845 100644 --- a/effects/blur.cpp +++ b/effects/blur.cpp @@ -175,7 +175,7 @@ void BlurEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowP // Set custom shader to render the window with mWindowShader->bind(); - w->setShader(mWindowShader); + data.shader = mWindowShader; // Put the blur texture to tex unit 4 glActiveTexture(GL_TEXTURE4); mBlurTexture->bind(); diff --git a/effects/explosioneffect.cpp b/effects/explosioneffect.cpp index 5751b01234..ebce1c3756 100644 --- a/effects/explosioneffect.cpp +++ b/effects/explosioneffect.cpp @@ -159,7 +159,7 @@ void ExplosionEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi glActiveTexture(GL_TEXTURE5); mEndOffsetTex->bind(); glActiveTexture(GL_TEXTURE0); - w->setShader(mShader); + data.shader = mShader; } // Call the next effect. diff --git a/lib/kwineffects.cpp b/lib/kwineffects.cpp index 643f7ab344..de324b1db7 100644 --- a/lib/kwineffects.cpp +++ b/lib/kwineffects.cpp @@ -45,6 +45,7 @@ WindowPaintData::WindowPaintData( EffectWindow* w ) , yTranslate( 0 ) , saturation( 1 ) , brightness( 1 ) + , shader( NULL ) { quads = w->buildQuads(); } diff --git a/lib/kwineffects.h b/lib/kwineffects.h index d8b5e70e83..2a26ac0a74 100644 --- a/lib/kwineffects.h +++ b/lib/kwineffects.h @@ -345,8 +345,6 @@ class KWIN_EXPORT EffectWindow virtual EffectWindow* findModal() = 0; virtual EffectWindowList mainWindows() const = 0; - virtual void setShader(GLShader* shader) = 0; - // TODO internal? virtual WindowQuadList buildQuads() const = 0; }; @@ -480,6 +478,10 @@ class KWIN_EXPORT WindowPaintData **/ float brightness; WindowQuadList quads; + /** + * Shader to be used for rendering, if any. + */ + GLShader* shader; }; class KWIN_EXPORT ScreenPaintData diff --git a/scene.cpp b/scene.cpp index 4331779f80..af9c85f2b3 100644 --- a/scene.cpp +++ b/scene.cpp @@ -269,7 +269,6 @@ void Scene::paintWindow( Window* w, int mask, QRegion region, WindowQuadList qua { WindowPaintData data( w->window()->effectWindow()); data.quads = quads; - w->prepareForPainting(); effects->paintWindow( effectWindow( w ), mask, region, data ); } diff --git a/scene.h b/scene.h index b0b5f1d133..4c2ddabb26 100644 --- a/scene.h +++ b/scene.h @@ -132,7 +132,6 @@ class Scene::Window virtual ~Window(); // perform the actual painting of the window virtual void performPaint( int mask, QRegion region, WindowPaintData data ) = 0; - virtual void prepareForPainting() {} // do any cleanup needed when the window's composite pixmap is discarded virtual void pixmapDiscarded() {} int x() const; diff --git a/scene_opengl.cpp b/scene_opengl.cpp index 2e8b0dc721..1d66ee55aa 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -1027,13 +1027,6 @@ SceneOpenGL::Window::~Window() discardTexture(); } -void SceneOpenGL::Window::prepareForPainting() - { - shader = NULL; // TODO - // We should also bind texture here so that effects could access it in the - // paint pass - } - // Bind the window pixmap to an OpenGL texture. bool SceneOpenGL::Window::bindTexture() { @@ -1141,19 +1134,19 @@ void SceneOpenGL::Window::performPaint( int mask, QRegion region, WindowPaintDat WindowQuadList decoration = data.quads.select( WindowQuadDecoration ); if( data.contents_opacity != data.decoration_opacity && !decoration.isEmpty()) { - prepareStates( data.opacity * data.contents_opacity, data.brightness, data.saturation ); + prepareStates( data.opacity * data.contents_opacity, data.brightness, data.saturation, data.shader ); renderQuads( mask, region, data.quads.select( WindowQuadContents )); - restoreStates( data.opacity * data.contents_opacity, data.brightness, data.saturation ); - prepareStates( data.opacity * data.decoration_opacity, data.brightness, data.saturation ); + restoreStates( data.opacity * data.contents_opacity, data.brightness, data.saturation, data.shader ); + prepareStates( data.opacity * data.decoration_opacity, data.brightness, data.saturation, data.shader ); renderQuads( mask, region, decoration ); - restoreStates( data.opacity * data.decoration_opacity, data.brightness, data.saturation ); + restoreStates( data.opacity * data.decoration_opacity, data.brightness, data.saturation, data.shader ); } else { - prepareStates( data.opacity * data.contents_opacity, data.brightness, data.saturation ); + prepareStates( data.opacity * data.contents_opacity, data.brightness, data.saturation, data.shader ); renderQuads( mask, region, data.quads.select( WindowQuadContents )); renderQuads( mask, region, data.quads.select( WindowQuadDecoration )); - restoreStates( data.opacity * data.contents_opacity, data.brightness, data.saturation ); + restoreStates( data.opacity * data.contents_opacity, data.brightness, data.saturation, data.shader ); } texture.disableUnnormalizedTexCoords(); @@ -1175,15 +1168,15 @@ void SceneOpenGL::Window::renderQuads( int mask, const QRegion& region, const Wi delete[] texcoords; } -void SceneOpenGL::Window::prepareStates( double opacity, double brightness, double saturation ) +void SceneOpenGL::Window::prepareStates( double opacity, double brightness, double saturation, GLShader* shader ) { if(shader) - prepareShaderRenderStates( opacity, brightness, saturation ); + prepareShaderRenderStates( opacity, brightness, saturation, shader ); else prepareRenderStates( opacity, brightness, saturation ); } -void SceneOpenGL::Window::prepareShaderRenderStates( double opacity, double brightness, double saturation ) +void SceneOpenGL::Window::prepareShaderRenderStates( double opacity, double brightness, double saturation, GLShader* shader ) { // setup blending of transparent windows glPushAttrib( GL_ENABLE_BIT ); @@ -1323,19 +1316,20 @@ void SceneOpenGL::Window::prepareRenderStates( double opacity, double brightness } } -void SceneOpenGL::Window::restoreStates( double opacity, double brightness, double saturation ) +void SceneOpenGL::Window::restoreStates( double opacity, double brightness, double saturation, GLShader* shader ) { if(shader) - restoreShaderRenderStates( opacity, brightness, saturation ); + restoreShaderRenderStates( opacity, brightness, saturation, shader ); else restoreRenderStates( opacity, brightness, saturation ); } -void SceneOpenGL::Window::restoreShaderRenderStates( double opacity, double brightness, double saturation ) +void SceneOpenGL::Window::restoreShaderRenderStates( double opacity, double brightness, double saturation, GLShader* shader ) { Q_UNUSED( opacity ); Q_UNUSED( brightness ); Q_UNUSED( saturation ); + Q_UNUSED( shader ); glPopAttrib(); // ENABLE_BIT } diff --git a/scene_opengl.h b/scene_opengl.h index 574675a480..e30d00db84 100644 --- a/scene_opengl.h +++ b/scene_opengl.h @@ -118,24 +118,21 @@ class SceneOpenGL::Window Window( Toplevel* c ); virtual ~Window(); virtual void performPaint( int mask, QRegion region, WindowPaintData data ); - virtual void prepareForPainting(); virtual void pixmapDiscarded(); bool bindTexture(); void discardTexture(); - void setShader( GLShader* s ) { shader = s; } protected: void renderQuads( int mask, const QRegion& region, const WindowQuadList& quads ); - void prepareStates( double opacity, double brightness, double saturation ); + void prepareStates( double opacity, double brightness, double saturation, GLShader* shader ); void prepareRenderStates( double opacity, double brightness, double saturation ); - void prepareShaderRenderStates( double opacity, double brightness, double saturation ); - void restoreStates( double opacity, double brightness, double saturation ); + void prepareShaderRenderStates( double opacity, double brightness, double saturation, GLShader* shader ); + void restoreStates( double opacity, double brightness, double saturation, GLShader* shader ); void restoreRenderStates( double opacity, double brightness, double saturation ); - void restoreShaderRenderStates( double opacity, double brightness, double saturation ); + void restoreShaderRenderStates( double opacity, double brightness, double saturation, GLShader* shader ); private: Texture texture; - GLShader* shader; // shader to be used for rendering, if any }; } // namespace