Move the shader used for painting to WindowPaintData, as it's

more related to one painting than to a window.


svn path=/trunk/KDE/kdebase/workspace/; revision=698576
icc-effect-5.14.5
Luboš Luňák 2007-08-10 11:26:58 +00:00
parent d3f83ad297
commit 5a50381e1f
10 changed files with 24 additions and 42 deletions

View File

@ -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();

View File

@ -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;

View File

@ -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();

View File

@ -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.

View File

@ -45,6 +45,7 @@ WindowPaintData::WindowPaintData( EffectWindow* w )
, yTranslate( 0 )
, saturation( 1 )
, brightness( 1 )
, shader( NULL )
{
quads = w->buildQuads();
}

View File

@ -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

View File

@ -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 );
}

View File

@ -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;

View File

@ -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
}

View File

@ -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