summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/painting.pri12
-rw-r--r--src/gui/painting/qbackingstore.cpp5
-rw-r--r--src/gui/painting/qbackingstore_p.h3
-rw-r--r--src/gui/painting/qblittable.cpp2
-rw-r--r--src/gui/painting/qblittable_p.h2
-rw-r--r--src/gui/painting/qdrawingprimitive_sse2_p.h4
-rw-r--r--src/gui/painting/qgraphicssystem_runtime.cpp15
-rw-r--r--src/gui/painting/qgraphicssystem_runtime_p.h3
-rw-r--r--src/gui/painting/qgraphicssystemfactory.cpp2
-rw-r--r--src/gui/painting/qpaintengine_blitter.cpp2
-rw-r--r--src/gui/painting/qpaintengine_blitter_p.h2
-rw-r--r--src/gui/painting/qpainterpath.cpp8
-rw-r--r--src/gui/painting/qprintengine_pdf.cpp2
-rw-r--r--src/gui/painting/qprinterinfo_p.h2
-rw-r--r--src/gui/painting/qunifiedtoolbarsurface_mac.cpp131
-rw-r--r--src/gui/painting/qunifiedtoolbarsurface_mac_p.h15
-rw-r--r--src/gui/painting/qwindowsurface.cpp28
-rw-r--r--src/gui/painting/qwindowsurface_p.h6
-rw-r--r--src/gui/painting/qwindowsurface_raster.cpp56
-rw-r--r--src/gui/painting/qwindowsurface_raster_p.h12
-rw-r--r--src/gui/painting/qwindowsurface_s60.cpp35
-rw-r--r--src/gui/painting/qwindowsurface_s60_p.h2
-rw-r--r--src/gui/painting/qwindowsurface_x11.cpp12
-rw-r--r--src/gui/painting/qwindowsurface_x11_p.h1
24 files changed, 201 insertions, 161 deletions
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
index 51f2538..65e7af4 100644
--- a/src/gui/painting/painting.pri
+++ b/src/gui/painting/painting.pri
@@ -234,8 +234,10 @@ x11 {
}
!embedded:!qpa:mac {
- HEADERS += painting/qwindowsurface_mac_p.h
- SOURCES += painting/qwindowsurface_mac.cpp
+ HEADERS += painting/qwindowsurface_mac_p.h \
+ painting/qunifiedtoolbarsurface_mac_p.h
+ SOURCES += painting/qwindowsurface_mac.cpp \
+ painting/qunifiedtoolbarsurface_mac.cpp
}
embedded {
@@ -260,12 +262,6 @@ symbian {
QMAKE_CXXFLAGS.ARMCC *= -O3
}
-mac {
- HEADERS += painting/qunifiedtoolbarsurface_mac_p.h
- SOURCES += painting/qunifiedtoolbarsurface_mac.cpp
-}
-
-
NEON_SOURCES += painting/qdrawhelper_neon.cpp
NEON_HEADERS += painting/qdrawhelper_neon_p.h
NEON_ASM += ../3rdparty/pixman/pixman-arm-neon-asm.S painting/qdrawhelper_neon_asm.S
diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp
index 129bba5..e5d8abc 100644
--- a/src/gui/painting/qbackingstore.cpp
+++ b/src/gui/painting/qbackingstore.cpp
@@ -1143,6 +1143,11 @@ void QWidgetBackingStore::sync(QWidget *exposedWidget, const QRegion &exposedReg
return;
}
+ // If there's no partial update support we always need
+ // to do a full repaint before flushing
+ if (!windowSurface->hasPartialUpdateSupport())
+ fullUpdatePending = true;
+
// Nothing to repaint.
if (!isDirty()) {
qt_flush(exposedWidget, exposedRegion, windowSurface, tlw, tlwOffset);
diff --git a/src/gui/painting/qbackingstore_p.h b/src/gui/painting/qbackingstore_p.h
index 47387ab..39bf66c 100644
--- a/src/gui/painting/qbackingstore_p.h
+++ b/src/gui/painting/qbackingstore_p.h
@@ -262,7 +262,8 @@ private:
}
inline bool hasStaticContents() const
- { return !staticWidgets.isEmpty() && windowSurface->hasStaticContentsSupport(); }
+ { return !staticWidgets.isEmpty() && windowSurface->hasStaticContentsSupport()
+ && windowSurface->hasPartialUpdateSupport(); }
friend QRegion qt_dirtyRegion(QWidget *);
friend class QWidgetPrivate;
diff --git a/src/gui/painting/qblittable.cpp b/src/gui/painting/qblittable.cpp
index f4b84a9..5802531 100644
--- a/src/gui/painting/qblittable.cpp
+++ b/src/gui/painting/qblittable.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/gui/painting/qblittable_p.h b/src/gui/painting/qblittable_p.h
index cb56cb2..9d0e822 100644
--- a/src/gui/painting/qblittable_p.h
+++ b/src/gui/painting/qblittable_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/gui/painting/qdrawingprimitive_sse2_p.h b/src/gui/painting/qdrawingprimitive_sse2_p.h
index 2d61cc5..d8793c3 100644
--- a/src/gui/painting/qdrawingprimitive_sse2_p.h
+++ b/src/gui/painting/qdrawingprimitive_sse2_p.h
@@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE
pixelVectorAG = _mm_mullo_epi16(pixelVectorAG, alphaChannel); \
pixelVectorRB = _mm_mullo_epi16(pixelVectorRB, alphaChannel); \
\
- /* 3. devide by 255, that's the tricky part. \
+ /* 3. divide by 255, that's the tricky part. \
we do it like for BYTE_MUL(), with bit shift: X/255 ~= (X + X/256 + rounding)/256 */ \
/** so first (X + X/256 + rounding) */\
pixelVectorRB = _mm_add_epi16(pixelVectorRB, _mm_srli_epi16(pixelVectorRB, 8)); \
@@ -86,7 +86,7 @@ QT_BEGIN_NAMESPACE
pixelVectorAG = _mm_add_epi16(pixelVectorAG, _mm_srli_epi16(pixelVectorAG, 8)); \
pixelVectorAG = _mm_add_epi16(pixelVectorAG, half); \
\
- /** second devide by 256 */\
+ /** second divide by 256 */\
pixelVectorRB = _mm_srli_epi16(pixelVectorRB, 8); \
/** for AG, we could >> 8 to divide followed by << 8 to put the \
bytes in the correct position. By masking instead, we execute \
diff --git a/src/gui/painting/qgraphicssystem_runtime.cpp b/src/gui/painting/qgraphicssystem_runtime.cpp
index 5841d40..46a6f81 100644
--- a/src/gui/painting/qgraphicssystem_runtime.cpp
+++ b/src/gui/painting/qgraphicssystem_runtime.cpp
@@ -319,6 +319,16 @@ QPoint QRuntimeWindowSurface::offset(const QWidget *widget) const
return m_windowSurface->offset(widget);
}
+bool QRuntimeWindowSurface::hasStaticContentsSupport() const
+{
+ return m_windowSurface->hasStaticContentsSupport();
+}
+
+bool QRuntimeWindowSurface::hasPartialUpdateSupport() const
+{
+ return m_windowSurface->hasPartialUpdateSupport();
+}
+
QRuntimeGraphicsSystem::QRuntimeGraphicsSystem()
: m_windowSurfaceDestroyPolicy(DestroyImmediately),
m_graphicsSystem(0)
@@ -394,7 +404,10 @@ void QRuntimeGraphicsSystem::setGraphicsSystem(const QString &name)
if(m_windowSurfaceDestroyPolicy == DestroyAfterFirstFlush)
proxy->m_pendingWindowSurface.reset(proxy->m_windowSurface.take());
- proxy->m_windowSurface.reset(m_graphicsSystem->createWindowSurface(widget));
+ QWindowSurface *newWindowSurface = m_graphicsSystem->createWindowSurface(widget);
+ newWindowSurface->setGeometry(proxy->geometry());
+
+ proxy->m_windowSurface.reset(newWindowSurface);
qt_widget_private(widget)->invalidateBuffer(widget->rect());
}
diff --git a/src/gui/painting/qgraphicssystem_runtime_p.h b/src/gui/painting/qgraphicssystem_runtime_p.h
index 30b4e3e..998fa98 100644
--- a/src/gui/painting/qgraphicssystem_runtime_p.h
+++ b/src/gui/painting/qgraphicssystem_runtime_p.h
@@ -129,6 +129,9 @@ public:
virtual QPoint offset(const QWidget *widget) const;
+ virtual bool hasStaticContentsSupport() const;
+ virtual bool hasPartialUpdateSupport() const;
+
QScopedPointer<QWindowSurface> m_windowSurface;
QScopedPointer<QWindowSurface> m_pendingWindowSurface;
diff --git a/src/gui/painting/qgraphicssystemfactory.cpp b/src/gui/painting/qgraphicssystemfactory.cpp
index 5605fc1..62a60d7 100644
--- a/src/gui/painting/qgraphicssystemfactory.cpp
+++ b/src/gui/painting/qgraphicssystemfactory.cpp
@@ -45,6 +45,7 @@
#include "qmutex.h"
#include "qapplication.h"
+#include <private/qapplication_p.h>
#include "qgraphicssystem_raster_p.h"
#include "qgraphicssystem_runtime_p.h"
#include "qdebug.h"
@@ -79,6 +80,7 @@ QGraphicsSystem *QGraphicsSystemFactory::create(const QString& key)
}
#endif
+ QApplicationPrivate::graphics_system_name = system;
if (system == QLatin1String("raster"))
return new QRasterGraphicsSystem;
else if (system == QLatin1String("runtime"))
diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp
index 2e8d9dd..500748e 100644
--- a/src/gui/painting/qpaintengine_blitter.cpp
+++ b/src/gui/painting/qpaintengine_blitter.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/gui/painting/qpaintengine_blitter_p.h b/src/gui/painting/qpaintengine_blitter_p.h
index c8aa536..be8b2bc 100644
--- a/src/gui/painting/qpaintengine_blitter_p.h
+++ b/src/gui/painting/qpaintengine_blitter_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index 8bff021..49f1a5f 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -1724,7 +1724,7 @@ static void qt_painterpath_isect_line(const QPointF &p1,
}
static void qt_painterpath_isect_curve(const QBezier &bezier, const QPointF &pt,
- int *winding)
+ int *winding, int depth = 0)
{
qreal y = pt.y();
qreal x = pt.x();
@@ -1739,7 +1739,7 @@ static void qt_painterpath_isect_curve(const QBezier &bezier, const QPointF &pt,
// hit lower limit... This is a rough threshold, but its a
// tradeoff between speed and precision.
const qreal lower_bound = qreal(.001);
- if (bounds.width() < lower_bound && bounds.height() < lower_bound) {
+ if (depth == 32 || (bounds.width() < lower_bound && bounds.height() < lower_bound)) {
// We make the assumption here that the curve starts to
// approximate a line after while (i.e. that it doesn't
// change direction drastically during its slope)
@@ -1752,8 +1752,8 @@ static void qt_painterpath_isect_curve(const QBezier &bezier, const QPointF &pt,
// split curve and try again...
QBezier first_half, second_half;
bezier.split(&first_half, &second_half);
- qt_painterpath_isect_curve(first_half, pt, winding);
- qt_painterpath_isect_curve(second_half, pt, winding);
+ qt_painterpath_isect_curve(first_half, pt, winding, depth + 1);
+ qt_painterpath_isect_curve(second_half, pt, winding, depth + 1);
}
}
diff --git a/src/gui/painting/qprintengine_pdf.cpp b/src/gui/painting/qprintengine_pdf.cpp
index f262144..b7f5160 100644
--- a/src/gui/painting/qprintengine_pdf.cpp
+++ b/src/gui/painting/qprintengine_pdf.cpp
@@ -936,7 +936,7 @@ void QPdfEnginePrivate::writeInfo()
xprintf("\n/Creator ");
printString(creator);
xprintf("\n/Producer ");
- printString(QString::fromLatin1("Qt " QT_VERSION_STR " (C) 2010 Nokia Corporation and/or its subsidiary(-ies)"));
+ printString(QString::fromLatin1("Qt " QT_VERSION_STR " (C) 2011 Nokia Corporation and/or its subsidiary(-ies)"));
QDateTime now = QDateTime::currentDateTime().toUTC();
QTime t = now.time();
QDate d = now.date();
diff --git a/src/gui/painting/qprinterinfo_p.h b/src/gui/painting/qprinterinfo_p.h
index 7781d59..fcc1acb 100644
--- a/src/gui/painting/qprinterinfo_p.h
+++ b/src/gui/painting/qprinterinfo_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp
index 02ba8db..3876c3d 100644
--- a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp
+++ b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -55,7 +55,6 @@ QUnifiedToolbarSurface::QUnifiedToolbarSurface(QWidget *widget)
{
d_ptr->image = 0;
d_ptr->inSetGeometry = false;
- setStaticContentsSupport(true);
setGeometry(QRect(QPoint(0, 0), QSize(widget->width(), 100))); // FIXME: Fix height.
}
@@ -71,7 +70,7 @@ QPaintDevice *QUnifiedToolbarSurface::paintDevice()
return &d_ptr->image->image;
}
-void QUnifiedToolbarSurface::recursiveRedirect(QObject *object, const QPoint &offset)
+void QUnifiedToolbarSurface::recursiveRedirect(QObject *object, QWidget *parent_toolbar, const QPoint &offset)
{
if (object != 0) {
if (object->isWidgetType()) {
@@ -83,9 +82,10 @@ void QUnifiedToolbarSurface::recursiveRedirect(QObject *object, const QPoint &of
widget->d_func()->unifiedSurface = this;
widget->d_func()->isInUnifiedToolbar = true;
widget->d_func()->toolbar_offset = offset;
+ widget->d_func()->toolbar_ancestor = parent_toolbar;
for (int i = 0; i < object->children().size(); ++i) {
- recursiveRedirect(object->children().at(i), offset);
+ recursiveRedirect(object->children().at(i), parent_toolbar, offset);
}
}
}
@@ -95,7 +95,35 @@ void QUnifiedToolbarSurface::recursiveRedirect(QObject *object, const QPoint &of
void QUnifiedToolbarSurface::insertToolbar(QWidget *toolbar, const QPoint &offset)
{
setGeometry(QRect(QPoint(0, 0), QSize(offset.x() + toolbar->width(), 100))); // FIXME
- recursiveRedirect(toolbar, offset);
+ recursiveRedirect(toolbar, toolbar, offset);
+}
+
+// We basically undo what we set in recursiveRedirect().
+void QUnifiedToolbarSurface::recursiveRemoval(QObject *object)
+{
+ if (object != 0) {
+ if (object->isWidgetType()) {
+ QWidget *widget = qobject_cast<QWidget *>(object);
+
+ // If it's a pop-up or something similar, we don't redirect it.
+ if (widget->windowType() & Qt::Window)
+ return;
+
+ widget->d_func()->unifiedSurface = 0;
+ widget->d_func()->isInUnifiedToolbar = false;
+ widget->d_func()->toolbar_offset = QPoint();
+ widget->d_func()->toolbar_ancestor = 0;
+ }
+
+ for (int i = 0; i < object->children().size(); ++i) {
+ recursiveRemoval(object->children().at(i));
+ }
+ }
+}
+
+void QUnifiedToolbarSurface::removeToolbar(QToolBar *toolbar)
+{
+ recursiveRemoval(toolbar);
}
void QUnifiedToolbarSurface::setGeometry(const QRect &rect)
@@ -127,70 +155,25 @@ void QUnifiedToolbarSurface::updateToolbarOffset(QWidget *widget)
mlayout->updateUnifiedToolbarOffset();
}
-void QUnifiedToolbarSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &offset)
+void QUnifiedToolbarSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
{
- Q_D(QUnifiedToolbarSurface);
-
- QRegion flushingRegion(widget->rect());
-
- if (!d->image || rgn.rectCount() == 0) {
- return;
- }
-
+ Q_UNUSED(region);
Q_UNUSED(offset);
- // Get a context for the widget.
- CGContextRef context;
- if (!(widget->d_func()->hasOwnContext)) {
- widget->d_func()->ut_rg = rgn;
- widget->d_func()->ut_pt = offset;
- qt_mac_display(widget);
- return;
- } else {
- // We render the content of the toolbar in the surface.
- updateToolbarOffset(widget);
- QRect beginPaintRect(widget->d_func()->toolbar_offset.x(), widget->d_func()->toolbar_offset.y(), widget->geometry().width(), widget->geometry().height());
- QRegion beginPaintRegion(beginPaintRect);
-
- context = widget->d_func()->cgContext;
- beginPaint(beginPaintRegion);
- widget->render(widget->d_func()->unifiedSurface->paintDevice(), widget->d_func()->toolbar_offset, QRegion(), QWidget::DrawChildren);
- }
+ this->flush(widget);
+}
- CGContextSaveGState(context);
+void QUnifiedToolbarSurface::flush(QWidget *widget)
+{
+ Q_D(QUnifiedToolbarSurface);
- int areaX = widget->d_func()->toolbar_offset.x();
- int areaY = widget->d_func()->toolbar_offset.y();
- int areaWidth = widget->geometry().width();
- int areaHeight = widget->geometry().height();
- const CGRect area = CGRectMake(areaX, areaY, areaWidth, areaHeight);
+ if (!d->image)
+ return;
- // Clip to region.
- const QVector<QRect> &rects = flushingRegion.rects();
- for (int i = 0; i < rects.size(); ++i) {
- const QRect &rect = rects.at(i);
- CGContextAddRect(context, CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()));
+ if (widget->d_func()->flushRequested) {
+ // We call display: directly to avoid flickering in the toolbar.
+ qt_mac_display(widget);
}
- CGContextAddRect(context, area);
- CGContextClip(context);
-
-
- CGImageRef image = CGBitmapContextCreateImage(d->image->cg);
- CGImageRef subImage = CGImageCreateWithImageInRect(image, area);
-
- const CGRect drawingArea = CGRectMake(0, 0, areaWidth, areaHeight);
- qt_mac_drawCGImage(context, &drawingArea, subImage);
-
- CGImageRelease(subImage);
- CGImageRelease(image);
-
- CGContextFlush(context);
-
- // Restore context.
- CGContextRestoreGState(context);
- CGContextRelease(context);
- widget->d_func()->cgContext = 0;
- widget->d_func()->hasOwnContext = false;
}
void QUnifiedToolbarSurface::prepareBuffer(QImage::Format format, QWidget *widget)
@@ -198,7 +181,7 @@ void QUnifiedToolbarSurface::prepareBuffer(QImage::Format format, QWidget *widge
Q_D(QUnifiedToolbarSurface);
int width = geometry().width();
- int height = geometry().height();
+ int height = 100; // FIXME
if (d->image) {
width = qMax(d->image->width(), width);
height = qMax(d->image->height(), height);
@@ -254,6 +237,28 @@ void QUnifiedToolbarSurface::prepareBuffer(QImage::Format format, QWidget *widge
delete oldImage;
}
+CGContextRef QUnifiedToolbarSurface::imageContext()
+{
+ Q_D(QUnifiedToolbarSurface);
+ return d->image->cg;
+}
+
+void QUnifiedToolbarSurface::renderToolbar(QWidget *widget, bool forceFlush)
+{
+ QWidget *toolbar = widget->d_func()->toolbar_ancestor;
+
+ updateToolbarOffset(toolbar);
+ QRect beginPaintRect(toolbar->d_func()->toolbar_offset.x(), toolbar->d_func()->toolbar_offset.y(), toolbar->geometry().width(), toolbar->geometry().height());
+ QRegion beginPaintRegion(beginPaintRect);
+
+ beginPaint(beginPaintRegion);
+ toolbar->render(paintDevice(), toolbar->d_func()->toolbar_offset, QRegion(toolbar->geometry()), QWidget::DrawChildren);
+ toolbar->d_func()->flushRequested = true;
+
+ if (forceFlush)
+ flush(toolbar);
+}
+
QT_END_NAMESPACE
#endif // QT_MAC_USE_COCOA
diff --git a/src/gui/painting/qunifiedtoolbarsurface_mac_p.h b/src/gui/painting/qunifiedtoolbarsurface_mac_p.h
index 3bc0404..0a7ebf1 100644
--- a/src/gui/painting/qunifiedtoolbarsurface_mac_p.h
+++ b/src/gui/painting/qunifiedtoolbarsurface_mac_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -55,6 +55,7 @@
#include <private/qwindowsurface_raster_p.h>
#include <QWidget>
+#include <QToolBar>
#include <private/qwidget_p.h>
#include <private/qnativeimage_p.h>
@@ -78,16 +79,22 @@ public:
QUnifiedToolbarSurface(QWidget *widget);
~QUnifiedToolbarSurface();
+ void flush(QWidget *widget);
void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
void setGeometry(const QRect &rect);
void beginPaint(const QRegion &rgn);
void insertToolbar(QWidget *toolbar, const QPoint &offset);
+ void removeToolbar(QToolBar *toolbar);
+ void updateToolbarOffset(QWidget *widget);
+ void renderToolbar(QWidget *widget, bool forceFlush = false);
+ void recursiveRedirect(QObject *widget, QWidget *parent_toolbar, const QPoint &offset);
-private:
QPaintDevice *paintDevice();
- void updateToolbarOffset(QWidget *widget);
+ CGContextRef imageContext();
+
+private:
void prepareBuffer(QImage::Format format, QWidget *widget);
- void recursiveRedirect(QObject *widget, const QPoint &offset);
+ void recursiveRemoval(QObject *object);
Q_DECLARE_PRIVATE(QUnifiedToolbarSurface)
QScopedPointer<QUnifiedToolbarSurfacePrivate> d_ptr;
diff --git a/src/gui/painting/qwindowsurface.cpp b/src/gui/painting/qwindowsurface.cpp
index 029b9dc..9b71818 100644
--- a/src/gui/painting/qwindowsurface.cpp
+++ b/src/gui/painting/qwindowsurface.cpp
@@ -52,8 +52,6 @@ class QWindowSurfacePrivate
public:
QWindowSurfacePrivate(QWidget *w)
: window(w)
- , staticContentsSupport(0)
- , partialUpdateSupport(1)
{
}
@@ -65,8 +63,6 @@ public:
#endif //Q_WS_QPA
QRegion staticContents;
QList<QImage*> bufferImages;
- uint staticContentsSupport : 1;
- uint partialUpdateSupport : 1;
};
/*!
@@ -313,16 +309,7 @@ QPoint QWindowSurface::offset(const QWidget *widget) const
bool QWindowSurface::hasStaticContentsSupport() const
{
- return d_ptr->staticContentsSupport;
-}
-
-void QWindowSurface::setStaticContentsSupport(bool enable)
-{
- if (enable && !d_ptr->partialUpdateSupport) {
- qWarning("QWindowSurface::setStaticContentsSupport: static contents support requires partial update support");
- return;
- }
- d_ptr->staticContentsSupport = enable;
+ return false;
}
void QWindowSurface::setStaticContents(const QRegion &region)
@@ -337,21 +324,12 @@ QRegion QWindowSurface::staticContents() const
bool QWindowSurface::hasStaticContents() const
{
- return d_ptr->staticContentsSupport && !d_ptr->staticContents.isEmpty();
+ return hasStaticContentsSupport() && !d_ptr->staticContents.isEmpty();
}
bool QWindowSurface::hasPartialUpdateSupport() const
{
- return d_ptr->partialUpdateSupport;
-}
-
-void QWindowSurface::setPartialUpdateSupport(bool enable)
-{
- if (!enable && d_ptr->staticContentsSupport) {
- qWarning("QWindowSurface::setPartialUpdateSupport: static contents support requires partial update support");
- return;
- }
- d_ptr->partialUpdateSupport = enable;
+ return true;
}
#ifdef Q_WS_QPA
diff --git a/src/gui/painting/qwindowsurface_p.h b/src/gui/painting/qwindowsurface_p.h
index 62137ef..4a2775f 100644
--- a/src/gui/painting/qwindowsurface_p.h
+++ b/src/gui/painting/qwindowsurface_p.h
@@ -100,16 +100,14 @@ public:
virtual QPoint offset(const QWidget *widget) const;
inline QRect rect(const QWidget *widget) const;
- bool hasStaticContentsSupport() const;
- bool hasPartialUpdateSupport() const;
+ virtual bool hasStaticContentsSupport() const;
+ virtual bool hasPartialUpdateSupport() const;
void setStaticContents(const QRegion &region);
QRegion staticContents() const;
protected:
bool hasStaticContents() const;
- void setStaticContentsSupport(bool enable);
- void setPartialUpdateSupport(bool enable);
private:
QWindowSurfacePrivate *d_ptr;
diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp
index 419518ac..a5c45c0 100644
--- a/src/gui/painting/qwindowsurface_raster.cpp
+++ b/src/gui/painting/qwindowsurface_raster.cpp
@@ -103,7 +103,11 @@ QRasterWindowSurface::QRasterWindowSurface(QWidget *window, bool setDefaultSurfa
#endif
d_ptr->image = 0;
d_ptr->inSetGeometry = false;
- setStaticContentsSupport(true);
+
+#ifdef QT_MAC_USE_COCOA
+ needsFlush = false;
+ regionToFlush = QRegion();
+#endif // QT_MAC_USE_COCOA
}
@@ -272,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);
@@ -332,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
@@ -425,6 +410,11 @@ bool QRasterWindowSurface::scroll(const QRegion &area, int dx, int dy)
#endif
}
+bool QRasterWindowSurface::hasStaticContentsSupport() const
+{
+ return true;
+}
+
void QRasterWindowSurface::prepareBuffer(QImage::Format format, QWidget *widget)
{
@@ -487,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
diff --git a/src/gui/painting/qwindowsurface_raster_p.h b/src/gui/painting/qwindowsurface_raster_p.h
index 903810b..669511d 100644
--- a/src/gui/painting/qwindowsurface_raster_p.h
+++ b/src/gui/painting/qwindowsurface_raster_p.h
@@ -56,6 +56,10 @@
#include <qglobal.h>
#include "private/qwindowsurface_p.h"
+#ifdef QT_MAC_USE_COCOA
+# include <private/qt_cocoa_helpers_mac_p.h>
+#endif // QT_MAC_USE_COCOA
+
QT_BEGIN_NAMESPACE
#ifdef Q_WS_WIN
@@ -105,6 +109,14 @@ public:
void beginPaint(const QRegion &rgn);
void setGeometry(const QRect &rect);
bool scroll(const QRegion &area, int dx, int dy);
+ bool hasStaticContentsSupport() const;
+
+#ifdef QT_MAC_USE_COCOA
+ CGContextRef imageContext();
+
+ bool needsFlush;
+ QRegion regionToFlush;
+#endif // QT_MAC_USE_COCOA
private:
#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp
index 71556d7..4fa25cb 100644
--- a/src/gui/painting/qwindowsurface_s60.cpp
+++ b/src/gui/painting/qwindowsurface_s60.cpp
@@ -63,7 +63,6 @@ struct QS60WindowSurfacePrivate
TDisplayMode displayMode(bool opaque)
{
-
TDisplayMode mode = S60->screenDevice()->DisplayMode();
if (opaque) {
mode = EColor16MU;
@@ -76,10 +75,18 @@ TDisplayMode displayMode(bool opaque)
return mode;
}
+bool blitWriteAlpha(QWidgetPrivate *widgetPrivate)
+{
+ QWExtra *extra = widgetPrivate->extraData();
+ return extra ? extra->nativePaintMode == QWExtra::BlitWriteAlpha : false;
+}
+
QS60WindowSurface::QS60WindowSurface(QWidget* widget)
: QWindowSurface(widget), d_ptr(new QS60WindowSurfacePrivate)
{
- TDisplayMode mode = displayMode(qt_widget_private(widget)->isOpaque);
+ QWidgetPrivate *widgetPrivate = qt_widget_private(widget);
+ const bool opaque = widgetPrivate->isOpaque && !blitWriteAlpha(widgetPrivate);
+ TDisplayMode mode = displayMode(opaque);
// We create empty CFbsBitmap here -> it will be resized in setGeometry
CFbsBitmap *bitmap = new CFbsBitmap; // CBase derived object needs check on new
Q_CHECK_PTR(bitmap);
@@ -90,8 +97,6 @@ QS60WindowSurface::QS60WindowSurface(QWidget* widget)
data->fromSymbianBitmap(bitmap, true);
d_ptr->device = QPixmap(data);
}
-
- setStaticContentsSupport(true);
}
QS60WindowSurface::~QS60WindowSurface()
@@ -124,7 +129,8 @@ void QS60WindowSurface::beginPaint(const QRegion &rgn)
S60->wsSession().Finish();
#endif
- if (!qt_widget_private(window())->isOpaque) {
+ QWidgetPrivate *windowPrivate = qt_widget_private(window());
+ if (!windowPrivate->isOpaque || blitWriteAlpha(windowPrivate)) {
QS60PixmapData *pixmapData = static_cast<QS60PixmapData *>(d_ptr->device.data_ptr().data());
TDisplayMode mode = displayMode(false);
@@ -133,12 +139,14 @@ void QS60WindowSurface::beginPaint(const QRegion &rgn)
pixmapData->beginDataAccess();
- QPainter p(&pixmapData->image);
- p.setCompositionMode(QPainter::CompositionMode_Source);
- const QVector<QRect> rects = rgn.rects();
- const QColor blank = Qt::transparent;
- for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
- p.fillRect(*it, blank);
+ if (!windowPrivate->isOpaque) {
+ QPainter p(&pixmapData->image);
+ p.setCompositionMode(QPainter::CompositionMode_Source);
+ const QVector<QRect> rects = rgn.rects();
+ const QColor blank = Qt::transparent;
+ for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
+ p.fillRect(*it, blank);
+ }
}
pixmapData->endDataAccess();
@@ -231,6 +239,11 @@ void QS60WindowSurface::setGeometry(const QRect& rect)
QWindowSurface::setGeometry(rect);
}
+bool QS60WindowSurface::hasStaticContentsSupport() const
+{
+ return true;
+}
+
CFbsBitmap* QS60WindowSurface::symbianBitmap() const
{
QS60PixmapData *data = static_cast<QS60PixmapData*>(d_ptr->device.data_ptr().data());
diff --git a/src/gui/painting/qwindowsurface_s60_p.h b/src/gui/painting/qwindowsurface_s60_p.h
index d0d4925..f730c87 100644
--- a/src/gui/painting/qwindowsurface_s60_p.h
+++ b/src/gui/painting/qwindowsurface_s60_p.h
@@ -79,6 +79,8 @@ public:
void setGeometry(const QRect &rect);
+ bool hasStaticContentsSupport() const;
+
CFbsBitmap *symbianBitmap() const;
private:
diff --git a/src/gui/painting/qwindowsurface_x11.cpp b/src/gui/painting/qwindowsurface_x11.cpp
index 2324bc2..ab4f53e 100644
--- a/src/gui/painting/qwindowsurface_x11.cpp
+++ b/src/gui/painting/qwindowsurface_x11.cpp
@@ -70,9 +70,6 @@ QX11WindowSurface::QX11WindowSurface(QWidget *widget)
#ifndef QT_NO_XRENDER
d_ptr->translucentBackground = X11->use_xrender
&& widget->x11Info().depth() == 32;
- setStaticContentsSupport(!d_ptr->translucentBackground);
-#else
- setStaticContentsSupport(true);
#endif
}
@@ -253,4 +250,13 @@ QPixmap QX11WindowSurface::grabWidget(const QWidget *widget,
return px;
}
+bool QX11WindowSurface::hasStaticContentsSupport() const
+{
+#ifndef QT_NO_XRENDER
+ return !d_ptr->translucentBackground;
+#else
+ return true;
+#endif
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/painting/qwindowsurface_x11_p.h b/src/gui/painting/qwindowsurface_x11_p.h
index 88753ea..d5179dd 100644
--- a/src/gui/painting/qwindowsurface_x11_p.h
+++ b/src/gui/painting/qwindowsurface_x11_p.h
@@ -80,6 +80,7 @@ public:
bool scroll(const QRegion &area, int dx, int dy);
QPixmap grabWidget(const QWidget *widget,
const QRect& rectangle = QRect()) const;
+ bool hasStaticContentsSupport() const;
private:
QX11WindowSurfacePrivate *d_ptr;
GC gc;