diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-11-08 05:17:42 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-11-08 05:17:42 (GMT) |
commit | e600496d74c607f2316dd66f117a3d693769cca2 (patch) | |
tree | a7ff0c46f570c3ea4c43e1fd6262e808c2b99775 /tests/auto/qgl | |
parent | 22c01928872db30bd47c740abd714989ac910b95 (diff) | |
parent | 200bceafe3826fb096617d2ddcb738d2b29a6a7b (diff) | |
download | Qt-e600496d74c607f2316dd66f117a3d693769cca2.zip Qt-e600496d74c607f2316dd66f117a3d693769cca2.tar.gz Qt-e600496d74c607f2316dd66f117a3d693769cca2.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2:
More fix for QTBUG-14640:oci performance problem with qlonglong
Doc: Fixing typo
Fixed grabWidget sometimes returning uninitialized memory.
Fix Malayalam Rendering - 'Ra' is PreBase
Update .def files for QtGui and QtOpenVG
Use 32bit textures for alpha textures after all.
One more fix for dithering.
Doc: Fixing typo
Fix QTBUG-14640:oci performance problem with qlonglong
32bit => 16bit conversion has 4byte-aligned output.
Fix gcc bug in qReallocAligned
Prevented threading related crash in OpenGL module.
Fix possible crash in QStaticText and QDeclarativeTextLayout
Fix QTBUG-14132 oracle (xe) stored procedures with bind variables get errors
Diffstat (limited to 'tests/auto/qgl')
-rw-r--r-- | tests/auto/qgl/tst_qgl.cpp | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index e411508..4220b45 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -96,6 +96,7 @@ private slots: void shareRegister(); void qglContextDefaultBindTexture(); void textureCleanup(); + void threadImages(); }; tst_QGL::tst_QGL() @@ -2253,6 +2254,123 @@ void tst_QGL::textureCleanup() #endif } +namespace ThreadImages { + +class Producer : public QObject +{ + Q_OBJECT +public: + Producer() + { + startTimer(20); + + QThread *thread = new QThread; + thread->start(); + + connect(this, SIGNAL(destroyed()), thread, SLOT(quit())); + + moveToThread(thread); + connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); + } + +signals: + void imageReady(const QImage &image); + +protected: + void timerEvent(QTimerEvent *) + { + QImage image(256, 256, QImage::Format_RGB32); + QLinearGradient g(0, 0, 0, 256); + g.setColorAt(0, QColor(255, 180, 180)); + g.setColorAt(1, Qt::white); + g.setSpread(QGradient::ReflectSpread); + + QBrush brush(g); + brush.setTransform(QTransform::fromTranslate(0, delta)); + delta += 10; + + QPainter p(&image); + p.fillRect(image.rect(), brush); + + if (images.size() > 10) + images.removeFirst(); + + images.append(image); + + emit imageReady(image); + } + +private: + QList<QImage> images; + int delta; +}; + + +class DisplayWidget : public QGLWidget +{ + Q_OBJECT +public: + DisplayWidget(QWidget *parent) : QGLWidget(parent) {} + void paintEvent(QPaintEvent *) + { + QPainter p(this); + p.drawImage(rect(), m_image); + } + +public slots: + void setImage(const QImage &image) + { + m_image = image; + update(); + } + +private: + QImage m_image; +}; + +class Widget : public QWidget +{ + Q_OBJECT +public: + Widget() + : iterations(0) + , display(0) + { + startTimer(400); + } + + int iterations; + +protected: + void timerEvent(QTimerEvent *) + { + ++iterations; + + delete display; + display = new DisplayWidget(this); + connect(&producer, SIGNAL(imageReady(const QImage &)), display, SLOT(setImage(const QImage &))); + + display->setGeometry(rect()); + display->show(); + } + +private: + Producer producer; + DisplayWidget *display; +}; + +} + +void tst_QGL::threadImages() +{ + ThreadImages::Widget *widget = new ThreadImages::Widget; + widget->show(); + + while (widget->iterations <= 5) { + qApp->processEvents(); + } +} + class tst_QGLDummy : public QObject { Q_OBJECT |