From cb470a33bf85cf15b9df57e3ade27c6a0720d138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 4 Jan 2011 08:39:22 +0100 Subject: Fixed first element being a LineToElement in QPainterPath::connectPath() This would produce an invalid path, causing potential crashes in various parts of Qt. Task-number: QTBUG-16377 Reviewed-by: Gunnar Sletta --- src/gui/painting/qpainterpath.cpp | 3 ++- tests/auto/qpainterpath/tst_qpainterpath.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index ffd0d5c..94e2cd4 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -1196,7 +1196,8 @@ void QPainterPath::connectPath(const QPainterPath &other) int first = d->elements.size(); d->elements += other.d_func()->elements; - d->elements[first].type = LineToElement; + if (first != 0) + d->elements[first].type = LineToElement; // avoid duplicate points if (first > 0 && QPointF(d->elements[first]) == QPointF(d->elements[first - 1])) { diff --git a/tests/auto/qpainterpath/tst_qpainterpath.cpp b/tests/auto/qpainterpath/tst_qpainterpath.cpp index d0cddda..66e6d10 100644 --- a/tests/auto/qpainterpath/tst_qpainterpath.cpp +++ b/tests/auto/qpainterpath/tst_qpainterpath.cpp @@ -107,6 +107,7 @@ private slots: void operators(); void connectPathDuplicatePoint(); + void connectPathMoveTo(); void translate(); }; @@ -1169,6 +1170,31 @@ void tst_QPainterPath::connectPathDuplicatePoint() QCOMPARE(c, a); } +void tst_QPainterPath::connectPathMoveTo() +{ + QPainterPath path1; + QPainterPath path2; + QPainterPath path3; + QPainterPath path4; + + path1.moveTo(1,1); + + path2.moveTo(4,4); + path2.lineTo(5,6); + path2.lineTo(6,7); + + path3.connectPath(path2); + + path4.lineTo(5,5); + + path1.connectPath(path2); + + QVERIFY(path1.elementAt(0).type == QPainterPath::MoveToElement); + QVERIFY(path2.elementAt(0).type == QPainterPath::MoveToElement); + QVERIFY(path3.elementAt(0).type == QPainterPath::MoveToElement); + QVERIFY(path4.elementAt(0).type == QPainterPath::MoveToElement); +} + void tst_QPainterPath::translate() { QPainterPath path; -- cgit v0.12 From 7fec0ddfae9e7c79d904c87e7726991a306f5ab3 Mon Sep 17 00:00:00 2001 From: Michael Dominic K Date: Tue, 4 Jan 2011 09:29:06 +0100 Subject: QMeeGoSwitchEvent exported and static. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 1009 Reviewed-by: Samuel Rødal --- tools/qmeegographicssystemhelper/qmeegoswitchevent.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/qmeegographicssystemhelper/qmeegoswitchevent.h b/tools/qmeegographicssystemhelper/qmeegoswitchevent.h index 0ddbd3d..462182f 100644 --- a/tools/qmeegographicssystemhelper/qmeegoswitchevent.h +++ b/tools/qmeegographicssystemhelper/qmeegoswitchevent.h @@ -52,7 +52,7 @@ when going to software mode. */ -class QMeeGoSwitchEvent : public QEvent +class Q_DECL_EXPORT QMeeGoSwitchEvent : public QEvent { public: @@ -83,7 +83,7 @@ public: The type is registered on first access. Use this to detect incoming QMeeGoSwitchEvents. */ - QEvent::Type eventNumber(); + static QEvent::Type eventNumber(); private: QString name; -- cgit v0.12 From 3ad35ffdbfcbd2db5e8aac95fa0cc9f80e372128 Mon Sep 17 00:00:00 2001 From: Michael Dominic K Date: Tue, 4 Jan 2011 10:28:20 +0100 Subject: Pre-create the GL share widget before window surface creation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not pixmap creation. Merge-request: 988 Reviewed-by: Samuel Rødal --- src/plugins/graphicssystems/meego/qmeegographicssystem.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp index 4a86082..b1a8f5f7 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp @@ -75,6 +75,8 @@ QMeeGoGraphicsSystem::~QMeeGoGraphicsSystem() QWindowSurface* QMeeGoGraphicsSystem::createWindowSurface(QWidget *widget) const { + QGLShareContextScope ctx(qt_gl_share_widget()->context()); + QMeeGoGraphicsSystem::surfaceWasCreated = true; QWindowSurface *surface = new QGLWindowSurface(widget); return surface; @@ -82,12 +84,6 @@ QWindowSurface* QMeeGoGraphicsSystem::createWindowSurface(QWidget *widget) const QPixmapData *QMeeGoGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const { - // Long story short: without this it's possible to hit an - // uninitialized paintDevice due to a Qt bug too complex to even - // explain here... not to mention fix without going crazy. - // MDK - QGLShareContextScope ctx(qt_gl_share_widget()->context()); - return new QRasterPixmapData(type); } -- cgit v0.12 From b5acfc61f3989ab8b72f784431fc5ab168ffb975 Mon Sep 17 00:00:00 2001 From: Michael Dominic K Date: Tue, 4 Jan 2011 10:53:57 +0100 Subject: Support for swap modes in QGLWindowSurface. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AlwaysFull and AlwaysPartial implemented in ES only for now. By default do automatic. Merge-request: 993 Reviewed-by: Samuel Rødal --- src/opengl/qwindowsurface_gl.cpp | 13 ++++++++++++- src/opengl/qwindowsurface_gl_p.h | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 7dc7dc7..b8716ce 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -284,6 +284,7 @@ struct QGLWindowSurfacePrivate }; QGLFormat QGLWindowSurface::surfaceFormat; +QGLWindowSurface::SwapMode QGLWindowSurface::swapBehavior = QGLWindowSurface::AutomaticSwap; void QGLWindowSurfaceGLPaintDevice::endPaint() { @@ -541,6 +542,9 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & const GLenum target = GL_TEXTURE_2D; Q_UNUSED(target); + if (QGLWindowSurface::swapBehavior == QGLWindowSurface::KillSwap) + return; + if (context()) { context()->makeCurrent(); @@ -588,7 +592,14 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & } } #endif - bool doingPartialUpdate = hasPartialUpdateSupport() && br.width() * br.height() < parent->geometry().width() * parent->geometry().height() * 0.2; + bool doingPartialUpdate = false; + if (QGLWindowSurface::swapBehavior == QGLWindowSurface::AutomaticSwap) + doingPartialUpdate = hasPartialUpdateSupport() && br.width() * br.height() < parent->geometry().width() * parent->geometry().height() * 0.2; + else if (QGLWindowSurface::swapBehavior == QGLWindowSurface::AlwaysFullSwap) + doingPartialUpdate = false; + else if (QGLWindowSurface::swapBehavior == QGLWindowSurface::AlwaysPartialSwap) + doingPartialUpdate = hasPartialUpdateSupport(); + QGLContext *ctx = reinterpret_cast(parent->d_func()->extraData()->glContext); if (widget != window()) { if (initializeOffscreenTexture(window()->size())) diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h index 6906f35..9b0bee3 100644 --- a/src/opengl/qwindowsurface_gl_p.h +++ b/src/opengl/qwindowsurface_gl_p.h @@ -102,6 +102,9 @@ public: static QGLFormat surfaceFormat; + enum SwapMode { AutomaticSwap, AlwaysFullSwap, AlwaysPartialSwap, KillSwap }; + static SwapMode swapBehavior; + private slots: void deleted(QObject *object); -- cgit v0.12 From 177f2a2f17251c22f57944e9dd100ec8515b891a Mon Sep 17 00:00:00 2001 From: Michael Dominic K Date: Tue, 4 Jan 2011 10:53:58 +0100 Subject: QMeeGoGraphicsSystemHelper::setSwapBehavior implementation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 993 Reviewed-by: Samuel Rødal --- .../qmeegographicssystemhelper.cpp | 15 +++++++++++++++ .../qmeegographicssystemhelper.h | 18 ++++++++++++++++++ .../qmeegographicssystemhelper.pro | 2 +- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp index b660eb3..37cc417 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include "qmeegoruntime.h" #include "qmeegoswitchevent.h" @@ -153,3 +154,17 @@ void QMeeGoGraphicsSystemHelper::setTranslucent(bool translucent) ENSURE_RUNNING_MEEGO; QMeeGoRuntime::setTranslucent(translucent); } + +void QMeeGoGraphicsSystemHelper::setSwapBehavior(SwapMode mode) +{ + ENSURE_RUNNING_MEEGO; + + if (mode == AutomaticSwap) + QGLWindowSurface::swapBehavior = QGLWindowSurface::AutomaticSwap; + else if (mode == AlwaysFullSwap) + QGLWindowSurface::swapBehavior = QGLWindowSurface::AlwaysFullSwap; + else if (mode == AlwaysPartialSwap) + QGLWindowSurface::swapBehavior = QGLWindowSurface::AlwaysPartialSwap; + else if (mode == KillSwap) + QGLWindowSurface::swapBehavior = QGLWindowSurface::KillSwap; +} diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h index 6df3c22..c8dccc2 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h @@ -186,6 +186,24 @@ public: on the top-level widget *before* you show it instead. */ static void setTranslucent(bool translucent); + + //! Used to specify the mode for swapping buffers in double-buffered GL rendering. + enum SwapMode { + AutomaticSwap, /**< Automatically choose netween full and partial updates (25% threshold) */ + AlwaysFullSwap, /**< Always do a full swap even if partial updates support present */ + AlwaysPartialSwap, /**< Always do a partial swap (if support present) no matter what threshold */ + KillSwap /**< Do not perform buffer swapping at all (no picture) */ + }; + + //! Sets the buffer swapping mode. + /*! + This can be only called when running with the meego graphics system. + The KillSwap mode can be specififed to effectively block painting. + + This functionality should be used only by applications counting on a specific behavior. + Most applications should use the default automatic behavior. + */ + static void setSwapBehavior(SwapMode mode); }; #endif diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro index 360847e..7639ad7 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro @@ -3,7 +3,7 @@ TARGET = QtMeeGoGraphicsSystemHelper include(../../src/qbase.pri) -QT += gui +QT += gui opengl INCLUDEPATH += '../../src/plugins/graphicssystems/meego' HEADERS = qmeegographicssystemhelper.h qmeegooverlaywidget.h qmeegolivepixmap.h qmeegoruntime.h qmeegolivepixmap_p.h qmeegofencesync.h qmeegofencesync_p.h qmeegoswitchevent.h -- cgit v0.12