summaryrefslogtreecommitdiffstats
path: root/tests/auto/opengl/qglthreads/tst_qglthreads.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/opengl/qglthreads/tst_qglthreads.cpp')
-rw-r--r--tests/auto/opengl/qglthreads/tst_qglthreads.cpp133
1 files changed, 0 insertions, 133 deletions
diff --git a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp
index 90fc4e0f2a..76186f5575 100644
--- a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp
+++ b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp
@@ -185,139 +185,6 @@ void tst_QGLThreads::swapInThread()
QVERIFY(true);
}
-
-
-
-
-
-
-/*
- textureUploadInThread
-
- The purpose of this testcase is to verify that doing texture uploads in a background
- thread is possible and that it works.
- */
-
-class CreateAndUploadThread : public QThread
-{
- Q_OBJECT
-public:
- CreateAndUploadThread(QGLWidget *shareWidget, QSemaphore *semaphore)
- : m_semaphore(semaphore)
- {
- m_gl = new QGLWidget(0, shareWidget);
- moveToThread(this);
-
- }
-
- void moveContextToThread()
- {
- m_gl->context()->moveToThread(this);
- }
-
- ~CreateAndUploadThread()
- {
- delete m_gl;
- }
-
- void run() {
- m_gl->makeCurrent();
- QTime time;
- time.start();
- while (time.elapsed() < RUNNING_TIME) {
- int width = 400;
- int height = 300;
- QImage image(width, height, QImage::Format_RGB32);
- QPainter p(&image);
- p.fillRect(image.rect(), QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256)));
- p.setPen(Qt::red);
- p.setFont(QFont("SansSerif", 24));
- p.drawText(image.rect(), Qt::AlignCenter, "This is an autotest");
- p.end();
- m_gl->bindTexture(image, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption);
-
- m_semaphore->acquire(1);
-
- createdAndUploaded(image);
- }
- }
-
-signals:
- void createdAndUploaded(const QImage &image);
-
-private:
- QGLWidget *m_gl;
- QSemaphore *m_semaphore;
-};
-
-class TextureDisplay : public QGLWidget
-{
- Q_OBJECT
-public:
- TextureDisplay(QSemaphore *semaphore)
- : m_semaphore(semaphore)
- {
- }
-
- void paintEvent(QPaintEvent *) {
- QPainter p(this);
- for (int i=0; i<m_images.size(); ++i) {
- p.drawImage(m_positions.at(i), m_images.at(i));
- m_positions[i] += QPoint(1, 1);
- }
- update();
- }
-
-public slots:
- void receiveImage(const QImage &image) {
- m_images << image;
- m_positions << QPoint(-QRandomGenerator::global()->bounded(width() / 2), -QRandomGenerator::global()->bounded(height() / 2));
-
- m_semaphore->release(1);
-
- if (m_images.size() > 100) {
- m_images.takeFirst();
- m_positions.takeFirst();
- }
- }
-
-private:
- QList <QImage> m_images;
- QList <QPoint> m_positions;
-
- QSemaphore *m_semaphore;
-};
-
-void tst_QGLThreads::textureUploadInThread()
-{
- if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedOpenGL))
- QSKIP("No platformsupport for ThreadedOpenGL");
-
- // prevent producer thread from queuing up too many images
- QSemaphore semaphore(100);
- TextureDisplay display(&semaphore);
- CreateAndUploadThread thread(&display, &semaphore);
-
- connect(&thread, SIGNAL(createdAndUploaded(QImage)), &display, SLOT(receiveImage(QImage)));
-
- display.show();
- QVERIFY(QTest::qWaitForWindowActive(&display));
-
- thread.moveContextToThread();
- thread.start();
-
- while (thread.isRunning()) {
- qApp->processEvents();
- }
-
- QVERIFY(true);
-}
-
-
-
-
-
-
/*
renderInThread