diff options
author | Paul Olav Tvete <paul.tvete@nokia.com> | 2010-07-19 12:32:08 (GMT) |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@nokia.com> | 2010-07-19 12:32:08 (GMT) |
commit | 680e7b8fb3b675842a69fb65024942fe838a8dd2 (patch) | |
tree | d1b588e71a6e9dea60f006fb1110be66a69093e8 /src/opengl | |
parent | df6549d1b95af017305744af04a7bb3b10025660 (diff) | |
parent | e97e3616a33ed93283157514c6b208e071aca8be (diff) | |
download | Qt-680e7b8fb3b675842a69fb65024942fe838a8dd2.zip Qt-680e7b8fb3b675842a69fb65024942fe838a8dd2.tar.gz Qt-680e7b8fb3b675842a69fb65024942fe838a8dd2.tar.bz2 |
Merge remote branch 'remotes/lighthouse/4.7' into lighthouse-master
Conflicts:
src/opengl/qgl_p.h
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/opengl.pro | 7 | ||||
-rw-r--r-- | src/opengl/qgl.cpp | 17 | ||||
-rw-r--r-- | src/opengl/qgl_p.h | 17 | ||||
-rw-r--r-- | src/opengl/qgl_qpa.cpp | 255 | ||||
-rw-r--r-- | src/opengl/qglpixelbuffer_p.h | 4 | ||||
-rw-r--r-- | src/opengl/qglpixelbuffer_stub.cpp | 84 | ||||
-rw-r--r-- | src/opengl/qwindowsurface_gl.cpp | 42 | ||||
-rw-r--r-- | src/opengl/qwindowsurface_gl_p.h | 6 |
8 files changed, 411 insertions, 21 deletions
diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index d6011cf..772c27f 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -11,7 +11,7 @@ unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui include(../qbase.pri) -!win32:!embedded:!mac:CONFIG += x11 +!win32:!embedded:!mac:!qpa:CONFIG += x11 contains(QT_CONFIG, opengl):CONFIG += opengl contains(QT_CONFIG, opengles1):CONFIG += opengles1 contains(QT_CONFIG, opengles2):CONFIG += opengles2 @@ -77,6 +77,11 @@ SOURCES += qgl.cpp \ } +qpa { + SOURCES += qgl_qpa.cpp \ + qglpixelbuffer_stub.cpp +} + x11 { contains(QT_CONFIG, egl) { SOURCES += qgl_x11egl.cpp \ diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index c625c27..5c49543 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -98,7 +98,7 @@ QT_BEGIN_NAMESPACE -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) +#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA) QGLExtensionFuncs QGLContextPrivate::qt_extensionFuncs; #endif @@ -1395,6 +1395,10 @@ QGLFormat::OpenGLVersionFlags QGLFormat::openGLVersionFlags() } } +#ifdef Q_WS_QPA + hasOpenGL(); // ### I have no idea why this is needed here, but it makes things work for testlite +#endif + QString versionString(QLatin1String(reinterpret_cast<const char*>(glGetString(GL_VERSION)))); OpenGLVersionFlags versionFlags = qOpenGLVersionFlagsFromString(versionString); if (currentCtx) { @@ -1667,7 +1671,10 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) # endif vi = 0; #endif -#ifndef QT_NO_EGL +#if defined(Q_WS_QPA) + platformContext = 0; +#endif +#if !defined(QT_NO_EGL) ownsEglContext = false; eglContext = 0; eglSurface = EGL_NO_SURFACE; @@ -2256,7 +2263,7 @@ static void convertToGLFormatHelper(QImage &dst, const QImage &img, GLenum textu } } -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) +#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA) QGLExtensionFuncs& QGLContextPrivate::extensionFuncs(const QGLContext *) { return qt_extensionFuncs; @@ -4070,7 +4077,7 @@ void QGLWidget::resizeOverlayGL(int, int) /*! \fn bool QGLWidget::event(QEvent *e) \reimp */ -#if !defined(Q_OS_WINCE) && !defined(Q_WS_QWS) +#if !defined(Q_OS_WINCE) && !defined(Q_WS_QWS) && !defined(Q_WS_QPA) bool QGLWidget::event(QEvent *e) { Q_D(QGLWidget); @@ -5273,7 +5280,7 @@ void QGLWidgetPrivate::initContext(QGLContext *context, const QGLWidget* shareWi glcx = new QGLContext(QGLFormat::defaultFormat(), q); } -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) +#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA) Q_GLOBAL_STATIC(QString, qt_gl_lib_name) Q_OPENGL_EXPORT void qt_set_gl_library_name(const QString& name) diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 5044795..f02b85f 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -68,6 +68,10 @@ #include <QtGui/private/qegl_p.h> #endif +#if defined(Q_WS_QPA) +#include <QtGui/QPlatformGLContext> +#endif + QT_BEGIN_NAMESPACE class QGLContext; @@ -161,7 +165,7 @@ class QGLWidgetPrivate : public QWidgetPrivate public: QGLWidgetPrivate() : QWidgetPrivate() , disable_clear_on_painter_begin(false) -#ifdef Q_WS_QWS +#if defined(Q_WS_QWS) , wsurf(0) #endif #if defined(Q_WS_X11) && !defined(QT_NO_EGL) @@ -351,11 +355,14 @@ public: Qt::HANDLE threadId; #endif #ifndef QT_NO_EGL - uint ownsEglContext : 1; QEglContext *eglContext; EGLSurface eglSurface; void destroyEglSurfaceForDevice(); EGLSurface eglSurfaceForDevice() const; +#endif + +#if defined(Q_WS_QPA) + QPlatformGLContext *platformContext; #elif defined(Q_WS_X11) || defined(Q_WS_MAC) void* cx; #endif @@ -394,6 +401,10 @@ public: uint workaround_brokenFBOReadBack : 1; uint workaroundsCached : 1; +#ifndef QT_NO_EGL + uint ownsEglContext : 1; +#endif + QPaintDevice *paintDevice; QColor transpColor; QGLContext *q_ptr; @@ -416,7 +427,7 @@ public: static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *ctx) { return ctx->d_ptr->group->extensionFuncs(); } #endif -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) +#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA) static Q_OPENGL_EXPORT QGLExtensionFuncs qt_extensionFuncs; static Q_OPENGL_EXPORT QGLExtensionFuncs& extensionFuncs(const QGLContext *); #endif diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp new file mode 100644 index 0000000..aa124fe --- /dev/null +++ b/src/opengl/qgl_qpa.cpp @@ -0,0 +1,255 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> +#include <QtGui/private/qapplication_p.h> +#include <QPixmap> +#include <QDebug> + +#include <QtGui/private/qapplication_p.h> +#include <QtGui/QPlatformWindow> + +#include "qgl.h" +#include "qgl_p.h" + +QT_BEGIN_NAMESPACE + + +bool QGLFormat::hasOpenGL() +{ + return QApplicationPrivate::platformIntegration()->hasOpenGL(); +} + +bool QGLContext::chooseContext(const QGLContext* shareContext) +{ + Q_D(QGLContext); + if (!d->paintDevice && d->paintDevice->devType() != QInternal::Widget) { + d->valid = false; + }else { + QWidget *widget = static_cast<QWidget *>(d->paintDevice); + if (!widget->platformWindow()){ + widget->winId();//make window + } + d->platformContext = widget->platformWindow()->glContext(); + d->valid =(bool) d->platformContext; + } + + return d->valid; +} + +void QGLContext::reset() +{ + Q_D(QGLContext); + if (!d->valid) + return; + d->cleanup(); + doneCurrent(); + + if (d->platformContext) { + //dont delete. This will be done by the platform + d->platformContext = 0; + } + + d->crWin = false; + d->sharing = false; + d->valid = false; + d->transpColor = QColor(); + d->initDone = false; + QGLContextGroup::removeShare(this); +} + +void QGLContext::makeCurrent() +{ + Q_D(QGLContext); + d->platformContext->makeCurrent(); + QGLContextPrivate::setCurrentContext(this); +} + +void QGLContext::doneCurrent() +{ + Q_D(QGLContext); + d->platformContext->doneCurrent(); + QGLContextPrivate::setCurrentContext(0); +} + +void QGLContext::swapBuffers() const +{ + Q_D(const QGLContext); + d->platformContext->swapBuffers(); +} + +void *QGLContext::getProcAddress(const QString &procName) const +{ + Q_D(const QGLContext); + return d->platformContext->getProcAddress(procName); +} + +void QGLWidget::setContext(QGLContext *context, + const QGLContext* shareContext, + bool deleteOldContext) +{ + Q_D(QGLWidget); + if (context == 0) { + qWarning("QGLWidget::setContext: Cannot set null context"); + return; + } + if (!context->deviceIsPixmap() && context->device() != this) { + qWarning("QGLWidget::setContext: Context must refer to this widget"); + return; + } + + if (d->glcx) + d->glcx->doneCurrent(); + QGLContext* oldcx = d->glcx; + d->glcx = context; + + if (!d->glcx->isValid()) + d->glcx->create(shareContext ? shareContext : oldcx); + + if (deleteOldContext) + delete oldcx; +} + +void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget *shareWidget) +{ + initContext(context, shareWidget); +} + +bool QGLFormat::hasOpenGLOverlays() +{ + return false; +} + +QColor QGLContext::overlayTransparentColor() const +{ + return QColor(); // Invalid color +} + +uint QGLContext::colorIndex(const QColor&) const +{ + return 0; +} + +void QGLContext::generateFontDisplayLists(const QFont & fnt, int listBase) +{ + Q_UNUSED(fnt); + Q_UNUSED(listBase); +} + +/* + QGLTemporaryContext implementation +*/ +class QGLTemporaryContextPrivate +{ +public: + QWidget *widget; +}; + +QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) + : d(new QGLTemporaryContextPrivate) +{ + d->widget = new QWidget; + d->widget->setGeometry(0,0,3,3); + d->widget->winId(); + d->widget->platformWindow()->glContext()->makeCurrent(); +} + +QGLTemporaryContext::~QGLTemporaryContext() +{ + delete d->widget; +} + + +bool QGLWidgetPrivate::renderCxPm(QPixmap*) +{ + return false; +} + +/*! \internal + Free up any allocated colormaps. This fn is only called for + top-level widgets. +*/ +void QGLWidgetPrivate::cleanupColormaps() +{ +} + +void QGLWidget::setMouseTracking(bool enable) +{ + Q_UNUSED(enable); +} + +bool QGLWidget::event(QEvent *e) +{ + return QWidget::event(e); +} + +void QGLWidget::resizeEvent(QResizeEvent *e) +{ + return QWidget::resizeEvent(e); +} + + +const QGLContext* QGLWidget::overlayContext() const +{ + return 0; +} + +void QGLWidget::makeOverlayCurrent() +{ +} + + +void QGLWidget::updateOverlayGL() +{ +} + +const QGLColormap & QGLWidget::colormap() const +{ + Q_D(const QGLWidget); + return d->cmap; +} + +void QGLWidget::setColormap(const QGLColormap & c) +{ + Q_UNUSED(c); +} + +QT_END_NAMESPACE diff --git a/src/opengl/qglpixelbuffer_p.h b/src/opengl/qglpixelbuffer_p.h index 2a1f671..69678d0 100644 --- a/src/opengl/qglpixelbuffer_p.h +++ b/src/opengl/qglpixelbuffer_p.h @@ -197,6 +197,10 @@ public: EGLSurface pbuf; QEglContext *ctx; int textureFormat; +#elif defined(Q_WS_QPA) + //stubs + void *pbuf; + void *ctx; #endif }; diff --git a/src/opengl/qglpixelbuffer_stub.cpp b/src/opengl/qglpixelbuffer_stub.cpp new file mode 100644 index 0000000..2caef6b --- /dev/null +++ b/src/opengl/qglpixelbuffer_stub.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qdebug.h> +#include "qglpixelbuffer.h" +#include "qglpixelbuffer_p.h" + +#include <qimage.h> +#include <private/qgl_p.h> + +QT_BEGIN_NAMESPACE + +bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidget *shareWidget) +{ + Q_UNUSED(size); + Q_UNUSED(f); + Q_UNUSED(shareWidget); + return false; +} + +bool QGLPixelBufferPrivate::cleanup() +{ + return false; +} + +bool QGLPixelBuffer::bindToDynamicTexture(GLuint texture_id) +{ + Q_UNUSED(texture_id); + return false; +} + +void QGLPixelBuffer::releaseFromDynamicTexture() +{ +} + +GLuint QGLPixelBuffer::generateDynamicTexture() const +{ + return 0; +} + +bool QGLPixelBuffer::hasOpenGLPbuffers() +{ + return false; +} + +QT_END_NAMESPACE diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index e9da452..8c54fd1 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -290,7 +290,7 @@ QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const QGLWindowSurface::QGLWindowSurface(QWidget *window) : QWindowSurface(window), d_ptr(new QGLWindowSurfacePrivate) { - Q_ASSERT(window->isTopLevel()); +// Q_ASSERT(window->isTopLevel()); d_ptr->pb = 0; d_ptr->fbo = 0; d_ptr->ctx = 0; @@ -433,8 +433,13 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget(); Q_ASSERT(parent); +#if !defined(Q_WS_QPA) if (!geometry().isValid()) return; +#else + if (!size().isValid()) + return; +#endif // Needed to support native child-widgets... hijackWindow(parent); @@ -494,11 +499,13 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & } } #endif +#ifndef Q_WS_QPA //############################################### if (d_ptr->paintedRegion.boundingRect() != geometry()) { // Emits warning if not supported. Should never happen unless // setPartialUpdateSupport(true) has been called. context()->d_func()->swapRegion(&d_ptr->paintedRegion); } else +#endif context()->swapBuffers(); d_ptr->paintedRegion = QRegion(); @@ -663,20 +670,31 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & } +#if !defined(Q_WS_QPA) void QGLWindowSurface::setGeometry(const QRect &rect) { QWindowSurface::setGeometry(rect); d_ptr->geometry_updated = true; } - +#else +void QGLWindowSurface::resize(const QSize &size) +{ + QWindowSurface::resize(size); + d_ptr->geometry_updated = true; +} +#endif void QGLWindowSurface::updateGeometry() { if (!d_ptr->geometry_updated) return; d_ptr->geometry_updated = false; +#ifdef Q_WS_QPA + QSize surfSize = size(); +#else + QSize surfSize = geometry().size(); +#endif - QRect rect = geometry(); hijackWindow(window()); QGLContext *ctx = reinterpret_cast<QGLContext *>(window()->d_func()->extraData()->glContext); @@ -686,19 +704,19 @@ void QGLWindowSurface::updateGeometry() { const GLenum target = GL_TEXTURE_2D; - if (rect.width() <= 0 || rect.height() <= 0) + if (surfSize.width() <= 0 || surfSize.height() <= 0) return; - if (d_ptr->size == rect.size()) + if (d_ptr->size == surfSize) return; - d_ptr->size = rect.size(); + d_ptr->size = surfSize; if (d_ptr->ctx) { #ifndef QT_OPENGL_ES_2 if (d_ptr->destructive_swap_buffers) { glBindTexture(target, d_ptr->tex_id); - glTexImage2D(target, 0, GL_RGBA, rect.width(), rect.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, 0); + glTexImage2D(target, 0, GL_RGBA, surfSize.width(), surfSize.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, 0); glBindTexture(target, 0); } #endif @@ -723,10 +741,10 @@ void QGLWindowSurface::updateGeometry() { if (QGLExtensions::glExtensions() & QGLExtensions::FramebufferBlit) format.setSamples(8); - d_ptr->fbo = new QGLFramebufferObject(rect.size(), format); + d_ptr->fbo = new QGLFramebufferObject(surfSize, format); if (d_ptr->fbo->isValid()) { - qDebug() << "Created Window Surface FBO" << rect.size() + qDebug() << "Created Window Surface FBO" << surfSize << "with samples" << d_ptr->fbo->format().samples(); return; } else { @@ -747,7 +765,7 @@ void QGLWindowSurface::updateGeometry() { delete d_ptr->pb; - d_ptr->pb = new QGLPixelBuffer(rect.width(), rect.height(), + d_ptr->pb = new QGLPixelBuffer(surfSize.width(), surfSize.height(), QGLFormat(QGL::SampleBuffers | QGL::StencilBuffer | QGL::DepthBuffer), qt_gl_share_widget()); @@ -757,7 +775,7 @@ void QGLWindowSurface::updateGeometry() { glGenTextures(1, &d_ptr->pb_tex_id); glBindTexture(target, d_ptr->pb_tex_id); - glTexImage2D(target, 0, GL_RGBA, rect.width(), rect.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + glTexImage2D(target, 0, GL_RGBA, surfSize.width(), surfSize.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -783,7 +801,7 @@ void QGLWindowSurface::updateGeometry() { if (d_ptr->destructive_swap_buffers) { glGenTextures(1, &d_ptr->tex_id); glBindTexture(target, d_ptr->tex_id); - glTexImage2D(target, 0, GL_RGBA, rect.width(), rect.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, 0); + glTexImage2D(target, 0, GL_RGBA, surfSize.width(), surfSize.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, 0); glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h index 5e670fe..eebc42f 100644 --- a/src/opengl/qwindowsurface_gl_p.h +++ b/src/opengl/qwindowsurface_gl_p.h @@ -88,7 +88,13 @@ public: QPaintDevice *paintDevice(); void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + +#if !defined(Q_WS_QPA) void setGeometry(const QRect &rect); +#else + virtual void resize(const QSize &size); +#endif + void updateGeometry(); bool scroll(const QRegion &area, int dx, int dy); |