diff options
author | Tom Cooksey <thomas.cooksey@nokia.com> | 2010-02-12 09:41:50 (GMT) |
---|---|---|
committer | Tom Cooksey <thomas.cooksey@nokia.com> | 2010-02-12 11:55:06 (GMT) |
commit | 95b320c17f4a0a505dd9da2362b0b7cc09ac64d8 (patch) | |
tree | 6537771b39a7cd78dc1ce75d9e7157f44d00c4d8 /tests/auto/qgl | |
parent | f42ad9029816891fd5c603b0fa6259e758db0e07 (diff) | |
download | Qt-95b320c17f4a0a505dd9da2362b0b7cc09ac64d8.zip Qt-95b320c17f4a0a505dd9da2362b0b7cc09ac64d8.tar.gz Qt-95b320c17f4a0a505dd9da2362b0b7cc09ac64d8.tar.bz2 |
Fix several bugs with GL texture cache
Reviewed-By: Trond
Autotest: tst_QGL::qglContextDefaultBindTexture
Diffstat (limited to 'tests/auto/qgl')
-rw-r--r-- | tests/auto/qgl/tst_qgl.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index d37d727..2983af3 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -57,6 +57,8 @@ #ifdef QT_BUILD_INTERNAL #include <QtOpenGL/private/qgl_p.h> #include <QtGui/private/qpixmapdata_p.h> +#include <QtGui/private/qimage_p.h> +#include <QtGui/private/qimagepixmapcleanuphooks_p.h> #endif //TESTED_CLASS= @@ -1947,7 +1949,6 @@ void tst_QGL::qglContextDefaultBindTexture() #ifdef QT_BUILD_INTERNAL QGLWidget w; w.makeCurrent(); - QGLContext *ctx = const_cast<QGLContext*>(w.context()); QImage *boundImage = new QImage(256, 256, QImage::Format_RGB32); @@ -1955,29 +1956,36 @@ void tst_QGL::qglContextDefaultBindTexture() QPixmap *boundPixmap = new QPixmap(256, 256); boundPixmap->fill(Qt::red); - // Check that calling QGLContext::bindTexture with default args adds textures to cache int startCacheItemCount = QGLTextureCache::instance()->size(); + GLuint boundImageTextureId = ctx->bindTexture(*boundImage); GLuint boundPixmapTextureId = ctx->bindTexture(*boundPixmap); + + // Make sure the image & pixmap have been added to the cache: QCOMPARE(QGLTextureCache::instance()->size(), startCacheItemCount+2); + // Make sure the image & pixmap have the is_cached flag set: + QVERIFY(QImagePixmapCleanupHooks::isImageCached(*boundImage)); + QVERIFY(QImagePixmapCleanupHooks::isPixmapCached(*boundPixmap)); + // Make sure the texture IDs returned are valid: QCOMPARE((bool)glIsTexture(boundImageTextureId), GL_TRUE); QCOMPARE((bool)glIsTexture(boundPixmapTextureId), GL_TRUE); - // Make sure the textures are still there after we delete the image/pixmap: + // Make sure the textures are still valid after we delete the image/pixmap: + // Also check that although the textures are left intact, the cache entries are removed: delete boundImage; boundImage = 0; + QCOMPARE((bool)glIsTexture(boundImageTextureId), GL_TRUE); + QCOMPARE(QGLTextureCache::instance()->size(), startCacheItemCount+1); delete boundPixmap; boundPixmap = 0; - QCOMPARE(QGLTextureCache::instance()->size(), startCacheItemCount+2); + QCOMPARE((bool)glIsTexture(boundPixmapTextureId), GL_TRUE); + QCOMPARE(QGLTextureCache::instance()->size(), startCacheItemCount); - // Make sure the textures are deleted from the cache after calling QGLContext::deleteTexture() + // Finally, make sure QGLContext::deleteTexture deletes the texture IDs: ctx->deleteTexture(boundImageTextureId); ctx->deleteTexture(boundPixmapTextureId); - QCOMPARE(QGLTextureCache::instance()->size(), startCacheItemCount); - - // Finally, make sure QGLContext::deleteTexture also deleted the texture IDs: QCOMPARE((bool)glIsTexture(boundImageTextureId), GL_FALSE); QCOMPARE((bool)glIsTexture(boundPixmapTextureId), GL_FALSE); #endif |