diff --git a/plugins/scenes/opengl/scene_opengl.h b/plugins/scenes/opengl/scene_opengl.h --- a/plugins/scenes/opengl/scene_opengl.h +++ b/plugins/scenes/opengl/scene_opengl.h @@ -46,7 +46,7 @@ ~SceneOpenGL() override; bool initFailed() const override; bool hasPendingFlush() const override; - qint64 paint(QRegion damage, QList windows) override; + qint64 paint(const QRegion &damage, const QList &windows) override; Scene::EffectFrame *createEffectFrame(EffectFrameImpl *frame) override; Shadow *createShadow(Toplevel *toplevel) override; void screenGeometryChanged(const QSize &size) override; @@ -85,7 +85,7 @@ protected: SceneOpenGL(OpenGLBackend *backend, QObject *parent = nullptr); - void paintBackground(QRegion region) override; + void paintBackground(const QRegion ®ion) override; void extendPaintRegion(QRegion ®ion, bool opaqueFullscreen) override; QMatrix4x4 transformation(int mask, const ScreenPaintData &data) const; void paintDesktop(int desktop, int mask, const QRegion ®ion, ScreenPaintData &data) override; @@ -123,16 +123,16 @@ QMatrix4x4 screenProjectionMatrix() const override { return m_screenProjectionMatrix; } protected: - void paintSimpleScreen(int mask, QRegion region) override; - void paintGenericScreen(int mask, ScreenPaintData data) override; + void paintSimpleScreen(int mask, const QRegion ®ion) override; + void paintGenericScreen(int mask, const ScreenPaintData &data) override; void doPaintBackground(const QVector< float >& vertices) override; Scene::Window *createWindow(Toplevel *t) override; - void finalDrawWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data) override; + void finalDrawWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data) override; void updateProjectionMatrix() override; void paintCursor() override; private: - void performPaintWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data); + void performPaintWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data); QMatrix4x4 createProjectionMatrix() const; private: @@ -174,7 +174,7 @@ ~OpenGLWindow() override; WindowPixmap *createWindowPixmap() override; - void performPaint(int mask, QRegion region, WindowPaintData data) override; + void performPaint(int mask, const QRegion ®ion, const WindowPaintData &data) override; private: QMatrix4x4 transformation(int mask, const WindowPaintData &data) const; @@ -222,7 +222,7 @@ void freeTextFrame() override; void freeSelection() override; - void render(QRegion region, double opacity, double frameOpacity) override; + void render(const QRegion ®ion, double opacity, double frameOpacity) override; void crossFadeIcon() override; void crossFadeText() override; diff --git a/plugins/scenes/opengl/scene_opengl.cpp b/plugins/scenes/opengl/scene_opengl.cpp --- a/plugins/scenes/opengl/scene_opengl.cpp +++ b/plugins/scenes/opengl/scene_opengl.cpp @@ -614,7 +614,7 @@ glDisable(GL_BLEND); } -qint64 SceneOpenGL::paint(QRegion damage, QList toplevels) +qint64 SceneOpenGL::paint(const QRegion &damage, const QList &toplevels) { // actually paint the frame, flushed with the NEXT frame createStackingOrder(toplevels); @@ -734,7 +734,7 @@ return matrix; } -void SceneOpenGL::paintBackground(QRegion region) +void SceneOpenGL::paintBackground(const QRegion ®ion) { PaintClipper pc(region); if (!PaintClipper::clip()) { @@ -1000,14 +1000,14 @@ m_projectionMatrix = createProjectionMatrix(); } -void SceneOpenGL2::paintSimpleScreen(int mask, QRegion region) +void SceneOpenGL2::paintSimpleScreen(int mask, const QRegion ®ion) { m_screenProjectionMatrix = m_projectionMatrix; Scene::paintSimpleScreen(mask, region); } -void SceneOpenGL2::paintGenericScreen(int mask, ScreenPaintData data) +void SceneOpenGL2::paintGenericScreen(int mask, const ScreenPaintData &data) { const QMatrix4x4 screenMatrix = transformation(mask, data); @@ -1034,15 +1034,15 @@ return new OpenGLWindow(t, this); } -void SceneOpenGL2::finalDrawWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data) +void SceneOpenGL2::finalDrawWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data) { if (waylandServer() && waylandServer()->isScreenLocked() && !w->window()->isLockScreen() && !w->window()->isInputMethod()) { return; } performPaintWindow(w, mask, region, data); } -void SceneOpenGL2::performPaintWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data) +void SceneOpenGL2::performPaintWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data) { if (mask & PAINT_WINDOW_LANCZOS) { if (!m_lanczosFilter) { @@ -1332,8 +1332,9 @@ } } -void OpenGLWindow::performPaint(int mask, QRegion region, WindowPaintData data) +void OpenGLWindow::performPaint(int mask, const QRegion ®ion, const WindowPaintData &_data) { + WindowPaintData data = _data; if (!beginRenderWindow(mask, region, data)) return; @@ -1710,12 +1711,13 @@ m_textTexture = nullptr; } -void SceneOpenGL::EffectFrame::render(QRegion region, double opacity, double frameOpacity) +void SceneOpenGL::EffectFrame::render(const QRegion &_region, double opacity, double frameOpacity) { if (m_effectFrame->geometry().isEmpty()) return; // Nothing to display - region = infiniteRegion(); // TODO: Old region doesn't seem to work with OpenGL + Q_UNUSED(_region); + const QRegion region = infiniteRegion(); // TODO: Old region doesn't seem to work with OpenGL GLShader* shader = m_effectFrame->shader(); if (!shader) { diff --git a/plugins/scenes/qpainter/scene_qpainter.h b/plugins/scenes/qpainter/scene_qpainter.h --- a/plugins/scenes/qpainter/scene_qpainter.h +++ b/plugins/scenes/qpainter/scene_qpainter.h @@ -36,8 +36,8 @@ ~SceneQPainter() override; bool usesOverlayWindow() const override; OverlayWindow* overlayWindow() const override; - qint64 paint(QRegion damage, QList windows) override; - void paintGenericScreen(int mask, ScreenPaintData data) override; + qint64 paint(const QRegion &damage, const QList &windows) override; + void paintGenericScreen(int mask, const ScreenPaintData &data) override; CompositingType compositingType() const override; bool initFailed() const override; EffectFrame *createEffectFrame(EffectFrameImpl *frame) override; @@ -59,7 +59,7 @@ static SceneQPainter *createScene(QObject *parent); protected: - void paintBackground(QRegion region) override; + void paintBackground(const QRegion ®ion) override; Scene::Window *createWindow(Toplevel *toplevel) override; void paintCursor() override; void paintEffectQuickView(EffectQuickView *w) override; @@ -76,7 +76,7 @@ public: Window(SceneQPainter *scene, Toplevel *c); ~Window() override; - void performPaint(int mask, QRegion region, WindowPaintData data) override; + void performPaint(int mask, const QRegion ®ion, const WindowPaintData &data) override; protected: WindowPixmap *createWindowPixmap() override; private: @@ -114,7 +114,7 @@ void freeIconFrame() override {} void freeTextFrame() override {} void freeSelection() override {} - void render(QRegion region, double opacity, double frameOpacity) override; + void render(const QRegion ®ion, double opacity, double frameOpacity) override; private: SceneQPainter *m_scene; }; diff --git a/plugins/scenes/qpainter/scene_qpainter.cpp b/plugins/scenes/qpainter/scene_qpainter.cpp --- a/plugins/scenes/qpainter/scene_qpainter.cpp +++ b/plugins/scenes/qpainter/scene_qpainter.cpp @@ -82,21 +82,22 @@ return false; } -void SceneQPainter::paintGenericScreen(int mask, ScreenPaintData data) +void SceneQPainter::paintGenericScreen(int mask, const ScreenPaintData &data) { m_painter->save(); m_painter->translate(data.xTranslation(), data.yTranslation()); m_painter->scale(data.xScale(), data.yScale()); Scene::paintGenericScreen(mask, data); m_painter->restore(); } -qint64 SceneQPainter::paint(QRegion damage, QList toplevels) +qint64 SceneQPainter::paint(const QRegion &_damage, const QList &toplevels) { QElapsedTimer renderTimer; renderTimer.start(); createStackingOrder(toplevels); + QRegion damage = _damage; int mask = 0; m_backend->prepareRenderingFrame(); @@ -153,7 +154,7 @@ return renderTimer.nsecsElapsed(); } -void SceneQPainter::paintBackground(QRegion region) +void SceneQPainter::paintBackground(const QRegion ®ion) { m_painter->setBrush(Qt::black); for (const QRect &rect : region) { @@ -256,8 +257,9 @@ return false; } -void SceneQPainter::Window::performPaint(int mask, QRegion region, WindowPaintData data) +void SceneQPainter::Window::performPaint(int mask, const QRegion &_region, const WindowPaintData &data) { + QRegion region = _region; if (!(mask & (PAINT_WINDOW_TRANSFORMED | PAINT_SCREEN_TRANSFORMED))) region &= toplevel->visibleRect(); @@ -489,7 +491,7 @@ { } -void QPainterEffectFrame::render(QRegion region, double opacity, double frameOpacity) +void QPainterEffectFrame::render(const QRegion ®ion, double opacity, double frameOpacity) { Q_UNUSED(region) Q_UNUSED(opacity) diff --git a/plugins/scenes/xrender/scene_xrender.h b/plugins/scenes/xrender/scene_xrender.h --- a/plugins/scenes/xrender/scene_xrender.h +++ b/plugins/scenes/xrender/scene_xrender.h @@ -154,7 +154,7 @@ CompositingType compositingType() const override { return XRenderCompositing; } - qint64 paint(QRegion damage, QList windows) override; + qint64 paint(const QRegion &damage, const QList &windows) override; Scene::EffectFrame *createEffectFrame(EffectFrameImpl *frame) override; Shadow *createShadow(Toplevel *toplevel) override; void screenGeometryChanged(const QSize &size) override; @@ -174,8 +174,8 @@ static SceneXrender *createScene(QObject *parent); protected: Scene::Window *createWindow(Toplevel *toplevel) override; - void paintBackground(QRegion region) override; - void paintGenericScreen(int mask, ScreenPaintData data) override; + void paintBackground(const QRegion ®ion) override; + void paintGenericScreen(int mask, const ScreenPaintData &data) override; void paintDesktop(int desktop, int mask, const QRegion ®ion, ScreenPaintData &data) override; void paintCursor() override; void paintEffectQuickView(EffectQuickView *w) override; @@ -192,7 +192,7 @@ public: Window(Toplevel* c, SceneXrender *scene); ~Window() override; - void performPaint(int mask, QRegion region, WindowPaintData data) override; + void performPaint(int mask, const QRegion ®ion, const WindowPaintData &data) override; QRegion transformedShape() const; void setTransformedShape(const QRegion& shape); static void cleanup(); @@ -238,7 +238,7 @@ void freeSelection() override; void crossFadeIcon() override; void crossFadeText() override; - void render(QRegion region, double opacity, double frameOpacity) override; + void render(const QRegion ®ion, double opacity, double frameOpacity) override; static void cleanup(); private: diff --git a/plugins/scenes/xrender/scene_xrender.cpp b/plugins/scenes/xrender/scene_xrender.cpp --- a/plugins/scenes/xrender/scene_xrender.cpp +++ b/plugins/scenes/xrender/scene_xrender.cpp @@ -249,7 +249,7 @@ } // the entry point for painting -qint64 SceneXrender::paint(QRegion damage, QList toplevels) +qint64 SceneXrender::paint(const QRegion &damage, const QList &toplevels) { QElapsedTimer renderTimer; renderTimer.start(); @@ -269,7 +269,7 @@ return renderTimer.nsecsElapsed(); } -void SceneXrender::paintGenericScreen(int mask, ScreenPaintData data) +void SceneXrender::paintGenericScreen(int mask, const ScreenPaintData &data) { screen_paint = data; // save, transformations will be done when painting windows Scene::paintGenericScreen(mask, data); @@ -283,7 +283,7 @@ } // fill the screen background -void SceneXrender::paintBackground(QRegion region) +void SceneXrender::paintBackground(const QRegion ®ion) { xcb_render_color_t col = { 0, 0, 0, 0xffff }; // black const QVector &rects = Xcb::regionToRects(region); @@ -418,8 +418,9 @@ } // paint the window -void SceneXrender::Window::performPaint(int mask, QRegion region, WindowPaintData data) +void SceneXrender::Window::performPaint(int mask, const QRegion &_region, const WindowPaintData &data) { + QRegion region = _region; setTransformedShape(QRegion()); // maybe nothing will be painted // check if there is something to paint bool opaque = isOpaque() && qFuzzyCompare(data.opacity(), 1.0); @@ -894,7 +895,7 @@ // TODO: implement me } -void SceneXrender::EffectFrame::render(QRegion region, double opacity, double frameOpacity) +void SceneXrender::EffectFrame::render(const QRegion ®ion, double opacity, double frameOpacity) { Q_UNUSED(region) if (m_effectFrame->geometry().isEmpty()) { diff --git a/scene.h b/scene.h --- a/scene.h +++ b/scene.h @@ -76,7 +76,7 @@ // The entry point for the main part of the painting pass. // returns the time since the last vblank signal - if there's one // ie. "what of this frame is lost to painting" - virtual qint64 paint(QRegion damage, QList windows) = 0; + virtual qint64 paint(const QRegion &damage, const QList &windows) = 0; /** * Adds the Toplevel to the Scene. @@ -209,29 +209,29 @@ void windowClosed(KWin::Toplevel* c, KWin::Deleted* deleted); protected: virtual Window *createWindow(Toplevel *toplevel) = 0; - void createStackingOrder(QList toplevels); + void createStackingOrder(const QList &toplevels); void clearStackingOrder(); // shared implementation, starts painting the screen void paintScreen(int *mask, const QRegion &damage, const QRegion &repaint, QRegion *updateRegion, QRegion *validRegion, const QMatrix4x4 &projection = QMatrix4x4(), const QRect &outputGeometry = QRect()); // Render cursor texture in case hardware cursor is disabled/non-applicable virtual void paintCursor() = 0; friend class EffectsHandlerImpl; // called after all effects had their paintScreen() called - void finalPaintScreen(int mask, QRegion region, ScreenPaintData& data); + void finalPaintScreen(int mask, const QRegion ®ion, ScreenPaintData& data); // shared implementation of painting the screen in the generic // (unoptimized) way - virtual void paintGenericScreen(int mask, ScreenPaintData data); + virtual void paintGenericScreen(int mask, const ScreenPaintData &data); // shared implementation of painting the screen in an optimized way - virtual void paintSimpleScreen(int mask, QRegion region); + virtual void paintSimpleScreen(int mask, const QRegion ®ion); // paint the background (not the desktop background - the whole background) - virtual void paintBackground(QRegion region) = 0; + virtual void paintBackground(const QRegion ®ion) = 0; // called after all effects had their paintWindow() called - void finalPaintWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data); + void finalPaintWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data); // shared implementation, starts painting the window - virtual void paintWindow(Window* w, int mask, QRegion region, WindowQuadList quads); + virtual void paintWindow(Window* w, int mask, const QRegion ®ion, const WindowQuadList &quads); // called after all effects had their drawWindow() called - virtual void finalDrawWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data); + virtual void finalDrawWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data); // let the scene decide whether it's better to paint more of the screen, eg. in order to allow a buffer swap // the default is NOOP virtual void extendPaintRegion(QRegion ®ion, bool opaqueFullscreen); @@ -263,7 +263,7 @@ int time_diff; QElapsedTimer last_time; private: - void paintWindowThumbnails(Scene::Window *w, QRegion region, qreal opacity, qreal brightness, qreal saturation); + void paintWindowThumbnails(Scene::Window *w, const QRegion ®ion, qreal opacity, qreal brightness, qreal saturation); void paintDesktopThumbnails(Scene::Window *w); QHash< Toplevel*, Window* > m_windows; // windows in their stacking order @@ -295,7 +295,7 @@ Window(Toplevel* c); virtual ~Window(); // perform the actual painting of the window - virtual void performPaint(int mask, QRegion region, WindowPaintData data) = 0; + virtual void performPaint(int mask, const QRegion ®ion, const WindowPaintData &data) = 0; // do any cleanup needed when the window's composite pixmap is discarded void discardPixmap(); void updatePixmap(); @@ -530,7 +530,7 @@ public: EffectFrame(EffectFrameImpl* frame); virtual ~EffectFrame(); - virtual void render(QRegion region, double opacity, double frameOpacity) = 0; + virtual void render(const QRegion ®ion, double opacity, double frameOpacity) = 0; virtual void free() = 0; virtual void freeIconFrame() = 0; virtual void freeTextFrame() = 0; diff --git a/scene.cpp b/scene.cpp --- a/scene.cpp +++ b/scene.cpp @@ -191,7 +191,7 @@ } // the function that'll be eventually called by paintScreen() above -void Scene::finalPaintScreen(int mask, QRegion region, ScreenPaintData& data) +void Scene::finalPaintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) { if (mask & (PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS)) paintGenericScreen(mask, data); @@ -201,7 +201,7 @@ // The generic painting code that can handle even transformations. // It simply paints bottom-to-top. -void Scene::paintGenericScreen(int orig_mask, ScreenPaintData) +void Scene::paintGenericScreen(int orig_mask, const ScreenPaintData &) { if (!(orig_mask & PAINT_SCREEN_BACKGROUND_FIRST)) { paintBackground(infiniteRegion()); @@ -246,7 +246,7 @@ // The optimized case without any transformations at all. // It can paint only the requested region and can use clipping // to reduce painting and improve performance. -void Scene::paintSimpleScreen(int orig_mask, QRegion region) +void Scene::paintSimpleScreen(int orig_mask, const QRegion ®ion) { Q_ASSERT((orig_mask & (PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS)) == 0); @@ -441,7 +441,7 @@ w->discardShape(); } -void Scene::createStackingOrder(QList toplevels) +void Scene::createStackingOrder(const QList &toplevels) { // TODO: cache the stacking_order in case it has not changed foreach (Toplevel *c, toplevels) { @@ -457,11 +457,10 @@ static Scene::Window *s_recursionCheck = nullptr; -void Scene::paintWindow(Window* w, int mask, QRegion region, WindowQuadList quads) +void Scene::paintWindow(Window* w, int mask, const QRegion &_region, const WindowQuadList &quads) { // no painting outside visible screen (and no transformations) - const QSize &screenSize = screens()->size(); - region &= QRect(0, 0, screenSize.width(), screenSize.height()); + const QRegion region = _region & QRect({0, 0}, screens()->size()); if (region.isEmpty()) // completely clipped return; if (w->window()->isDeleted() && w->window()->skipsCloseAnimation()) { @@ -504,7 +503,7 @@ } } -void Scene::paintWindowThumbnails(Scene::Window *w, QRegion region, qreal opacity, qreal brightness, qreal saturation) +void Scene::paintWindowThumbnails(Scene::Window *w, const QRegion ®ion, qreal opacity, qreal brightness, qreal saturation) { EffectWindowImpl *wImpl = static_cast(effectWindow(w)); for (QHash >::const_iterator it = wImpl->thumbnails().constBegin(); @@ -601,13 +600,13 @@ } // the function that'll be eventually called by paintWindow() above -void Scene::finalPaintWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data) +void Scene::finalPaintWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data) { effects->drawWindow(w, mask, region, data); } // will be eventually called from drawWindow() -void Scene::finalDrawWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data) +void Scene::finalDrawWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data) { if (waylandServer() && waylandServer()->isScreenLocked() && !w->window()->isLockScreen() && !w->window()->isInputMethod()) { return;