From ea83669b9b44b1fb3a5acae6d53afd1df401e9b5 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Tue, 16 Jun 2009 09:51:09 +0200 Subject: Don't mark ItemHasNoContents items as dirty, ever. The QGraphicsItem::ItemHasNoContents flag ensures that we don't have to ever paint this item. So let's not mark it as dirty at all (items are marked as dirty when updated, moved, or transformed). This is a minor optimization. Reviewed-by: bnilsen --- src/gui/graphicsview/qgraphicsscene.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 38a1abe..1340adf 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -5282,11 +5282,14 @@ void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, b return; } - item->d_ptr->dirty = 1; - if (fullItemUpdate) - item->d_ptr->fullUpdatePending = 1; - else if (!item->d_ptr->fullUpdatePending) - item->d_ptr->needsRepaint |= rect; + bool hasNoContents = item->d_ptr->flags & QGraphicsItem::ItemHasNoContents; + if (!hasNoContents) { + item->d_ptr->dirty = 1; + if (fullItemUpdate) + item->d_ptr->fullUpdatePending = 1; + else if (!item->d_ptr->fullUpdatePending) + item->d_ptr->needsRepaint |= rect; + } if (invalidateChildren) { item->d_ptr->allChildrenDirty = 1; -- cgit v0.12