summaryrefslogtreecommitdiffstats
path: root/src/opengl/qgl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl/qgl.cpp')
-rw-r--r--src/opengl/qgl.cpp55
1 files changed, 49 insertions, 6 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 5f5864d..9520b2b 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -100,7 +100,8 @@
#if defined(QT_OPENGL_ES) && !defined(QT_NO_EGL)
#include <EGL/egl.h>
#endif
-#ifdef QGL_USE_TEXTURE_POOL
+
+#ifdef Q_OS_SYMBIAN
#include <private/qgltexturepool_p.h>
#endif
@@ -2042,10 +2043,6 @@ struct DDSFormat {
the pixmap/image that it stems from, e.g. installing destruction
hooks in them.
- \omitvalue TemporarilyCachedBindOption Used by paint engines on some
- platforms to indicate that the pixmap or image texture is possibly
- cached only temporarily and must be destroyed immediately after the use.
-
\omitvalue InternalBindOption
*/
@@ -2550,7 +2547,8 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G
#endif
const QImage &constRef = img; // to avoid detach in bits()...
-#ifdef QGL_USE_TEXTURE_POOL
+#ifdef Q_OS_SYMBIAN
+ // On Symbian we always use texture pool to reserve the texture
QGLTexturePool::instance()->createPermanentTexture(tx_id,
target,
0, internalFormat,
@@ -2562,6 +2560,7 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G
glTexImage2D(target, 0, internalFormat, img.width(), img.height(), 0, externalFormat,
pixel_type, constRef.bits());
#endif
+
#if defined(QT_OPENGL_ES_2)
if (genMipmap)
glGenerateMipmap(target);
@@ -2585,6 +2584,13 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G
QGLTexture *texture = new QGLTexture(q, tx_id, target, options);
QGLTextureCache::instance()->insert(q, key, texture, cost);
+#ifdef Q_OS_SYMBIAN
+ // Store the key so that QGLTexturePool
+ // is able to release this texture when needed.
+ texture->boundKey = key;
+ // And append to LRU list
+ QGLTexturePool::instance()->useTexture(texture);
+#endif
return texture;
}
@@ -2665,6 +2671,20 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target,
#endif
if (!texture) {
+#ifdef Q_OS_SYMBIAN
+ // On Symbian pixmaps are backed up by native CFbsBitmap
+ // which can be shared across processes. QVolatileImage wraps
+ // it and provides locking mechanism to pixel access.
+ QVolatileImage volatileImage = pd->toVolatileImage();
+ if (volatileImage.isNull()) { // TODO: raster graphics system don't provide volatile image (yet)
+ // NOTE! On Symbian raster graphics system QPixmap::toImage() makes deep copy
+ texture = bindTexture(pixmap.toImage(), target, format, key, options);
+ } else {
+ volatileImage.beginDataAccess();
+ texture = bindTexture(volatileImage.imageRef(), target, format, key, options);
+ volatileImage.endDataAccess(true);
+ }
+#else
QImage image = pixmap.toImage();
// If the system depth is 16 and the pixmap doesn't have an alpha channel
// then we convert it to RGB16 in the hope that it gets uploaded as a 16
@@ -2672,6 +2692,7 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target,
if (pixmap.depth() == 16 && !image.hasAlphaChannel() )
image = image.convertToFormat(QImage::Format_RGB16);
texture = bindTexture(image, target, format, key, options);
+#endif
}
// NOTE: bindTexture(const QImage&, GLenum, GLint, const qint64, bool) should never return null
Q_ASSERT(texture);
@@ -6063,4 +6084,26 @@ QSize QGLTexture::bindCompressedTexturePVR(const char *buf, int len)
#undef ctx
+#ifdef Q_OS_SYMBIAN
+void QGLTexture::freeTexture()
+{
+ if (!id)
+ return;
+
+ if (inTexturePool)
+ QGLTexturePool::instance()->detachTexture(this);
+
+ if (boundPixmap)
+ boundPixmap->releaseNativeImageHandle();
+
+ if (options & QGLContext::MemoryManagedBindOption) {
+ Q_ASSERT(context);
+ context->d_ptr->texture_destroyer->emitFreeTexture(context, 0, id);
+ }
+
+ id = 0;
+ boundKey = 0;
+}
+#endif
+
QT_END_NAMESPACE