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:
parent
ff643184cf
commit
da02ba11ca
6 changed files with 35 additions and 53 deletions
|
@ -256,10 +256,6 @@ Scene::Window::~Window()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::Window::free()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scene::Window::discardShape()
|
void Scene::Window::discardShape()
|
||||||
{
|
{
|
||||||
// it is created on-demand and cached, simply
|
// it is created on-demand and cached, simply
|
||||||
|
|
4
scene.h
4
scene.h
|
@ -119,8 +119,6 @@ class Scene::Window
|
||||||
public:
|
public:
|
||||||
Window( Toplevel* c );
|
Window( Toplevel* c );
|
||||||
virtual ~Window();
|
virtual ~Window();
|
||||||
// this class is often copied by value, use manually instead of dtor
|
|
||||||
virtual void free();
|
|
||||||
// perform the actual painting of the window
|
// perform the actual painting of the window
|
||||||
virtual void performPaint( int mask, QRegion region, WindowPaintData data ) = 0;
|
virtual void performPaint( int mask, QRegion region, WindowPaintData data ) = 0;
|
||||||
virtual void prepareForPainting() {}
|
virtual void prepareForPainting() {}
|
||||||
|
@ -160,7 +158,6 @@ class Scene::Window
|
||||||
QRegion shape() const;
|
QRegion shape() const;
|
||||||
void discardShape();
|
void discardShape();
|
||||||
void updateToplevel( Toplevel* c );
|
void updateToplevel( Toplevel* c );
|
||||||
Window() {} // QMap sucks even in Qt4
|
|
||||||
protected:
|
protected:
|
||||||
Toplevel* toplevel;
|
Toplevel* toplevel;
|
||||||
ImageFilterType filter;
|
ImageFilterType filter;
|
||||||
|
@ -168,6 +165,7 @@ class Scene::Window
|
||||||
int disable_painting;
|
int disable_painting;
|
||||||
mutable QRegion shape_region;
|
mutable QRegion shape_region;
|
||||||
mutable bool shape_valid;
|
mutable bool shape_valid;
|
||||||
|
Q_DISABLE_COPY(Window);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Scene* scene;
|
extern Scene* scene;
|
||||||
|
|
|
@ -163,10 +163,8 @@ SceneOpenGL::SceneOpenGL( Workspace* ws )
|
||||||
|
|
||||||
SceneOpenGL::~SceneOpenGL()
|
SceneOpenGL::~SceneOpenGL()
|
||||||
{
|
{
|
||||||
for( QHash< Toplevel*, Window >::Iterator it = windows.begin();
|
foreach( Window* w, windows )
|
||||||
it != windows.end();
|
delete w;
|
||||||
++it )
|
|
||||||
(*it).free();
|
|
||||||
// do cleanup after initBuffer()
|
// do cleanup after initBuffer()
|
||||||
if( wspace->overlayWindow())
|
if( wspace->overlayWindow())
|
||||||
{
|
{
|
||||||
|
@ -535,7 +533,7 @@ void SceneOpenGL::paint( QRegion damage, ToplevelList toplevels )
|
||||||
foreach( Toplevel* c, toplevels )
|
foreach( Toplevel* c, toplevels )
|
||||||
{
|
{
|
||||||
assert( windows.contains( c ));
|
assert( windows.contains( c ));
|
||||||
stacking_order.append( &windows[ c ] );
|
stacking_order.append( windows[ c ] );
|
||||||
}
|
}
|
||||||
grabXServer();
|
grabXServer();
|
||||||
glXWaitX();
|
glXWaitX();
|
||||||
|
@ -667,7 +665,7 @@ void SceneOpenGL::paintBackground( QRegion region )
|
||||||
void SceneOpenGL::windowAdded( Toplevel* c )
|
void SceneOpenGL::windowAdded( Toplevel* c )
|
||||||
{
|
{
|
||||||
assert( !windows.contains( c ));
|
assert( !windows.contains( c ));
|
||||||
windows[ c ] = Window( c );
|
windows[ c ] = new Window( c );
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneOpenGL::windowClosed( Toplevel* c, Deleted* deleted )
|
void SceneOpenGL::windowClosed( Toplevel* c, Deleted* deleted )
|
||||||
|
@ -675,33 +673,30 @@ void SceneOpenGL::windowClosed( Toplevel* c, Deleted* deleted )
|
||||||
assert( windows.contains( c ));
|
assert( windows.contains( c ));
|
||||||
if( deleted != NULL )
|
if( deleted != NULL )
|
||||||
{ // replace c with deleted
|
{ // replace c with deleted
|
||||||
Window& w = windows[ c ];
|
Window* w = windows.take( c );
|
||||||
w.updateToplevel( deleted );
|
w->updateToplevel( deleted );
|
||||||
windows[ deleted ] = w;
|
windows[ deleted ] = w;
|
||||||
windows.remove( c );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
windows[ c ].free();
|
delete windows.take( c );
|
||||||
windows.remove( c );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneOpenGL::windowDeleted( Deleted* c )
|
void SceneOpenGL::windowDeleted( Deleted* c )
|
||||||
{
|
{
|
||||||
assert( windows.contains( c ));
|
assert( windows.contains( c ));
|
||||||
windows[ c ].free();
|
delete windows.take( c );
|
||||||
windows.remove( c );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneOpenGL::windowGeometryShapeChanged( Toplevel* c )
|
void SceneOpenGL::windowGeometryShapeChanged( Toplevel* c )
|
||||||
{
|
{
|
||||||
if( !windows.contains( c )) // this is ok, shape is not valid
|
if( !windows.contains( c )) // this is ok, shape is not valid
|
||||||
return; // by default
|
return; // by default
|
||||||
Window& w = windows[ c ];
|
Window* w = windows[ c ];
|
||||||
w.discardShape();
|
w->discardShape();
|
||||||
w.discardTexture();
|
w->discardTexture();
|
||||||
w.discardVertices();
|
w->discardVertices();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneOpenGL::windowOpacityChanged( Toplevel* )
|
void SceneOpenGL::windowOpacityChanged( Toplevel* )
|
||||||
|
@ -711,8 +706,8 @@ void SceneOpenGL::windowOpacityChanged( Toplevel* )
|
||||||
// creating it
|
// creating it
|
||||||
if( !windows.contains( c )) // this is ok, texture is created
|
if( !windows.contains( c )) // this is ok, texture is created
|
||||||
return; // on demand
|
return; // on demand
|
||||||
Window& w = windows[ c ];
|
Window* w = windows[ c ];
|
||||||
w.discardTexture();
|
w->discardTexture();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -737,7 +732,7 @@ SceneOpenGL::Window::Window( Toplevel* c )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneOpenGL::Window::free()
|
SceneOpenGL::Window::~Window()
|
||||||
{
|
{
|
||||||
discardTexture();
|
discardTexture();
|
||||||
discardVertices();
|
discardVertices();
|
||||||
|
|
|
@ -79,7 +79,7 @@ class SceneOpenGL
|
||||||
static bool supports_npot_textures;
|
static bool supports_npot_textures;
|
||||||
static bool supports_fbo;
|
static bool supports_fbo;
|
||||||
static bool supports_saturation;
|
static bool supports_saturation;
|
||||||
QHash< Toplevel*, Window > windows;
|
QHash< Toplevel*, Window* > windows;
|
||||||
#ifdef HAVE_XSHM
|
#ifdef HAVE_XSHM
|
||||||
static XShmSegmentInfo shm;
|
static XShmSegmentInfo shm;
|
||||||
#endif
|
#endif
|
||||||
|
@ -90,7 +90,7 @@ class SceneOpenGL::Window
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Window( Toplevel* c );
|
Window( Toplevel* c );
|
||||||
virtual void free();
|
virtual ~Window();
|
||||||
virtual void performPaint( int mask, QRegion region, WindowPaintData data );
|
virtual void performPaint( int mask, QRegion region, WindowPaintData data );
|
||||||
virtual void prepareForPainting();
|
virtual void prepareForPainting();
|
||||||
void findTextureTarget();
|
void findTextureTarget();
|
||||||
|
@ -99,7 +99,6 @@ class SceneOpenGL::Window
|
||||||
void disableTexture();
|
void disableTexture();
|
||||||
void discardTexture();
|
void discardTexture();
|
||||||
void discardVertices();
|
void discardVertices();
|
||||||
Window() {} // QMap sucks even in Qt4
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @short Vertex class
|
* @short Vertex class
|
||||||
|
|
|
@ -97,10 +97,8 @@ SceneXrender::~SceneXrender()
|
||||||
XRenderFreePicture( display(), front );
|
XRenderFreePicture( display(), front );
|
||||||
XRenderFreePicture( display(), buffer );
|
XRenderFreePicture( display(), buffer );
|
||||||
wspace->destroyOverlay();
|
wspace->destroyOverlay();
|
||||||
for( QHash< Toplevel*, Window >::Iterator it = windows.begin();
|
foreach( Window* w, windows )
|
||||||
it != windows.end();
|
delete w;
|
||||||
++it )
|
|
||||||
(*it).free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// the entry point for painting
|
// the entry point for painting
|
||||||
|
@ -109,7 +107,7 @@ void SceneXrender::paint( QRegion damage, ToplevelList toplevels )
|
||||||
foreach( Toplevel* c, toplevels )
|
foreach( Toplevel* c, toplevels )
|
||||||
{
|
{
|
||||||
assert( windows.contains( c ));
|
assert( windows.contains( c ));
|
||||||
stacking_order.append( &windows[ c ] );
|
stacking_order.append( windows[ c ] );
|
||||||
}
|
}
|
||||||
int mask = 0;
|
int mask = 0;
|
||||||
paintScreen( &mask, &damage );
|
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
|
if( !windows.contains( c )) // this is ok, shape is not valid by default
|
||||||
return;
|
return;
|
||||||
Window& w = windows[ c ];
|
Window* w = windows[ c ];
|
||||||
w.discardPicture();
|
w->discardPicture();
|
||||||
w.discardShape();
|
w->discardShape();
|
||||||
w.discardAlpha();
|
w->discardAlpha();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneXrender::windowOpacityChanged( Toplevel* c )
|
void SceneXrender::windowOpacityChanged( Toplevel* c )
|
||||||
{
|
{
|
||||||
if( !windows.contains( c )) // this is ok, alpha is created on demand
|
if( !windows.contains( c )) // this is ok, alpha is created on demand
|
||||||
return;
|
return;
|
||||||
Window& w = windows[ c ];
|
Window* w = windows[ c ];
|
||||||
w.discardAlpha();
|
w->discardAlpha();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneXrender::windowClosed( Toplevel* c, Deleted* deleted )
|
void SceneXrender::windowClosed( Toplevel* c, Deleted* deleted )
|
||||||
|
@ -237,29 +235,26 @@ void SceneXrender::windowClosed( Toplevel* c, Deleted* deleted )
|
||||||
assert( windows.contains( c ));
|
assert( windows.contains( c ));
|
||||||
if( deleted != NULL )
|
if( deleted != NULL )
|
||||||
{ // replace c with deleted
|
{ // replace c with deleted
|
||||||
Window& w = windows[ c ];
|
Window* w = windows.take( c );
|
||||||
w.updateToplevel( deleted );
|
w->updateToplevel( deleted );
|
||||||
windows[ deleted ] = w;
|
windows[ deleted ] = w;
|
||||||
windows.remove( c );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
windows[ c ].free();
|
delete windows.take( c );
|
||||||
windows.remove( c );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneXrender::windowDeleted( Deleted* c )
|
void SceneXrender::windowDeleted( Deleted* c )
|
||||||
{
|
{
|
||||||
assert( windows.contains( c ));
|
assert( windows.contains( c ));
|
||||||
windows[ c ].free();
|
delete windows.take( c );
|
||||||
windows.remove( c );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneXrender::windowAdded( Toplevel* c )
|
void SceneXrender::windowAdded( Toplevel* c )
|
||||||
{
|
{
|
||||||
assert( !windows.contains( 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,
|
// 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();
|
discardPicture();
|
||||||
discardAlpha();
|
discardAlpha();
|
||||||
|
|
|
@ -48,7 +48,7 @@ class SceneXrender
|
||||||
static Picture buffer;
|
static Picture buffer;
|
||||||
static ScreenPaintData screen_paint;
|
static ScreenPaintData screen_paint;
|
||||||
class Window;
|
class Window;
|
||||||
QHash< Toplevel*, Window > windows;
|
QHash< Toplevel*, Window* > windows;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SceneXrender::Window
|
class SceneXrender::Window
|
||||||
|
@ -56,13 +56,12 @@ class SceneXrender::Window
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Window( Toplevel* c );
|
Window( Toplevel* c );
|
||||||
virtual void free();
|
virtual ~Window();
|
||||||
virtual void performPaint( int mask, QRegion region, WindowPaintData data );
|
virtual void performPaint( int mask, QRegion region, WindowPaintData data );
|
||||||
void discardPicture();
|
void discardPicture();
|
||||||
void discardAlpha();
|
void discardAlpha();
|
||||||
QRegion transformedShape() const;
|
QRegion transformedShape() const;
|
||||||
void setTransformedShape( const QRegion& shape );
|
void setTransformedShape( const QRegion& shape );
|
||||||
Window() {} // QMap sucks even in Qt4
|
|
||||||
private:
|
private:
|
||||||
Picture picture();
|
Picture picture();
|
||||||
Picture alphaMask( double opacity );
|
Picture alphaMask( double opacity );
|
||||||
|
|
Loading…
Reference in a new issue