From 44e1526ee2585c0402c284aa94eb2472fa4a4145 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Wed, 18 May 2011 16:17:17 +0200 Subject: Change the flushing of the CGContext to a synchronization. When many NSView are being drawn, calling CGContextFlush() is too expensive and some flickering becomes apparent. We now call CGContextSynchronize() instead. Since this solves the flickering problem, we can now call setNeedsDisplay: for items in the unified toolbar. This allows us to smootly trigger many flushings inside the unified toolbar. Task-number: QTBUG-19267 Reviewed-by: Jiang Jiang --- src/gui/kernel/qcocoaview_mac.mm | 2 +- src/gui/painting/qunifiedtoolbarsurface_mac.cpp | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index b5e5d18..578970c 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -320,7 +320,7 @@ static int qCocoaViewCount = 0; } - CGContextFlush(context); + CGContextSynchronize(context); qt_mac_release_graphics_context(context); return; } diff --git a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp index 2fda6b9..94a7417 100644 --- a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp +++ b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp @@ -171,10 +171,8 @@ void QUnifiedToolbarSurface::flush(QWidget *widget) if (!d->image) return; - if (widget->d_func()->flushRequested) { - // We call display: directly to avoid flickering in the toolbar. - qt_mac_display(widget); - } + if (widget->d_func()->flushRequested) + qt_mac_setNeedsDisplay(widget); } void QUnifiedToolbarSurface::prepareBuffer(QImage::Format format, QWidget *widget) -- cgit v0.12