Commit ad4a3107 authored by Martin Flöser's avatar Martin Flöser

Add virtual Scene::scenePainter method

Summary:
So far EffectsHandlerImpl directly accessed SceneQPainter::painter
through a dynamic cast. If in future the QPainter based compositor should
be moved into a plugin we cannot access it through a dynamic cast.

To solve this problem the painter method is moved into Scene as
a virtual method returning a sane default value.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D7214
parent c1892e6c
......@@ -32,7 +32,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "group.h"
#include "osd.h"
#include "pointer_input.h"
#include "scene_qpainter.h"
#include "unmanaged.h"
#ifdef KWIN_BUILD_TABBOX
#include "tabbox.h"
......@@ -1328,11 +1327,7 @@ unsigned long EffectsHandlerImpl::xrenderBufferPicture()
QPainter *EffectsHandlerImpl::scenePainter()
{
if (SceneQPainter *s = dynamic_cast<SceneQPainter*>(m_scene)) {
return s->painter();
} else {
return NULL;
}
return m_scene->scenePainter();
}
void EffectsHandlerImpl::toggleEffect(const QString& name)
......
......@@ -657,6 +657,11 @@ xcb_render_picture_t Scene::xrenderBufferPicture() const
return XCB_RENDER_PICTURE_NONE;
}
QPainter *Scene::scenePainter() const
{
return nullptr;
}
//****************************************
// Scene::Window
//****************************************
......
......@@ -163,6 +163,12 @@ public:
**/
virtual xcb_render_picture_t xrenderBufferPicture() const;
/**
* The QPainter used by a QPainter based compositor scene.
* Default implementation returns @c nullptr;
**/
virtual QPainter *scenePainter() const;
Q_SIGNALS:
void frameRendered();
......
......@@ -281,7 +281,7 @@ void SceneQPainter::Window::performPaint(int mask, QRegion region, WindowPaintDa
toplevel->resetDamage();
}
QPainter *scenePainter = m_scene->painter();
QPainter *scenePainter = m_scene->scenePainter();
QPainter *painter = scenePainter;
painter->save();
painter->setClipRegion(region);
......@@ -523,7 +523,7 @@ void QPainterEffectFrame::render(QRegion region, double opacity, double frameOpa
if (m_effectFrame->geometry().isEmpty()) {
return; // Nothing to display
}
QPainter *painter = m_scene->painter();
QPainter *painter = m_scene->scenePainter();
// Render the actual frame
......
......@@ -123,7 +123,7 @@ public:
return false;
}
QPainter *painter();
QPainter *scenePainter() const override;
QPainterBackend *backend() const {
return m_backend.data();
......@@ -252,7 +252,7 @@ OverlayWindow* SceneQPainter::overlayWindow()
}
inline
QPainter* SceneQPainter::painter()
QPainter* SceneQPainter::scenePainter() const
{
return m_painter.data();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment