summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qwindowsurface_raster.cpp
diff options
context:
space:
mode:
authorFabien Freling <fabien.freling@nokia.com>2011-03-16 14:09:29 (GMT)
committerFabien Freling <fabien.freling@nokia.com>2011-03-17 09:59:29 (GMT)
commit67625836d115f3990b39cf9eb1f2cd959960998c (patch)
tree9745335d03b132341af97d38b62b6d858bc42f4e /src/gui/painting/qwindowsurface_raster.cpp
parented218edcf3d40e05b7cc9e1b895b7dad662e0511 (diff)
parentd149125e0b539ff13f77cb2a67194ac3d6e331a0 (diff)
downloadQt-67625836d115f3990b39cf9eb1f2cd959960998c.zip
Qt-67625836d115f3990b39cf9eb1f2cd959960998c.tar.gz
Qt-67625836d115f3990b39cf9eb1f2cd959960998c.tar.bz2
Merge remote branch 'raster/master' into merge_raster
Diffstat (limited to 'src/gui/painting/qwindowsurface_raster.cpp')
-rw-r--r--src/gui/painting/qwindowsurface_raster.cpp50
1 files changed, 22 insertions, 28 deletions
diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp
index 3a5dcc3..a5c45c0 100644
--- a/src/gui/painting/qwindowsurface_raster.cpp
+++ b/src/gui/painting/qwindowsurface_raster.cpp
@@ -103,6 +103,11 @@ QRasterWindowSurface::QRasterWindowSurface(QWidget *window, bool setDefaultSurfa
#endif
d_ptr->image = 0;
d_ptr->inSetGeometry = false;
+
+#ifdef QT_MAC_USE_COCOA
+ needsFlush = false;
+ regionToFlush = QRegion();
+#endif // QT_MAC_USE_COCOA
}
@@ -271,41 +276,26 @@ 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
- // Unified toolbar hack.
- QMainWindow* mWindow = qobject_cast<QMainWindow*>(widget->window());
- if (mWindow) {
- QMainWindowLayout *mLayout = qobject_cast<QMainWindowLayout*>(mWindow->layout());
- QList<QToolBar *> toolbarList = mLayout->qtoolbarsInUnifiedToolbarList;
- for (int i = 0; i < toolbarList.size(); ++i) {
- QToolBar* toolbar = toolbarList.at(i);
- if (mLayout->toolBarArea(toolbar) == Qt::TopToolBarArea) {
- QWidget* tbWidget = (QWidget*) toolbar;
- if (tbWidget->d_func()->unifiedSurface) {
- tbWidget->d_func()->unifiedSurface->flush(tbWidget, rgn, offset);
- }
- }
- }
- }
-#endif // QT_MAC_USE_COCOA
+ this->needsFlush = true;
+ this->regionToFlush += rgn;
- Q_UNUSED(offset);
+ // The actual flushing will be processed in [view drawRect:rect]
+ qt_mac_setNeedsDisplay(widget);
+
+#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
- QMacCocoaAutoReleasePool pool;
- extern CGContextRef qt_mac_graphicsContextFor(QWidget *);
- CGContextRef context = qt_mac_graphicsContextFor(widget);
-#endif
CGContextRetain(context);
CGContextSaveGState(context);
@@ -331,16 +321,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
@@ -491,4 +477,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