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.
This commit is contained in:
Vlad Zahorodnii 2021-06-10 14:18:42 +03:00
parent 49744cfc53
commit 5339b1a9d7
5 changed files with 4 additions and 20 deletions

View file

@ -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<QRegion> m_repaints;
mutable WindowQuadList m_quads;
mutable bool m_quadsValid = false;
friend class Scene::Window;
};
} // namespace KWin

View file

@ -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<ShadowItem *>(item)) {
WindowQuadList quads = clipQuads(item, context);
if (!quads.isEmpty()) {

View file

@ -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());

View file

@ -239,9 +239,6 @@ void Scene::paintGenericScreen(int orig_mask, const ScreenPaintData &)
QVector<Phase2Data> 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 &region)
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<AbstractClient *>(toplevel);
@ -859,16 +853,6 @@ void Scene::Window::disablePainting(int reason)
disable_painting |= reason;
}
void Scene::Window::preprocess(Item *item)
{
item->preprocess();
const QList<Item *> children = item->childItems();
for (Item *child : children) {
preprocess(child);
}
}
WindowItem *Scene::Window::windowItem() const
{
return m_windowItem.data();

View file

@ -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;