From 5339b1a9d738a3882bbfa15b7b85b1b7b4785d24 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 10 Jun 2021 14:18:42 +0300 Subject: [PATCH] scene: Move item preprocessing to scene We no longer use window pixmaps to get the shape and the opaque regions, so preprocess() can be called now only if we are about to paint the item. --- src/item.h | 4 +--- src/plugins/scenes/opengl/scene_opengl.cpp | 2 ++ src/plugins/scenes/qpainter/scene_qpainter.cpp | 1 + src/scene.cpp | 16 ---------------- src/scene.h | 1 - 5 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/item.h b/src/item.h index b12e3c2b15..e93902cbf7 100644 --- a/src/item.h +++ b/src/item.h @@ -100,6 +100,7 @@ public: void resetRepaints(int screen); WindowQuadList quads() const; + virtual void preprocess(); Q_SIGNALS: /** @@ -126,7 +127,6 @@ Q_SIGNALS: void boundingRectChanged(); protected: - virtual void preprocess(); virtual WindowQuadList buildQuads() const; void discardQuads(); @@ -153,8 +153,6 @@ private: QVector m_repaints; mutable WindowQuadList m_quads; mutable bool m_quadsValid = false; - - friend class Scene::Window; }; } // namespace KWin diff --git a/src/plugins/scenes/opengl/scene_opengl.cpp b/src/plugins/scenes/opengl/scene_opengl.cpp index b7cc4a9484..33fa84aafc 100644 --- a/src/plugins/scenes/opengl/scene_opengl.cpp +++ b/src/plugins/scenes/opengl/scene_opengl.cpp @@ -1217,6 +1217,8 @@ static WindowQuadList clipQuads(const Item *item, const OpenGLWindow::RenderCont void OpenGLWindow::createRenderNode(Item *item, RenderContext *context) { + item->preprocess(); + if (auto shadowItem = qobject_cast(item)) { WindowQuadList quads = clipQuads(item, context); if (!quads.isEmpty()) { diff --git a/src/plugins/scenes/qpainter/scene_qpainter.cpp b/src/plugins/scenes/qpainter/scene_qpainter.cpp index add8766994..0a7204f5c2 100644 --- a/src/plugins/scenes/qpainter/scene_qpainter.cpp +++ b/src/plugins/scenes/qpainter/scene_qpainter.cpp @@ -245,6 +245,7 @@ void SceneQPainter::Window::performPaint(int mask, const QRegion &_region, const void SceneQPainter::Window::renderItem(QPainter *painter, Item *item) const { + item->preprocess(); painter->save(); painter->translate(item->position()); diff --git a/src/scene.cpp b/src/scene.cpp index fddc7aa4cb..5f4eec916b 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -239,9 +239,6 @@ void Scene::paintGenericScreen(int orig_mask, const ScreenPaintData &) QVector phase2; phase2.reserve(stacking_order.size()); Q_FOREACH (Window * w, stacking_order) { // bottom to top - // Let the scene window update the window pixmap tree. - w->preprocess(w->windowItem()); - // Reset the repaint_region. // This has to be done here because many effects schedule a repaint for // the next frame within Effects::prePaintWindow. @@ -311,9 +308,6 @@ void Scene::paintSimpleScreen(int orig_mask, const QRegion ®ion) data.paint = region; accumulateRepaints(window->windowItem(), painted_screen, &data.paint); - // Let the scene window update the window pixmap tree. - window->preprocess(window->windowItem()); - // Clip out the decoration for opaque windows; the decoration is drawn in the second pass opaqueFullscreen = false; // TODO: do we care about unmanged windows here (maybe input windows?) AbstractClient *client = dynamic_cast(toplevel); @@ -859,16 +853,6 @@ void Scene::Window::disablePainting(int reason) disable_painting |= reason; } -void Scene::Window::preprocess(Item *item) -{ - item->preprocess(); - - const QList children = item->childItems(); - for (Item *child : children) { - preprocess(child); - } -} - WindowItem *Scene::Window::windowItem() const { return m_windowItem.data(); diff --git a/src/scene.h b/src/scene.h index 3cb4ef7396..7033577bed 100644 --- a/src/scene.h +++ b/src/scene.h @@ -340,7 +340,6 @@ public: void updateToplevel(Deleted *deleted); void referencePreviousPixmap(); void unreferencePreviousPixmap(); - void preprocess(Item *item); WindowItem *windowItem() const; SurfaceItem *surfaceItem() const; ShadowItem *shadowItem() const;