diff options
author | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-07-22 16:43:06 (GMT) |
---|---|---|
committer | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-07-22 17:08:23 (GMT) |
commit | 5796404298446038878da065c32429a0e31e9506 (patch) | |
tree | c8257588585a52b65db321ce20c3972381343349 /src/opengl | |
parent | 8768bcfa0000bc216a7f722cd82ac6b06b85a70d (diff) | |
download | Qt-5796404298446038878da065c32429a0e31e9506.zip Qt-5796404298446038878da065c32429a0e31e9506.tar.gz Qt-5796404298446038878da065c32429a0e31e9506.tar.bz2 |
Fix build on Mac
The texture_from_pixmap patch removed a bindTexture overload from
QGLContextPrivate which is actually needed by all architectures. It was
just it's use in the mac compat methods which broke the build and
highlighted the issue.
Reviewed-By: Trustme
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/qgl.cpp | 35 | ||||
-rw-r--r-- | src/opengl/qgl_p.h | 1 |
2 files changed, 28 insertions, 8 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 392e750..edda6b6 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1866,6 +1866,27 @@ QImage QGLContextPrivate::convertToGLFormat(const QImage &image, bool force_prem return result; } +/*! \internal */ +QGLTexture *QGLContextPrivate::bindTexture(const QImage &image, GLenum target, GLint format, bool clean) +{ + const qint64 key = image.cacheKey(); + QGLTexture *texture = textureCacheLookup(key, target); + if (texture) { + glBindTexture(target, texture->id); + return texture; + } + + if (!texture) + texture = bindTexture(image, target, format, key, clean); + // NOTE: bindTexture(const QImage&, GLenum, GLint, const qint64, bool) should never return null + Q_ASSERT(texture); + + if (texture->id > 0) + const_cast<QImage &>(image).data_ptr()->is_cached = true; + + return texture; +} + QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, GLint format, const qint64 key, bool clean) { @@ -2011,16 +2032,12 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, if (!texture) texture = bindTexture(pixmap.toImage(), target, format, key, clean); - - // We should never return 0 as callers shouldn't need to null-check - static QGLTexture invalidTexture; - if (!texture) - texture = &invalidTexture; + // NOTE: bindTexture(const QImage&, GLenum, GLint, const qint64, bool) should never return null + Q_ASSERT(texture); if (texture->id > 0) const_cast<QPixmap &>(pixmap).data_ptr()->is_cached = true; - Q_ASSERT(texture); return texture; } @@ -2096,7 +2113,8 @@ GLuint QGLContext::bindTexture(const QImage &image, GLenum target, GLint format) GLuint QGLContext::bindTexture(const QImage &image, QMacCompatGLenum target, QMacCompatGLint format) { Q_D(QGLContext); - return d->bindTexture(image, GLenum(target), GLint(format), false); + QGLTexture *texture = d->bindTexture(image, GLenum(target), GLint(format), false); + return texture->id; } #endif @@ -2116,7 +2134,8 @@ GLuint QGLContext::bindTexture(const QPixmap &pixmap, GLenum target, GLint forma GLuint QGLContext::bindTexture(const QPixmap &pixmap, QMacCompatGLenum target, QMacCompatGLint format) { Q_D(QGLContext); - return d->bindTexture(pixmap, GLenum(target), GLint(format), false); + QGLTexture *texture = d->bindTexture(pixmap, GLenum(target), GLint(format), false, false); + return texture->id; } #endif diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 2ee3e1d..85dae0d 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -208,6 +208,7 @@ class QGLContextPrivate public: explicit QGLContextPrivate(QGLContext *context) : internal_context(false), q_ptr(context) {groupResources = new QGLContextGroupResources;} ~QGLContextPrivate() {if (!groupResources->refs.deref()) delete groupResources;} + QGLTexture *bindTexture(const QImage &image, GLenum target, GLint format, bool clean); QGLTexture *bindTexture(const QImage &image, GLenum target, GLint format, const qint64 key, bool clean = false); QGLTexture *bindTexture(const QPixmap &pixmap, GLenum target, GLint format, bool clean, bool canInvert = false); |