diff options
author | Fabien Freling <fabien.freling@nokia.com> | 2011-02-14 16:23:00 +0100 |
---|---|---|
committer | Fabien Freling <fabien.freling@nokia.com> | 2011-02-15 13:49:38 +0100 |
commit | 78c5c1cae5f9e100bfb7388f68208406f0db4b42 (patch) | |
tree | 3dc89f26963c084ead61ec0ccefac9981e94866c /src/gui/kernel | |
parent | 7da16ed9888133039c6d7a261fc7c4b61d9b6114 (diff) |
Optimize the rendering path for the unified toolbar.
The over flushing of the toolbar had a huge
performance impact so now we only flush the toolbar
when necessary and moved the rendering out of the
flushing process.
Reviewed-by: Richard Moe Gustavsen
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qcocoaview_mac.mm | 10 | ||||
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 17 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_p.h | 4 |
3 files changed, 21 insertions, 10 deletions
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index e50c401d2e..1fe96f81dd 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -581,20 +581,12 @@ static int qCocoaViewCount = 0; } else { - QUnifiedToolbarSurface *unifiedSurface = dynamic_cast<QUnifiedToolbarSurface *>(qwidgetprivate->unifiedSurface); + QUnifiedToolbarSurface *unifiedSurface = qwidgetprivate->unifiedSurface; if (!unifiedSurface || !qwidgetprivate->flushRequested) { qt_mac_release_graphics_context(context); return; } - // We render the content of the toolbar in the surface. - unifiedSurface->updateToolbarOffset(qwidget); - QRect beginPaintRect(qwidgetprivate->toolbar_offset.x(), qwidgetprivate->toolbar_offset.y(), qwidget->geometry().width(), qwidget->geometry().height()); - QRegion beginPaintRegion(beginPaintRect); - - unifiedSurface->beginPaint(beginPaintRegion); - qwidget->render(unifiedSurface->paintDevice(), qwidgetprivate->toolbar_offset, QRegion(), QWidget::DrawChildren); - int areaX = qwidgetprivate->toolbar_offset.x(); int areaY = qwidgetprivate->toolbar_offset.y(); int areaWidth = qwidget->geometry().width(); diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 04bc2fbfc3..84a839f88e 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -324,6 +324,7 @@ QWidgetPrivate::QWidgetPrivate(int version) hasOwnContext = false; isInUnifiedToolbar = false; unifiedSurface = 0; + toolbar_ancestor = 0; flushRequested = false; #endif // QT_MAC_USE_COCOA #ifdef QWIDGET_EXTRA_DEBUG @@ -10360,6 +10361,10 @@ void QWidget::repaint(const QRect &rect) return; if (hasBackingStoreSupport()) { + if (qt_widget_private(this)->isInUnifiedToolbar) { + qt_widget_private(this)->unifiedSurface->renderToolbar(this, true); + return; + } QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) { tlwExtra->inRepaint = true; @@ -10389,6 +10394,10 @@ void QWidget::repaint(const QRegion &rgn) return; if (hasBackingStoreSupport()) { + if (qt_widget_private(this)->isInUnifiedToolbar) { + qt_widget_private(this)->unifiedSurface->renderToolbar(this, true); + return; + } QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) { tlwExtra->inRepaint = true; @@ -10446,6 +10455,10 @@ void QWidget::update(const QRect &rect) } if (hasBackingStoreSupport()) { + if (qt_widget_private(this)->isInUnifiedToolbar) { + qt_widget_private(this)->unifiedSurface->renderToolbar(this); + return; + } QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) tlwExtra->backingStore->markDirty(rect, this); @@ -10470,6 +10483,10 @@ void QWidget::update(const QRegion &rgn) } if (hasBackingStoreSupport()) { + if (qt_widget_private(this)->isInUnifiedToolbar) { + qt_widget_private(this)->unifiedSurface->renderToolbar(this); + return; + } QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) tlwExtra->backingStore->markDirty(rgn, this); diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 921cf03eb3..59cb7377f3 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -79,6 +79,7 @@ #ifdef Q_WS_MAC #include <private/qt_mac_p.h> +#include <private/qunifiedtoolbarsurface_mac_p.h> #endif #if defined(Q_WS_QWS) @@ -855,8 +856,9 @@ public: // Unified toolbar variables bool isInUnifiedToolbar; - QWindowSurface *unifiedSurface; + QUnifiedToolbarSurface *unifiedSurface; QPoint toolbar_offset; + QWidget *toolbar_ancestor; bool flushRequested; #endif // QT_MAC_USE_COCOA void determineWindowClass(); |