summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qwindowsurface_raster.cpp
diff options
context:
space:
mode:
authorFabien Freling <fabien.freling@nokia.com>2011-01-25 15:23:34 +0100
committerFabien Freling <fabien.freling@nokia.com>2011-01-26 12:25:48 +0100
commit26d25ab46900d84b44e451c2a0a986bfed94a3f4 (patch)
treebbc66fa6f2d1c4f0126663efbadbaddc1020b686 /src/gui/painting/qwindowsurface_raster.cpp
parent85b8631c2f30947e3c8364c903a4f85abb8f11e2 (diff)
Move the flushing to [view drawRect:rect]
Instead of flushing by grabbing the Core Graphics context, we do it directly in the drawRect: method. This approach allows us to call flush() many times and only proceed to flush when the system is ready. Reviewed-by: Richard Moe Gustavsen
Diffstat (limited to 'src/gui/painting/qwindowsurface_raster.cpp')
-rw-r--r--src/gui/painting/qwindowsurface_raster.cpp42
1 files changed, 27 insertions, 15 deletions
diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp
index 2b4e12521e..92e9425a25 100644
--- a/src/gui/painting/qwindowsurface_raster.cpp
+++ b/src/gui/painting/qwindowsurface_raster.cpp
@@ -98,6 +98,11 @@ QRasterWindowSurface::QRasterWindowSurface(QWidget *window, bool setDefaultSurfa
d_ptr->image = 0;
d_ptr->inSetGeometry = false;
setStaticContentsSupport(true);
+
+#ifdef QT_MAC_USE_COCOA
+ needsFlush = false;
+ regionToFlush = QRegion();
+#endif // QT_MAC_USE_COCOA
}
@@ -251,13 +256,23 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi
#ifdef Q_WS_MAC
+ Q_UNUSED(offset);
+
// This is mainly done for native components like native "open file" dialog.
if (widget->testAttribute(Qt::WA_DontShowOnScreen)) {
return;
}
#ifdef QT_MAC_USE_COCOA
+ this->needsFlush = true;
+ this->regionToFlush += rgn;
+
+ // The actual flushing will be processed in [view drawRect:rect]
+ qt_mac_setneedsdisplay(widget);
+
// Unified toolbar hack.
+ // We issue a flush call for each QToolBar so they get repainted right after
+ // the main window.
QMainWindow* mWindow = qobject_cast<QMainWindow*>(widget->window());
if (mWindow) {
QMainWindowLayout *mLayout = qobject_cast<QMainWindowLayout*>(mWindow->layout());
@@ -267,24 +282,17 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi
QToolBar* toolbar = toolbarList.at(i);
if (mLayout->toolBarArea(toolbar) == Qt::TopToolBarArea) {
QWidget* tbWidget = (QWidget*) toolbar;
- if (tbWidget->d_func()->unifiedSurface) {
+ if (tbWidget->d_func()->unifiedSurface)
tbWidget->d_func()->unifiedSurface->flush(tbWidget, rgn, offset);
- }
}
}
}
-#endif // QT_MAC_USE_COCOA
-
- Q_UNUSED(offset);
+#else
// Get a context for the widget.
-#ifndef QT_MAC_USE_COCOA
CGContextRef context;
CGrafPtr port = GetWindowPort(qt_mac_window_for(widget));
QDBeginCGContext(port, &context);
-#else
- extern CGContextRef qt_mac_graphicsContextFor(QWidget *);
- CGContextRef context = qt_mac_graphicsContextFor(widget);
-#endif
+
CGContextRetain(context);
CGContextSaveGState(context);
@@ -310,16 +318,12 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi
CGImageRelease(subImage);
CGImageRelease(image);
-#ifndef QT_MAC_USE_COCOA
QDEndCGContext(port, &context);
-#else
- CGContextFlush(context);
-#endif
// Restore context.
CGContextRestoreGState(context);
CGContextRelease(context);
-
+#endif // QT_MAC_USE_COCOA
#endif // Q_WS_MAC
@@ -461,4 +465,12 @@ void QRasterWindowSurface::prepareBuffer(QImage::Format format, QWidget *widget)
delete oldImage;
}
+#ifdef QT_MAC_USE_COCOA
+CGContextRef QRasterWindowSurface::imageContext()
+{
+ Q_D(QRasterWindowSurface);
+ return d->image->cg;
+}
+#endif // QT_MAC_USE_COCOA
+
QT_END_NAMESPACE