diff options
author | Jani Hautakangas <jani.hautakangas@nokia.com> | 2011-03-07 22:26:05 (GMT) |
---|---|---|
committer | Jani Hautakangas <jani.hautakangas@nokia.com> | 2011-03-15 17:09:32 (GMT) |
commit | 2355774b061d9e7213634ddec3c50280c4b10b70 (patch) | |
tree | b7f1b95a4839c2f6cc4f0cd119fd31aeb3929c15 /src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | |
parent | b3b332a50a6288164ca86d0691e9615f9c19abda (diff) | |
download | Qt-2355774b061d9e7213634ddec3c50280c4b10b70.zip Qt-2355774b061d9e7213634ddec3c50280c4b10b70.tar.gz Qt-2355774b061d9e7213634ddec3c50280c4b10b70.tar.bz2 |
Initial implementation of GLES2.0 resource pooling
Keep the implementation in separate
qpixmapdata_poolgl.cpp file until the pooling has
been verified and confirmed to work ok.
Task-number: QTBUG-15253 QTBUG-17850
Reviewed-by: Samuel Rødal
Diffstat (limited to 'src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp')
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index cda31e5..c8786fb 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1335,11 +1335,14 @@ void QGL2PaintEngineEx::drawPixmap(const QRectF& dest, const QPixmap & pixmap, c ensureActive(); d->transferMode(ImageDrawingMode); + QGLContext::BindOptions bindOptions = QGLContext::InternalBindOption|QGLContext::CanFlipNativePixmapBindOption; +#ifdef QGL_USE_TEXTURE_POOL + bindOptions |= QGLContext::TemporarilyCachedBindOption; +#endif + glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); QGLTexture *texture = - ctx->d_func()->bindTexture(pixmap, GL_TEXTURE_2D, GL_RGBA, - QGLContext::InternalBindOption - | QGLContext::CanFlipNativePixmapBindOption); + ctx->d_func()->bindTexture(pixmap, GL_TEXTURE_2D, GL_RGBA, bindOptions); GLfloat top = texture->options & QGLContext::InvertedYBindOption ? (pixmap.height() - src.top()) : src.top(); GLfloat bottom = texture->options & QGLContext::InvertedYBindOption ? (pixmap.height() - src.bottom()) : src.bottom(); @@ -1351,6 +1354,12 @@ void QGL2PaintEngineEx::drawPixmap(const QRectF& dest, const QPixmap & pixmap, c d->updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, state()->renderHints & QPainter::SmoothPixmapTransform, texture->id); d->drawTexture(dest, srcRect, pixmap.size(), isOpaque, isBitmap); + + if (texture->options&QGLContext::TemporarilyCachedBindOption) { + // pixmap was temporarily cached as a QImage texture by pooling system + // and should be destroyed immediately + QGLTextureCache::instance()->remove(ctx, texture->id); + } } void QGL2PaintEngineEx::drawImage(const QRectF& dest, const QImage& image, const QRectF& src, @@ -1375,12 +1384,23 @@ void QGL2PaintEngineEx::drawImage(const QRectF& dest, const QImage& image, const glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); - QGLTexture *texture = ctx->d_func()->bindTexture(image, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption); + QGLContext::BindOptions bindOptions = QGLContext::InternalBindOption; +#ifdef QGL_USE_TEXTURE_POOL + bindOptions |= QGLContext::TemporarilyCachedBindOption; +#endif + + QGLTexture *texture = ctx->d_func()->bindTexture(image, GL_TEXTURE_2D, GL_RGBA, bindOptions); GLuint id = texture->id; d->updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, state()->renderHints & QPainter::SmoothPixmapTransform, id); d->drawTexture(dest, src, image.size(), !image.hasAlphaChannel()); + + if (texture->options&QGLContext::TemporarilyCachedBindOption) { + // image was temporarily cached by texture pooling system + // and should be destroyed immediately + QGLTextureCache::instance()->remove(ctx, texture->id); + } } void QGL2PaintEngineEx::drawStaticTextItem(QStaticTextItem *textItem) |