Scene*::Window classes are now too complex to be value-based,

allocate them dynamically.


svn path=/branches/work/kwin_composite/; revision=645046
This commit is contained in:
Luboš Luňák 2007-03-21 15:52:42 +00:00
parent ff643184cf
commit da02ba11ca
6 changed files with 35 additions and 53 deletions

View file

@ -256,10 +256,6 @@ Scene::Window::~Window()
{
}
void Scene::Window::free()
{
}
void Scene::Window::discardShape()
{
// it is created on-demand and cached, simply

View file

@ -119,8 +119,6 @@ class Scene::Window
public:
Window( Toplevel* c );
virtual ~Window();
// this class is often copied by value, use manually instead of dtor
virtual void free();
// perform the actual painting of the window
virtual void performPaint( int mask, QRegion region, WindowPaintData data ) = 0;
virtual void prepareForPainting() {}
@ -160,7 +158,6 @@ class Scene::Window
QRegion shape() const;
void discardShape();
void updateToplevel( Toplevel* c );
Window() {} // QMap sucks even in Qt4
protected:
Toplevel* toplevel;
ImageFilterType filter;
@ -168,6 +165,7 @@ class Scene::Window
int disable_painting;
mutable QRegion shape_region;
mutable bool shape_valid;
Q_DISABLE_COPY(Window);
};
extern Scene* scene;

View file

@ -163,10 +163,8 @@ SceneOpenGL::SceneOpenGL( Workspace* ws )
SceneOpenGL::~SceneOpenGL()
{
for( QHash< Toplevel*, Window >::Iterator it = windows.begin();
it != windows.end();
++it )
(*it).free();
foreach( Window* w, windows )
delete w;
// do cleanup after initBuffer()
if( wspace->overlayWindow())
{
@ -535,7 +533,7 @@ void SceneOpenGL::paint( QRegion damage, ToplevelList toplevels )
foreach( Toplevel* c, toplevels )
{
assert( windows.contains( c ));
stacking_order.append( &windows[ c ] );
stacking_order.append( windows[ c ] );
}
grabXServer();
glXWaitX();
@ -667,7 +665,7 @@ void SceneOpenGL::paintBackground( QRegion region )
void SceneOpenGL::windowAdded( Toplevel* c )
{
assert( !windows.contains( c ));
windows[ c ] = Window( c );
windows[ c ] = new Window( c );
}
void SceneOpenGL::windowClosed( Toplevel* c, Deleted* deleted )
@ -675,33 +673,30 @@ void SceneOpenGL::windowClosed( Toplevel* c, Deleted* deleted )
assert( windows.contains( c ));
if( deleted != NULL )
{ // replace c with deleted
Window& w = windows[ c ];
w.updateToplevel( deleted );
Window* w = windows.take( c );
w->updateToplevel( deleted );
windows[ deleted ] = w;
windows.remove( c );
}
else
{
windows[ c ].free();
windows.remove( c );
delete windows.take( c );
}
}
void SceneOpenGL::windowDeleted( Deleted* c )
{
assert( windows.contains( c ));
windows[ c ].free();
windows.remove( c );
delete windows.take( c );
}
void SceneOpenGL::windowGeometryShapeChanged( Toplevel* c )
{
if( !windows.contains( c )) // this is ok, shape is not valid
return; // by default
Window& w = windows[ c ];
w.discardShape();
w.discardTexture();
w.discardVertices();
Window* w = windows[ c ];
w->discardShape();
w->discardTexture();
w->discardVertices();
}
void SceneOpenGL::windowOpacityChanged( Toplevel* )
@ -711,8 +706,8 @@ void SceneOpenGL::windowOpacityChanged( Toplevel* )
// creating it
if( !windows.contains( c )) // this is ok, texture is created
return; // on demand
Window& w = windows[ c ];
w.discardTexture();
Window* w = windows[ c ];
w->discardTexture();
#endif
}
@ -737,7 +732,7 @@ SceneOpenGL::Window::Window( Toplevel* c )
{
}
void SceneOpenGL::Window::free()
SceneOpenGL::Window::~Window()
{
discardTexture();
discardVertices();

View file

@ -79,7 +79,7 @@ class SceneOpenGL
static bool supports_npot_textures;
static bool supports_fbo;
static bool supports_saturation;
QHash< Toplevel*, Window > windows;
QHash< Toplevel*, Window* > windows;
#ifdef HAVE_XSHM
static XShmSegmentInfo shm;
#endif
@ -90,7 +90,7 @@ class SceneOpenGL::Window
{
public:
Window( Toplevel* c );
virtual void free();
virtual ~Window();
virtual void performPaint( int mask, QRegion region, WindowPaintData data );
virtual void prepareForPainting();
void findTextureTarget();
@ -99,7 +99,6 @@ class SceneOpenGL::Window
void disableTexture();
void discardTexture();
void discardVertices();
Window() {} // QMap sucks even in Qt4
/**
* @short Vertex class

View file

@ -97,10 +97,8 @@ SceneXrender::~SceneXrender()
XRenderFreePicture( display(), front );
XRenderFreePicture( display(), buffer );
wspace->destroyOverlay();
for( QHash< Toplevel*, Window >::Iterator it = windows.begin();
it != windows.end();
++it )
(*it).free();
foreach( Window* w, windows )
delete w;
}
// the entry point for painting
@ -109,7 +107,7 @@ void SceneXrender::paint( QRegion damage, ToplevelList toplevels )
foreach( Toplevel* c, toplevels )
{
assert( windows.contains( c ));
stacking_order.append( &windows[ c ] );
stacking_order.append( windows[ c ] );
}
int mask = 0;
paintScreen( &mask, &damage );
@ -218,18 +216,18 @@ void SceneXrender::windowGeometryShapeChanged( Toplevel* c )
{
if( !windows.contains( c )) // this is ok, shape is not valid by default
return;
Window& w = windows[ c ];
w.discardPicture();
w.discardShape();
w.discardAlpha();
Window* w = windows[ c ];
w->discardPicture();
w->discardShape();
w->discardAlpha();
}
void SceneXrender::windowOpacityChanged( Toplevel* c )
{
if( !windows.contains( c )) // this is ok, alpha is created on demand
return;
Window& w = windows[ c ];
w.discardAlpha();
Window* w = windows[ c ];
w->discardAlpha();
}
void SceneXrender::windowClosed( Toplevel* c, Deleted* deleted )
@ -237,29 +235,26 @@ void SceneXrender::windowClosed( Toplevel* c, Deleted* deleted )
assert( windows.contains( c ));
if( deleted != NULL )
{ // replace c with deleted
Window& w = windows[ c ];
w.updateToplevel( deleted );
Window* w = windows.take( c );
w->updateToplevel( deleted );
windows[ deleted ] = w;
windows.remove( c );
}
else
{
windows[ c ].free();
windows.remove( c );
delete windows.take( c );
}
}
void SceneXrender::windowDeleted( Deleted* c )
{
assert( windows.contains( c ));
windows[ c ].free();
windows.remove( c );
delete windows.take( c );
}
void SceneXrender::windowAdded( Toplevel* c )
{
assert( !windows.contains( c ));
windows[ c ] = Window( c );
windows[ c ] = new Window( c );
}
// Create the compositing buffer. The root window is not double-buffered,
@ -306,7 +301,7 @@ SceneXrender::Window::Window( Toplevel* c )
{
}
void SceneXrender::Window::free()
SceneXrender::Window::~Window()
{
discardPicture();
discardAlpha();

View file

@ -48,7 +48,7 @@ class SceneXrender
static Picture buffer;
static ScreenPaintData screen_paint;
class Window;
QHash< Toplevel*, Window > windows;
QHash< Toplevel*, Window* > windows;
};
class SceneXrender::Window
@ -56,13 +56,12 @@ class SceneXrender::Window
{
public:
Window( Toplevel* c );
virtual void free();
virtual ~Window();
virtual void performPaint( int mask, QRegion region, WindowPaintData data );
void discardPicture();
void discardAlpha();
QRegion transformedShape() const;
void setTransformedShape( const QRegion& shape );
Window() {} // QMap sucks even in Qt4
private:
Picture picture();
Picture alphaMask( double opacity );