summaryrefslogtreecommitdiffstats
path: root/src/opengl/qgl.cpp
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2009-07-22 16:43:06 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2009-07-22 17:08:23 (GMT)
commit5796404298446038878da065c32429a0e31e9506 (patch)
treec8257588585a52b65db321ce20c3972381343349 /src/opengl/qgl.cpp
parent8768bcfa0000bc216a7f722cd82ac6b06b85a70d (diff)
downloadQt-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/qgl.cpp')
-rw-r--r--src/opengl/qgl.cpp35
1 files changed, 27 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