diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-04-21 12:22:24 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2010-04-21 12:22:24 (GMT) |
commit | 51dca5f8afc3aa619a3bb62858db78a85cc3ecef (patch) | |
tree | dfc1fb65b6a8e5e429f1701992548f8a0425decb /src/opengl/qgl.cpp | |
parent | 6f5ad5dcab8e6f702894c4fa5c016d9837375626 (diff) | |
parent | c74dac2a0ef5d1b428c4da4e48fab05f9886233a (diff) | |
download | Qt-51dca5f8afc3aa619a3bb62858db78a85cc3ecef.zip Qt-51dca5f8afc3aa619a3bb62858db78a85cc3ecef.tar.gz Qt-51dca5f8afc3aa619a3bb62858db78a85cc3ecef.tar.bz2 |
Merge remote branch 'origin/4.7' into lighthouse
Conflicts:
configure
src/gui/kernel/qapplication.cpp
src/gui/painting/qbackingstore.cpp
src/opengl/qgl.cpp
src/opengl/qgl_p.h
src/plugins/plugins.pro
tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir
tools/tools.pro
Diffstat (limited to 'src/opengl/qgl.cpp')
-rw-r--r-- | src/opengl/qgl.cpp | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 6c6f6d9..580f3d0 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -49,7 +49,7 @@ #include "private/qpixmap_x11_p.h" #define INT32 dummy_INT32 #define INT8 dummy_INT8 -#if !defined(QT_OPENGL_ES) +#ifdef QT_NO_EGL # include <GL/glx.h> #endif #undef INT32 @@ -1588,7 +1588,7 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) #endif #if defined(Q_WS_LITE) platformContext = 0; -#elif defined(QT_OPENGL_ES) +#elif !defined(QT_NO_EGL) ownsEglContext = false; eglContext = 0; eglSurface = EGL_NO_SURFACE; @@ -2214,8 +2214,8 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G Q_Q(QGLContext); #ifdef QGL_BIND_TEXTURE_DEBUG - printf("QGLContextPrivate::bindTexture(), imageSize=(%d,%d), internalFormat =0x%x, options=%x\n", - image.width(), image.height(), internalFormat, int(options)); + printf("QGLContextPrivate::bindTexture(), imageSize=(%d,%d), internalFormat =0x%x, options=%x, key=%llx\n", + image.width(), image.height(), internalFormat, int(options), key); QTime time; time.start(); #endif @@ -2448,9 +2448,10 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, // Try to use texture_from_pixmap const QX11Info *xinfo = qt_x11Info(paintDevice); if (pd->classId() == QPixmapData::X11Class && pd->pixelType() == QPixmapData::PixmapType - && xinfo && xinfo->screen() == pixmap.x11Info().screen()) + && xinfo && xinfo->screen() == pixmap.x11Info().screen() + && target == GL_TEXTURE_2D) { - texture = bindTextureFromNativePixmap(pd, key, options); + texture = bindTextureFromNativePixmap(const_cast<QPixmap*>(&pixmap), key, options); if (texture) { texture->options |= QGLContext::MemoryManagedBindOption; texture->boundPixmap = pd; @@ -2459,8 +2460,15 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, } #endif - if (!texture) - texture = bindTexture(pixmap.toImage(), target, format, key, options); + if (!texture) { + 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 + // bit texture which is much faster to access than a 32-bit one. + if (pixmap.depth() == 16 && !image.hasAlphaChannel() ) + image = image.convertToFormat(QImage::Format_RGB16); + texture = bindTexture(image, target, format, key, options); + } // NOTE: bindTexture(const QImage&, GLenum, GLint, const qint64, bool) should never return null Q_ASSERT(texture); @@ -2553,7 +2561,7 @@ GLuint QGLContext::bindTexture(const QImage &image, GLenum target, GLint format, return 0; Q_D(QGLContext); - QGLTexture *texture = d->bindTexture(image, target, format, false, options); + QGLTexture *texture = d->bindTexture(image, target, format, options); return texture->id; } @@ -2565,7 +2573,7 @@ GLuint QGLContext::bindTexture(const QImage &image, QMacCompatGLenum target, QMa return 0; Q_D(QGLContext); - QGLTexture *texture = d->bindTexture(image, GLenum(target), GLint(format), false, DefaultBindOption); + QGLTexture *texture = d->bindTexture(image, GLenum(target), GLint(format), DefaultBindOption); return texture->id; } @@ -2577,7 +2585,7 @@ GLuint QGLContext::bindTexture(const QImage &image, QMacCompatGLenum target, QMa return 0; Q_D(QGLContext); - QGLTexture *texture = d->bindTexture(image, GLenum(target), GLint(format), false, options); + QGLTexture *texture = d->bindTexture(image, GLenum(target), GLint(format), options); return texture->id; } #endif @@ -2765,6 +2773,18 @@ void QGLContext::drawTexture(const QRectF &target, GLuint textureId, GLenum text return; } #else + + if (d_ptr->active_engine && + d_ptr->active_engine->type() == QPaintEngine::OpenGL2) { + QGL2PaintEngineEx *eng = static_cast<QGL2PaintEngineEx*>(d_ptr->active_engine); + if (!eng->isNativePaintingActive()) { + QRectF src(0, 0, target.width(), target.height()); + QSize size(target.width(), target.height()); + eng->drawTexture(target, textureId, size, src); + return; + } + } + const bool wasEnabled = glIsEnabled(GL_TEXTURE_2D); GLint oldTexture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture); @@ -2815,6 +2835,7 @@ void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum text Q_UNUSED(textureTarget); qWarning("drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) not supported with OpenGL ES, use rect version instead"); #else + const bool wasEnabled = glIsEnabled(GL_TEXTURE_2D); GLint oldTexture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture); @@ -2828,6 +2849,18 @@ void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum text glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_WIDTH, &textureWidth); glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_HEIGHT, &textureHeight); + if (d_ptr->active_engine && + d_ptr->active_engine->type() == QPaintEngine::OpenGL2) { + QGL2PaintEngineEx *eng = static_cast<QGL2PaintEngineEx*>(d_ptr->active_engine); + if (!eng->isNativePaintingActive()) { + QRectF dest(point, QSizeF(textureWidth, textureHeight)); + QRectF src(0, 0, textureWidth, textureHeight); + QSize size(textureWidth, textureHeight); + eng->drawTexture(dest, textureId, size, src); + return; + } + } + qDrawTextureRect(QRectF(point, QSizeF(textureWidth, textureHeight)), textureWidth, textureHeight, textureTarget); if (!wasEnabled) @@ -3948,7 +3981,7 @@ bool QGLWidget::event(QEvent *e) } } -#if defined(QT_OPENGL_ES) +#ifndef QT_NO_EGL // A re-parent is likely to destroy the X11 window and re-create it. It is important // that we free the EGL surface _before_ the winID changes - otherwise we can leak. if (e->type() == QEvent::ParentAboutToChange) @@ -4907,7 +4940,7 @@ void QGLWidget::drawTexture(const QPointF &point, QMacCompatGLuint textureId, QM } #endif -#if !defined(QT_OPENGL_ES_1) +#ifndef QT_OPENGL_ES_1 Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_2_engine) #endif |