diff options
Diffstat (limited to 'src/opengl/qgl.cpp')
-rw-r--r-- | src/opengl/qgl.cpp | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 39f04d4..6720ae7 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -151,22 +151,6 @@ class QGLEngineSelector public: QGLEngineSelector() : engineType(QPaintEngine::MaxUser) { -#ifdef Q_WS_MAC - // The ATI X1600 driver for Mac OS X does not support return - // values from functions in GLSL. Since working around this in - // the GL2 engine would require a big, ugly rewrite, we're - // falling back to the GL 1 engine.. - QGLWidget *tmp = 0; - if (!QGLContext::currentContext()) { - tmp = new QGLWidget(); - tmp->makeCurrent(); - } - if (strstr((char *) glGetString(GL_RENDERER), "X1600")) - setPreferredPaintEngine(QPaintEngine::OpenGL); - if (tmp) - delete tmp; -#endif - } void setPreferredPaintEngine(QPaintEngine::Type type) { @@ -175,6 +159,25 @@ public: } QPaintEngine::Type preferredPaintEngine() { +#ifdef Q_WS_MAC + // The ATI X1600 driver for Mac OS X does not support return + // values from functions in GLSL. Since working around this in + // the GL2 engine would require a big, ugly rewrite, we're + // falling back to the GL 1 engine.. + static bool mac_x1600_check_done = false; + if (!mac_x1600_check_done) { + QGLWidget *tmp = 0; + if (!QGLContext::currentContext()) { + tmp = new QGLWidget(); + tmp->makeCurrent(); + } + if (strstr((char *) glGetString(GL_RENDERER), "X1600")) + engineType = QPaintEngine::OpenGL; + if (tmp) + delete tmp; + mac_x1600_check_done = true; + } +#endif if (engineType == QPaintEngine::MaxUser) { // No user-set engine - use the defaults #if defined(QT_OPENGL_ES_2) @@ -1584,7 +1587,10 @@ QGLTextureCache::QGLTextureCache() Q_ASSERT(qt_gl_texture_cache == 0); qt_gl_texture_cache = this; - QImagePixmapCleanupHooks::instance()->addPixmapHook(pixmapCleanupHook); + QImagePixmapCleanupHooks::instance()->addPixmapModificationHook(cleanupTextures); +#ifdef Q_WS_X11 + QImagePixmapCleanupHooks::instance()->addPixmapDestructionHook(cleanupPixmapSurfaces); +#endif QImagePixmapCleanupHooks::instance()->addImageHook(imageCleanupHook); } @@ -1592,7 +1598,10 @@ QGLTextureCache::~QGLTextureCache() { qt_gl_texture_cache = 0; - QImagePixmapCleanupHooks::instance()->removePixmapHook(pixmapCleanupHook); + QImagePixmapCleanupHooks::instance()->removePixmapModificationHook(cleanupTextures); +#ifdef Q_WS_X11 + QImagePixmapCleanupHooks::instance()->removePixmapDestructionHook(cleanupPixmapSurfaces); +#endif QImagePixmapCleanupHooks::instance()->removeImageHook(imageCleanupHook); } @@ -1660,7 +1669,7 @@ void QGLTextureCache::imageCleanupHook(qint64 cacheKey) } -void QGLTextureCache::pixmapCleanupHook(QPixmap* pixmap) +void QGLTextureCache::cleanupTextures(QPixmap* pixmap) { // ### remove when the GL texture cache becomes thread-safe if (qApp->thread() == QThread::currentThread()) { @@ -1669,14 +1678,21 @@ void QGLTextureCache::pixmapCleanupHook(QPixmap* pixmap) if (texture && texture->options & QGLContext::MemoryManagedBindOption) instance()->remove(cacheKey); } +} + #if defined(Q_WS_X11) +void QGLTextureCache::cleanupPixmapSurfaces(QPixmap* pixmap) +{ + // Remove any bound textures first: + cleanupTextures(pixmap); + QPixmapData *pd = pixmap->data_ptr().data(); if (pd->classId() == QPixmapData::X11Class) { Q_ASSERT(pd->ref == 1); // Make sure reference counting isn't broken QGLContextPrivate::destroyGlSurfaceForPixmap(pd); } -#endif } +#endif void QGLTextureCache::deleteIfEmpty() { |