From a359db8f939ccbe8ce49c2ef71ff4585ab69c15e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 17 Feb 2010 17:12:57 +0100 Subject: Fixed autotest failure in tst_QPainter::drawEllipse on Maemo. The previous fix (baa7c3bdecc) attempted to fall back to path drawing in QPainter::drawEllipse, however we have some specific filling rules for aliased ellipse drawing in the raster paint engine. We should use the (now free of fixed point math) drawEllipse_midpoint_i function on all platforms. Reviewed-by: Gunnar Sletta --- src/gui/painting/qpaintengine_raster.cpp | 8 -------- tests/auto/qpainter/tst_qpainter.cpp | 2 -- 2 files changed, 10 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 4a4792a..3c2cc8c 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -100,10 +100,6 @@ #endif #include -#if defined(QT_NO_FPU) || (_MSC_VER >= 1300 && _MSC_VER < 1400) -# define FLOATING_POINT_BUGGY_OR_NO_FPU -#endif - QT_BEGIN_NAMESPACE extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp @@ -1827,7 +1823,6 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush) } } -#ifndef FLOATING_POINT_BUGGY_OR_NO_FPU if (path.shape() == QVectorPath::EllipseHint) { if (!s->flags.antialiased && s->matrix.type() <= QTransform::TxScale) { const qreal *p = path.points(); @@ -1847,7 +1842,6 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush) } } } -#endif // ### Optimize for non transformed ellipses and rectangles... QRectF cpRect = path.controlPointRect(); @@ -3674,7 +3668,6 @@ void QRasterPaintEngine::drawLines(const QLineF *lines, int lineCount) */ void QRasterPaintEngine::drawEllipse(const QRectF &rect) { -#ifndef FLOATING_POINT_BUGGY_OR_NO_FPU Q_D(QRasterPaintEngine); QRasterPaintEngineState *s = state(); @@ -3697,7 +3690,6 @@ void QRasterPaintEngine::drawEllipse(const QRectF &rect) return; } } -#endif QPaintEngineEx::drawEllipse(rect); } diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 104728d..beb83a1 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -1580,10 +1580,8 @@ void tst_QPainter::drawClippedEllipse_data() void tst_QPainter::drawClippedEllipse() { QFETCH(QRect, rect); -#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) if (sizeof(qreal) != sizeof(double)) QSKIP("Test only works for qreal==double", SkipAll); -#endif QImage image(rect.width() + 1, rect.height() + 1, QImage::Format_ARGB32_Premultiplied); QRect expected = QRect(rect.x(), rect.y(), rect.width()+1, rect.height()+1) -- cgit v0.12 From 08a40e6d4ef085c13d95c300c4df6b19caf7c483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 18 Feb 2010 10:10:39 +0100 Subject: Documented behavior of blur effect radius and drop shadow offset. Our graphics effects are always done in device coordinates (unless they can be done in logical coordinates with the same result as an optimization, e.g. opacity effects). Reviewed-by: Andy Shaw --- src/gui/effects/qgraphicseffect.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 7d1d03d..ce4ce6a 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -726,7 +726,8 @@ void QGraphicsColorizeEffect::draw(QPainter *painter) elements. The level of detail can be modified using the setBlurRadius() function. Use setBlurHints() to choose the blur hints. - By default, the blur radius is 5 pixels. + By default, the blur radius is 5 pixels. The blur radius is specified in + device coordinates. \img graphicseffect-blur.png @@ -781,6 +782,9 @@ QGraphicsBlurEffect::~QGraphicsBlurEffect() radius results in a more blurred appearance. By default, the blur radius is 5 pixels. + + The radius is given in device coordinates, meaning it is + unaffected by scale. */ qreal QGraphicsBlurEffect::blurRadius() const { @@ -884,7 +888,8 @@ void QGraphicsBlurEffect::draw(QPainter *painter) By default, the drop shadow is a semi-transparent dark gray (QColor(63, 63, 63, 180)) shadow, blurred with a radius of 1 at an offset - of 8 pixels towards the lower right. + of 8 pixels towards the lower right. The drop shadow offset is specified + in device coordinates. \img graphicseffect-drop-shadow.png @@ -913,6 +918,9 @@ QGraphicsDropShadowEffect::~QGraphicsDropShadowEffect() By default, the offset is 8 pixels towards the lower right. + The offset is given in device coordinates, which means it is + unaffected by scale. + \sa xOffset(), yOffset(), blurRadius(), color() */ QPointF QGraphicsDropShadowEffect::offset() const -- cgit v0.12 From a6eac63470ad8dd3f1687fcd4039a5312c44a5d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Wed, 17 Feb 2010 15:59:49 +0100 Subject: Compiler warning, unusable variable in tst_QGraphicsScene benchmark. --- tests/benchmarks/gui/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/benchmarks/gui/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index 5bd07f9..9531619 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/benchmarks/gui/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -209,7 +209,6 @@ void tst_QGraphicsScene::itemAt() if (!sceneRect.isNull()) scene.setSceneRect(sceneRect); - QGraphicsItem *item = 0; for (int y = 0; y < numItems_Y; ++y) { for (int x = 0; x < numItems_X; ++x) { QGraphicsRectItem *item = new QGraphicsRectItem(itemRect); -- cgit v0.12 From 5c4363a0fa3cd654413ff2637cb70aeec7a590ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Wed, 17 Feb 2010 16:12:09 +0100 Subject: Stabilize QGraphicsScene benchmarks. --- .../gui/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/benchmarks/gui/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index 9531619..10d73d5 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/benchmarks/gui/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -75,8 +75,16 @@ tst_QGraphicsScene::~tst_QGraphicsScene() { } +static inline void processEvents() +{ + QApplication::flush(); + QApplication::processEvents(); + QApplication::processEvents(); +} + void tst_QGraphicsScene::init() { + processEvents(); } void tst_QGraphicsScene::cleanup() @@ -148,6 +156,8 @@ void tst_QGraphicsScene::addItem() if (!sceneRect.isNull()) scene.setSceneRect(sceneRect); + processEvents(); + QBENCHMARK { QGraphicsItem *item = 0; for (int y = 0; y < numItems_Y; ++y) { @@ -218,9 +228,11 @@ void tst_QGraphicsScene::itemAt() } scene.itemAt(0, 0); // triggers indexing + processEvents(); + QGraphicsItem *item = 0; QBENCHMARK { - scene.itemAt(0, 0); + item = scene.itemAt(0, 0); } //let QGraphicsScene::_q_polishItems be called so ~QGraphicsItem doesn't spend all his time cleaning the unpolished list -- cgit v0.12 From b77624c18896e149f338cb512369215b11bba685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Wed, 17 Feb 2010 16:30:52 +0100 Subject: Compiler warnings in QGraphicsView benchmark. --- .../gui/graphicsview/qgraphicsview/tst_qgraphicsview.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/benchmarks/gui/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 10e00a6..267fecc 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -560,7 +560,7 @@ void tst_QGraphicsView::imageRiver() #else for (int i = 0; i < 100; ++i) { #endif - AnimatedPixmapItem *item; + AnimatedPixmapItem *item = 0; if (direction == 0) item = new AnimatedPixmapItem((i % 4) + 1, 0, rotation, scale); if (direction == 1) item = new AnimatedPixmapItem(0, (i % 4) + 1, rotation, scale); if (direction == 2) item = new AnimatedPixmapItem((i % 4) + 1, (i % 4) + 1, rotation, scale); @@ -682,7 +682,7 @@ void tst_QGraphicsView::textRiver() #else for (int i = 0; i < 100; ++i) { #endif - AnimatedTextItem *item; + AnimatedTextItem *item = 0; if (direction == 0) item = new AnimatedTextItem((i % 4) + 1, 0, rotation, scale); if (direction == 1) item = new AnimatedTextItem(0, (i % 4) + 1, rotation, scale); if (direction == 2) item = new AnimatedTextItem((i % 4) + 1, (i % 4) + 1, rotation, scale); @@ -792,7 +792,7 @@ void tst_QGraphicsView::moveItemCache() #else for (int i = 0; i < 50; ++i) { #endif - AnimatedPixmapCacheItem *item; + AnimatedPixmapCacheItem *item = 0; if (direction == 0) item = new AnimatedPixmapCacheItem((i % 4) + 1, 0); if (direction == 1) item = new AnimatedPixmapCacheItem(0, (i % 4) + 1); if (direction == 2) item = new AnimatedPixmapCacheItem((i % 4) + 1, (i % 4) + 1); @@ -843,6 +843,7 @@ public: protected: void advance(int i) { + Q_UNUSED(i); if (partial) update(QRectF(boundingRect().center().x(), boundingRect().center().x(), 30, 30)); else -- cgit v0.12 From f9a790fcac5222c89797e896ed14cd5b4ccd1fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Wed, 17 Feb 2010 16:43:04 +0100 Subject: Remove platform dependent code from QGraphicsView benchmark. First, it doesn't make much sense to have platform specific code like this in a benchmark. Second, the Q_OS_SYMBIAN specific values makes more sense anyways, so we can use them on all platforms. --- .../qgraphicsview/tst_qgraphicsview.cpp | 34 +--------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/benchmarks/gui/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 267fecc..235afef 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -170,11 +170,7 @@ void tst_QGraphicsView::paintSingleItem() } } -#ifdef Q_OS_SYMBIAN -# define DEEP_STACKING_COUNT 85 -#else -# define DEEP_STACKING_COUNT 1000 -#endif +#define DEEP_STACKING_COUNT 85 void tst_QGraphicsView::paintDeepStackingItems() { @@ -555,11 +551,7 @@ void tst_QGraphicsView::imageRiver() QFile file(":/random.data"); QVERIFY(file.open(QIODevice::ReadOnly)); QDataStream str(&file); -#if defined(Q_OS_SYMBIAN) for (int i = 0; i < 50; ++i) { -#else - for (int i = 0; i < 100; ++i) { -#endif AnimatedPixmapItem *item = 0; if (direction == 0) item = new AnimatedPixmapItem((i % 4) + 1, 0, rotation, scale); if (direction == 1) item = new AnimatedPixmapItem(0, (i % 4) + 1, rotation, scale); @@ -578,11 +570,7 @@ void tst_QGraphicsView::imageRiver() #ifdef CALLGRIND_DEBUG CALLGRIND_START_INSTRUMENTATION #endif -#if defined(Q_OS_SYMBIAN) for (int i = 0; i < 50; ++i) { -#else - for (int i = 0; i < 100; ++i) { -#endif scene.advance(); while (view.count < (i+1)) qApp->processEvents(); @@ -677,11 +665,7 @@ void tst_QGraphicsView::textRiver() QFile file(":/random.data"); QVERIFY(file.open(QIODevice::ReadOnly)); QDataStream str(&file); -#if defined(Q_OS_SYMBIAN) for (int i = 0; i < 50; ++i) { -#else - for (int i = 0; i < 100; ++i) { -#endif AnimatedTextItem *item = 0; if (direction == 0) item = new AnimatedTextItem((i % 4) + 1, 0, rotation, scale); if (direction == 1) item = new AnimatedTextItem(0, (i % 4) + 1, rotation, scale); @@ -699,11 +683,7 @@ void tst_QGraphicsView::textRiver() #ifdef CALLGRIND_DEBUG CALLGRIND_START_INSTRUMENTATION #endif -#if defined(Q_OS_SYMBIAN) for (int i = 0; i < 50; ++i) { -#else - for (int i = 0; i < 100; ++i) { -#endif scene.advance(); while (view.count < (i+1)) qApp->processEvents(); @@ -787,11 +767,7 @@ void tst_QGraphicsView::moveItemCache() QFile file(":/random.data"); QVERIFY(file.open(QIODevice::ReadOnly)); QDataStream str(&file); -#if defined(Q_OS_SYMBIAN) for (int i = 0; i < 5; ++i) { -#else - for (int i = 0; i < 50; ++i) { -#endif AnimatedPixmapCacheItem *item = 0; if (direction == 0) item = new AnimatedPixmapCacheItem((i % 4) + 1, 0); if (direction == 1) item = new AnimatedPixmapCacheItem(0, (i % 4) + 1); @@ -813,11 +789,7 @@ void tst_QGraphicsView::moveItemCache() #ifdef CALLGRIND_DEBUG CALLGRIND_START_INSTRUMENTATION #endif -#if defined(Q_OS_SYMBIAN) for (int i = 0; i < 50; ++i) { -#else - for (int i = 0; i < 100; ++i) { -#endif scene.advance(); while (view.count < (i+1)) qApp->processEvents(); @@ -918,11 +890,7 @@ void tst_QGraphicsView::paintItemCache() #ifdef CALLGRIND_DEBUG CALLGRIND_START_INSTRUMENTATION #endif -#if defined(Q_OS_SYMBIAN) for (int i = 0; i < 5; ++i) { -#else - for (int i = 0; i < 50; ++i) { -#endif scene.advance(); while (view.count < (i+1)) qApp->processEvents(); -- cgit v0.12 From b37def83cb97dec7167f99a53dfada1b48dee59c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Thu, 18 Feb 2010 16:13:14 +0100 Subject: Stabilize QGraphicsView benchmarks. --- .../qgraphicsview/tst_qgraphicsview.cpp | 259 +++++++++++---------- 1 file changed, 134 insertions(+), 125 deletions(-) diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/benchmarks/gui/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 235afef..3c0ae71 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -45,11 +45,7 @@ #include #include #include -#ifdef Q_WS_X11 -QT_BEGIN_NAMESPACE -extern void qt_x11_wait_for_window_manager(QWidget *); -QT_END_NAMESPACE -#endif + #include "chiptester/chiptester.h" //#define CALLGRIND_DEBUG #ifdef CALLGRIND_DEBUG @@ -58,34 +54,65 @@ QT_END_NAMESPACE //TESTED_FILES= -class QEventWaiter : public QEventLoop +static inline void processEvents() { + QPixmapCache::clear(); + QApplication::flush(); + QApplication::processEvents(); + QApplication::processEvents(); +} + +class TestView : public QGraphicsView +{ + Q_OBJECT public: - QEventWaiter(QObject *receiver, QEvent::Type type) - : waiting(false), t(type) - { - receiver->installEventFilter(this); - } + TestView() : QGraphicsView(), waiting(false), timerId(-1) + {} - void wait() + void waitForPaintEvent(int timeout = 4000) { + if (waiting) + return; waiting = true; - exec(); + timerId = startTimer(timeout); + eventLoop.exec(); + killTimer(timerId); + timerId = -1; + waiting = false; } - bool eventFilter(QObject *receiver, QEvent *event) + void tryResize(int width, int height) { - Q_UNUSED(receiver); - if (waiting && event->type() == t) { - waiting = false; - exit(); + QDesktopWidget *desktop = QApplication::desktop(); + if (desktop->width() < width) + width = desktop->width(); + if (desktop->height() < height) + height = desktop->height(); + if (size() != QSize(width, height)) { + resize(width, height); + QTest::qWait(250); + processEvents(); } - return false; + } + +protected: + void paintEvent(QPaintEvent *event) + { + QGraphicsView::paintEvent(event); + if (waiting) + eventLoop.exit(); + } + + void timerEvent(QTimerEvent *event) + { + if (event->timerId() == timerId) + eventLoop.exit(); } private: + QEventLoop eventLoop; bool waiting; - QEvent::Type t; + int timerId; }; class tst_QGraphicsView : public QObject @@ -97,6 +124,7 @@ public: virtual ~tst_QGraphicsView(); public slots: + void initTestCase(); void init(); void cleanup(); @@ -126,6 +154,9 @@ private slots: void moveItemCache(); void paintItemCache_data(); void paintItemCache(); + +private: + TestView mView; }; tst_QGraphicsView::tst_QGraphicsView() @@ -136,8 +167,25 @@ tst_QGraphicsView::~tst_QGraphicsView() { } +void tst_QGraphicsView::initTestCase() +{ + mView.setFrameStyle(0); + mView.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + mView.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + mView.tryResize(100, 100); + mView.show(); + QTest::qWaitForWindowShown(&mView); + QTest::qWait(300); + processEvents(); +} + void tst_QGraphicsView::init() { + mView.setRenderHints(QPainter::RenderHints(0)); + mView.viewport()->setMouseTracking(false); + mView.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); + for (int i = 0; i < 3; ++i) + processEvents(); } void tst_QGraphicsView::cleanup() @@ -156,17 +204,14 @@ void tst_QGraphicsView::paintSingleItem() QGraphicsScene scene(0, 0, 100, 100); scene.addRect(0, 0, 10, 10); - QGraphicsView view(&scene); - view.show(); - view.resize(100, 100); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif + mView.setScene(&scene); + mView.tryResize(100, 100); + processEvents(); QImage image(100, 100, QImage::Format_ARGB32_Premultiplied); QPainter painter(&image); QBENCHMARK { - view.viewport()->render(&painter); + mView.viewport()->render(&painter); } } @@ -184,17 +229,14 @@ void tst_QGraphicsView::paintDeepStackingItems() lastRect = rect; } - QGraphicsView view(&scene); - view.show(); - view.resize(100, 100); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif + mView.setScene(&scene); + mView.tryResize(100, 100); + processEvents(); QImage image(100, 100, QImage::Format_ARGB32_Premultiplied); QPainter painter(&image); QBENCHMARK { - view.viewport()->render(&painter); + mView.viewport()->render(&painter); } } @@ -211,17 +253,14 @@ void tst_QGraphicsView::paintDeepStackingItems_clipped() lastRect = rect; } - QGraphicsView view(&scene); - view.show(); - view.resize(100, 100); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif + mView.setScene(&scene); + mView.tryResize(100, 100); + processEvents(); QImage image(100, 100, QImage::Format_ARGB32_Premultiplied); QPainter painter(&image); QBENCHMARK { - view.viewport()->render(&painter); + mView.viewport()->render(&painter); } } @@ -230,18 +269,14 @@ void tst_QGraphicsView::moveSingleItem() QGraphicsScene scene(0, 0, 100, 100); QGraphicsRectItem *item = scene.addRect(0, 0, 10, 10); - QGraphicsView view(&scene); - view.show(); - view.resize(100, 100); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif + mView.setScene(&scene); + mView.tryResize(100, 100); + processEvents(); - QEventWaiter waiter(view.viewport(), QEvent::Paint); int n = 1; QBENCHMARK { item->setPos(25 * n, 25 * n); - waiter.wait(); + mView.waitForPaintEvent(); n = n ? 0 : 1; } } @@ -267,6 +302,8 @@ void tst_QGraphicsView::mapPointToScene() QGraphicsView view; view.setTransform(transform); + processEvents(); + QBENCHMARK { view.mapToScene(point); } @@ -293,6 +330,8 @@ void tst_QGraphicsView::mapPointFromScene() QGraphicsView view; view.setTransform(transform); + processEvents(); + QBENCHMARK { view.mapFromScene(point); } @@ -319,6 +358,8 @@ void tst_QGraphicsView::mapRectToScene() QGraphicsView view; view.setTransform(transform); + processEvents(); + QBENCHMARK { view.mapToScene(rect); } @@ -345,6 +386,8 @@ void tst_QGraphicsView::mapRectFromScene() QGraphicsView view; view.setTransform(transform); + processEvents(); + QBENCHMARK { view.mapFromScene(rect); } @@ -376,13 +419,14 @@ void tst_QGraphicsView::chipTester() QFETCH(int, operation); ChipTester tester; - tester.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&tester); -#endif tester.setAntialias(antialias); tester.setOpenGL(opengl); tester.setOperation(ChipTester::Operation(operation)); + tester.show(); + QTest::qWaitForWindowShown(&tester); + QTest::qWait(250); + processEvents(); + QBENCHMARK { tester.runBenchmark(); } @@ -432,20 +476,20 @@ void tst_QGraphicsView::deepNesting() } scene.setItemIndexMethod(bsp ? QGraphicsScene::BspTreeIndex : QGraphicsScene::NoIndex); scene.setSortCacheEnabled(sortCache); + scene.setSceneRect(scene.sceneRect()); - QGraphicsView view(&scene); - view.setRenderHint(QPainter::Antialiasing); - view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif - QTest::qWait(250); + mView.setRenderHint(QPainter::Antialiasing); + mView.setScene(&scene); + mView.tryResize(600, 600); + (void)scene.itemAt(0, 0); + processEvents(); QBENCHMARK { #ifdef CALLGRIND_DEBUG CALLGRIND_START_INSTRUMENTATION #endif - view.viewport()->repaint(); + mView.viewport()->update(); + mView.waitForPaintEvent(); #ifdef CALLGRIND_DEBUG CALLGRIND_STOP_INSTRUMENTATION #endif @@ -499,23 +543,6 @@ private: bool scale; }; -class CountPaintEventView : public QGraphicsView -{ -public: - CountPaintEventView(QGraphicsScene *scene = 0) - : QGraphicsView(scene), count(0) - { } - - int count; - -protected: - void paintEvent(QPaintEvent *event) - { - ++count; - QGraphicsView::paintEvent(event); - }; -}; - void tst_QGraphicsView::imageRiver_data() { QTest::addColumn("direction"); @@ -537,13 +564,6 @@ void tst_QGraphicsView::imageRiver() QGraphicsScene scene(0, 0, 300, 300); - CountPaintEventView view(&scene); - view.resize(300, 300); - view.setFrameStyle(0); - view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - view.show(); - QPixmap pix(":/images/designer.png"); QVERIFY(!pix.isNull()); @@ -559,12 +579,15 @@ void tst_QGraphicsView::imageRiver() item->setPixmap(pix); int rnd1, rnd2; str >> rnd1 >> rnd2; - item->setPos(-pix.width() + rnd1 % (view.width() + pix.width()), - -pix.height() + rnd2 % (view.height() + pix.height())); + item->setPos(-pix.width() + rnd1 % (300 + pix.width()), + -pix.height() + rnd2 % (300 + pix.height())); scene.addItem(item); } + scene.setSceneRect(0, 0, 300, 300); - view.count = 0; + mView.setScene(&scene); + mView.tryResize(300, 300); + processEvents(); QBENCHMARK { #ifdef CALLGRIND_DEBUG @@ -572,8 +595,7 @@ void tst_QGraphicsView::imageRiver() #endif for (int i = 0; i < 50; ++i) { scene.advance(); - while (view.count < (i+1)) - qApp->processEvents(); + mView.waitForPaintEvent(); } #ifdef CALLGRIND_DEBUG CALLGRIND_STOP_INSTRUMENTATION @@ -651,13 +673,6 @@ void tst_QGraphicsView::textRiver() QGraphicsScene scene(0, 0, 300, 300); - CountPaintEventView view(&scene); - view.resize(300, 300); - view.setFrameStyle(0); - view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - view.show(); - QPixmap pix(":/images/designer.png"); QVERIFY(!pix.isNull()); @@ -672,12 +687,17 @@ void tst_QGraphicsView::textRiver() if (direction == 2) item = new AnimatedTextItem((i % 4) + 1, (i % 4) + 1, rotation, scale); int rnd1, rnd2; str >> rnd1 >> rnd2; - item->setPos(-pix.width() + rnd1 % (view.width() + pix.width()), - -pix.height() + rnd2 % (view.height() + pix.height())); + item->setPos(-pix.width() + rnd1 % (300 + pix.width()), + -pix.height() + rnd2 % (300 + pix.height())); + item->setAcceptDrops(false); + item->setAcceptHoverEvents(false); scene.addItem(item); } + scene.setSceneRect(0, 0, 300, 300); - view.count = 0; + mView.setScene(&scene); + mView.tryResize(300, 300); + processEvents(); QBENCHMARK { #ifdef CALLGRIND_DEBUG @@ -685,8 +705,7 @@ void tst_QGraphicsView::textRiver() #endif for (int i = 0; i < 50; ++i) { scene.advance(); - while (view.count < (i+1)) - qApp->processEvents(); + mView.waitForPaintEvent(); } #ifdef CALLGRIND_DEBUG CALLGRIND_STOP_INSTRUMENTATION @@ -753,13 +772,6 @@ void tst_QGraphicsView::moveItemCache() QGraphicsScene scene(0, 0, 300, 300); - CountPaintEventView view(&scene); - view.resize(600, 600); - view.setFrameStyle(0); - view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - view.show(); - QPixmap pix(":/images/wine.jpeg"); QVERIFY(!pix.isNull()); @@ -778,21 +790,23 @@ void tst_QGraphicsView::moveItemCache() item->setTransform(QTransform().rotate(45)); int rnd1, rnd2; str >> rnd1 >> rnd2; - item->setPos(-pix.width() + rnd1 % (view.width() + pix.width()), - -pix.height() + rnd2 % (view.height() + pix.height())); + item->setPos(-pix.width() + rnd1 % (400 + pix.width()), + -pix.height() + rnd2 % (400 + pix.height())); scene.addItem(item); } + scene.setSceneRect(0, 0, 400, 400); - view.count = 0; + mView.setScene(&scene); + mView.tryResize(400, 400); + processEvents(); QBENCHMARK { #ifdef CALLGRIND_DEBUG CALLGRIND_START_INSTRUMENTATION #endif - for (int i = 0; i < 50; ++i) { + for (int i = 0; i < 5; ++i) { scene.advance(); - while (view.count < (i+1)) - qApp->processEvents(); + mView.waitForPaintEvent(); } #ifdef CALLGRIND_DEBUG CALLGRIND_STOP_INSTRUMENTATION @@ -853,13 +867,6 @@ void tst_QGraphicsView::paintItemCache() QGraphicsScene scene(0, 0, 300, 300); - CountPaintEventView view(&scene); - view.resize(600, 600); - view.setFrameStyle(0); - view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - view.show(); - QPixmap pix(":/images/wine.jpeg"); QVERIFY(!pix.isNull()); @@ -883,8 +890,11 @@ void tst_QGraphicsView::paintItemCache() item->setTransform(QTransform().rotate(45)); item->setPos(0, 0); scene.addItem(item); + scene.setSceneRect(-100, -100, 600, 600); - view.count = 0; + mView.tryResize(600, 600); + mView.setScene(&scene); + processEvents(); QBENCHMARK { #ifdef CALLGRIND_DEBUG @@ -892,8 +902,7 @@ void tst_QGraphicsView::paintItemCache() #endif for (int i = 0; i < 5; ++i) { scene.advance(); - while (view.count < (i+1)) - qApp->processEvents(); + mView.waitForPaintEvent(); } #ifdef CALLGRIND_DEBUG CALLGRIND_STOP_INSTRUMENTATION -- cgit v0.12 From 059be19781a22d2e41f22072152589857d0fabf9 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 18 Feb 2010 16:21:42 +0100 Subject: Fixed a regression in dockwidgets that would jump when toplevel resized This was reproducible when the main window doesn't contain a central widget. Task-number: QTBUG-8107 Reviewed-by: ogoffart --- src/gui/widgets/qdockarealayout.cpp | 2 +- src/gui/widgets/qmainwindowlayout.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index d754800..0c39f42 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -2635,7 +2635,7 @@ void QDockAreaLayout::getGrid(QVector *_ver_struct_list, QSize bottom_max = docks[QInternal::BottomDock].maximumSize(); bottom_hint = bottom_hint.boundedTo(bottom_max).expandedTo(bottom_min); - fallbackToSizeHints = !have_central; + fallbackToSizeHints = false; if (_ver_struct_list != 0) { QVector &ver_struct_list = *_ver_struct_list; diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp index fc75c92..593e391 100644 --- a/src/gui/widgets/qmainwindowlayout.cpp +++ b/src/gui/widgets/qmainwindowlayout.cpp @@ -1772,6 +1772,7 @@ void QMainWindowLayout::setCentralWidget(QWidget *widget) if (savedState.isValid()) { #ifndef QT_NO_DOCKWIDGET savedState.dockAreaLayout.centralWidgetItem = layoutState.dockAreaLayout.centralWidgetItem; + savedState.dockAreaLayout.fallbackToSizeHints = true; #else savedState.centralWidgetItem = layoutState.centralWidgetItem; #endif -- cgit v0.12 From 3a1ad930266b7b10c04ee0481e6fa6b0b6bed739 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Thu, 18 Feb 2010 17:08:29 +0100 Subject: Always use display() in QEglContext, so initialization can occur Reviewed-By: Trustme --- src/gui/egl/qegl.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index 4d447cb..0ed95ea 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -101,7 +101,7 @@ bool QEglContext::chooseConfig // If we want the best pixel format, then return the first // matching configuration. if (match == QEgl::BestPixelFormat) { - eglChooseConfig(dpy, props.properties(), &cfg, 1, &matching); + eglChooseConfig(display(), props.properties(), &cfg, 1, &matching); if (matching < 1) continue; return true; @@ -111,13 +111,13 @@ bool QEglContext::chooseConfig // first that matches the pixel format we wanted. EGLint size = matching; EGLConfig *configs = new EGLConfig [size]; - eglChooseConfig(dpy, props.properties(), configs, size, &matching); + eglChooseConfig(display(), props.properties(), configs, size, &matching); for (EGLint index = 0; index < size; ++index) { EGLint red, green, blue, alpha; - eglGetConfigAttrib(dpy, configs[index], EGL_RED_SIZE, &red); - eglGetConfigAttrib(dpy, configs[index], EGL_GREEN_SIZE, &green); - eglGetConfigAttrib(dpy, configs[index], EGL_BLUE_SIZE, &blue); - eglGetConfigAttrib(dpy, configs[index], EGL_ALPHA_SIZE, &alpha); + eglGetConfigAttrib(display(), configs[index], EGL_RED_SIZE, &red); + eglGetConfigAttrib(display(), configs[index], EGL_GREEN_SIZE, &green); + eglGetConfigAttrib(display(), configs[index], EGL_BLUE_SIZE, &blue); + eglGetConfigAttrib(display(), configs[index], EGL_ALPHA_SIZE, &alpha); if (red == props.value(EGL_RED_SIZE) && green == props.value(EGL_GREEN_SIZE) && blue == props.value(EGL_BLUE_SIZE) && @@ -181,7 +181,7 @@ bool QEglContext::createContext(QEglContext *shareContext, const QEglProperties } } if (ctx == EGL_NO_CONTEXT) { - ctx = eglCreateContext(dpy, cfg, 0, contextProps.properties()); + ctx = eglCreateContext(display(), cfg, 0, contextProps.properties()); if (ctx == EGL_NO_CONTEXT) { qWarning() << "QEglContext::createContext(): Unable to create EGL context:" << errorString(eglGetError()); return false; @@ -197,7 +197,7 @@ void QEglContext::destroySurface(EGLSurface surface) if (surface != EGL_NO_SURFACE) { if (surface == currentSurface) doneCurrent(); - eglDestroySurface(dpy, surface); + eglDestroySurface(display(), surface); } } @@ -205,8 +205,7 @@ void QEglContext::destroySurface(EGLSurface surface) void QEglContext::destroyContext() { if (ctx != EGL_NO_CONTEXT && ownsContext) - eglDestroyContext(dpy, ctx); - dpy = EGL_NO_DISPLAY; + eglDestroyContext(display(), ctx); ctx = EGL_NO_CONTEXT; cfg = 0; } @@ -343,7 +342,7 @@ QEglProperties QEglContext::configProperties(EGLConfig cfg) const QEglProperties props; for (int name = 0x3020; name <= 0x304F; ++name) { EGLint value; - if (name != EGL_NONE && eglGetConfigAttrib(dpy, cfg, name, &value)) + if (name != EGL_NONE && eglGetConfigAttrib(display(), cfg, name, &value)) props.setValue(name, value); } eglGetError(); // Clear the error state. @@ -417,7 +416,7 @@ void QEglContext::dumpAllConfigs() if (!eglGetConfigs(display(), 0, 0, &count) || count < 1) return; EGLConfig *configs = new EGLConfig [count]; - eglGetConfigs(dpy, configs, count, &count); + eglGetConfigs(display(), configs, count, &count); for (EGLint index = 0; index < count; ++index) { props = configProperties(configs[index]); qWarning() << props.toString(); -- cgit v0.12