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

Add virtual Scene::xrenderBufferPicture method

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

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

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7207
parent 83790306
......@@ -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_xrender.h"
#include "scene_qpainter.h"
#include "unmanaged.h"
#ifdef KWIN_BUILD_TABBOX
......@@ -1324,11 +1323,7 @@ void EffectsHandlerImpl::unregisterTouchBorder(ElectricBorder border, QAction *a
unsigned long EffectsHandlerImpl::xrenderBufferPicture()
{
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
if (SceneXrender* s = dynamic_cast< SceneXrender* >(m_scene))
return s->bufferPicture();
#endif
return None;
return m_scene->xrenderBufferPicture();
}
QPainter *EffectsHandlerImpl::scenePainter()
......
......@@ -652,6 +652,11 @@ QMatrix4x4 Scene::screenProjectionMatrix() const
return QMatrix4x4();
}
xcb_render_picture_t Scene::xrenderBufferPicture() const
{
return XCB_RENDER_PICTURE_NONE;
}
//****************************************
// Scene::Window
//****************************************
......
......@@ -157,6 +157,12 @@ public:
**/
virtual bool animationsSupported() const = 0;
/**
* The render buffer used by an XRender based compositor scene.
* Default implementation returns XCB_RENDER_PICTURE_NONE
**/
virtual xcb_render_picture_t xrenderBufferPicture() const;
Q_SIGNALS:
void frameRendered();
......
......@@ -280,7 +280,7 @@ void SceneXrender::paintBackground(QRegion region)
{
xcb_render_color_t col = { 0, 0, 0, 0xffff }; // black
const QVector<xcb_rectangle_t> &rects = Xcb::regionToRects(region);
xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, bufferPicture(), col, rects.count(), rects.data());
xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, xrenderBufferPicture(), col, rects.count(), rects.data());
}
Scene::Window *SceneXrender::createWindow(Toplevel *toplevel)
......@@ -515,7 +515,7 @@ void SceneXrender::Window::performPaint(int mask, QRegion region, WindowPaintDat
const bool blitInTempPixmap = xRenderOffscreen() || (data.crossFadeProgress() < 1.0 && !opaque) ||
(scaled && (wantShadow || (client && !client->noBorder()) || (deleted && !deleted->noBorder())));
xcb_render_picture_t renderTarget = m_scene->bufferPicture();
xcb_render_picture_t renderTarget = m_scene->xrenderBufferPicture();
if (blitInTempPixmap) {
if (scene_xRenderOffscreenTarget()) {
temp_visibleRect = toplevel->visibleRect().translated(-toplevel->pos());
......@@ -729,7 +729,7 @@ xcb_render_composite(connection(), XCB_RENDER_PICT_OP_OVER, m_xrenderShadow->pic
xcb_render_set_picture_transform(connection(), *s_tempPicture, xform);
setPictureFilter(*s_tempPicture, filter);
xcb_render_composite(connection(), XCB_RENDER_PICT_OP_OVER, *s_tempPicture,
XCB_RENDER_PICTURE_NONE, m_scene->bufferPicture(),
XCB_RENDER_PICTURE_NONE, m_scene->xrenderBufferPicture(),
0, 0, 0, 0, r.x(), r.y(), r.width(), r.height());
xcb_render_set_picture_transform(connection(), *s_tempPicture, identity);
}
......
......@@ -160,7 +160,7 @@ public:
virtual Scene::EffectFrame *createEffectFrame(EffectFrameImpl *frame);
virtual Shadow *createShadow(Toplevel *toplevel);
virtual void screenGeometryChanged(const QSize &size);
xcb_render_picture_t bufferPicture();
xcb_render_picture_t xrenderBufferPicture() const override;
virtual OverlayWindow *overlayWindow() {
return m_backend->overlayWindow();
}
......@@ -253,7 +253,7 @@ private:
};
inline
xcb_render_picture_t SceneXrender::bufferPicture()
xcb_render_picture_t SceneXrender::xrenderBufferPicture() const
{
return m_backend->buffer();
}
......
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