From 5d3d8834ab167c91f37a739348eb7d307e16dacd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 24 Jun 2013 08:49:24 +0200 Subject: [PATCH] Pass creation of Scene::EffectFrame to the Scene Instead of having the EffectFrameImpl check the compositor type and do the decision which Scene::EffectFrame to create, a pure virtual method in Scene is called which returns the specific Scene::EffectFrame. --- effects.cpp | 12 +----------- scene.h | 6 ++++++ scene_opengl.cpp | 5 +++++ scene_opengl.h | 1 + scene_xrender.cpp | 5 +++++ scene_xrender.h | 1 + 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/effects.cpp b/effects.cpp index 39e7019387..c57e58a57b 100644 --- a/effects.cpp +++ b/effects.cpp @@ -31,7 +31,6 @@ along with this program. If not, see . #include "cursor.h" #include "group.h" #include "scene_xrender.h" -#include "scene_opengl.h" #include "unmanaged.h" #ifdef KWIN_BUILD_TABBOX #include "tabbox.h" @@ -1891,16 +1890,7 @@ EffectFrameImpl::EffectFrameImpl(EffectFrameStyle style, bool staticSize, QPoint m_selection.setCacheAllRenderedFrames(true); m_selection.setEnabledBorders(Plasma::FrameSvg::AllBorders); - if (effects->isOpenGLCompositing()) { - m_sceneFrame = new SceneOpenGL::EffectFrame(this, static_cast(Compositor::self()->scene())); - } else if (effects->compositingType() == XRenderCompositing) { -#ifdef KWIN_HAVE_XRENDER_COMPOSITING - m_sceneFrame = new SceneXrender::EffectFrame(this); -#endif - } else { - // that should not happen and will definitely crash! - m_sceneFrame = NULL; - } + m_sceneFrame = Compositor::self()->scene()->createEffectFrame(this); } EffectFrameImpl::~EffectFrameImpl() diff --git a/scene.h b/scene.h index ca4afb734f..f2ae94cf9b 100644 --- a/scene.h +++ b/scene.h @@ -66,6 +66,12 @@ public: // a new window has been created virtual void windowAdded(Toplevel*) = 0; + /** + * @brief Creates the Scene backend of an EffectFrame. + * + * @param frame The EffectFrame this Scene::EffectFrame belongs to. + */ + virtual Scene::EffectFrame *createEffectFrame(EffectFrameImpl *frame) = 0; /** * Method invoked when the screen geometry is changed. * Reimplementing classes should also invoke the parent method diff --git a/scene_opengl.cpp b/scene_opengl.cpp index 289e1987d6..0ab2f7bea9 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -636,6 +636,11 @@ void SceneOpenGL::doneOpenGLContextCurrent() m_backend->doneCurrent(); } +Scene::EffectFrame *SceneOpenGL::createEffectFrame(EffectFrameImpl *frame) +{ + return new SceneOpenGL::EffectFrame(frame, this); +} + //**************************************** // SceneOpenGL2 //**************************************** diff --git a/scene_opengl.h b/scene_opengl.h index d43ee632ae..6437bf3f4b 100644 --- a/scene_opengl.h +++ b/scene_opengl.h @@ -50,6 +50,7 @@ public: virtual qint64 paint(QRegion damage, ToplevelList windows); virtual void windowAdded(Toplevel*); virtual void windowDeleted(Deleted*); + virtual Scene::EffectFrame *createEffectFrame(EffectFrameImpl *frame); virtual void screenGeometryChanged(const QSize &size); virtual OverlayWindow *overlayWindow(); virtual bool blocksForRetrace() const; diff --git a/scene_xrender.cpp b/scene_xrender.cpp index efb924b422..6d7a5a2912 100644 --- a/scene_xrender.cpp +++ b/scene_xrender.cpp @@ -288,6 +288,11 @@ void SceneXrender::windowAdded(Toplevel* c) windows[ c ]->updateShadow(c->shadow()); } +Scene::EffectFrame *SceneXrender::createEffectFrame(EffectFrameImpl *frame) +{ + return new SceneXrender::EffectFrame(frame); +} + //**************************************** // SceneXrender::Window //**************************************** diff --git a/scene_xrender.h b/scene_xrender.h index 5c8e917520..fe2806d9c7 100644 --- a/scene_xrender.h +++ b/scene_xrender.h @@ -45,6 +45,7 @@ public: virtual qint64 paint(QRegion damage, ToplevelList windows); virtual void windowAdded(Toplevel*); virtual void windowDeleted(Deleted*); + virtual Scene::EffectFrame *createEffectFrame(EffectFrameImpl *frame); virtual void screenGeometryChanged(const QSize &size); xcb_render_picture_t bufferPicture(); virtual OverlayWindow *overlayWindow() {