diff options
author | Tom Cooksey <thomas.cooksey@nokia.com> | 2010-04-27 13:59:50 (GMT) |
---|---|---|
committer | Tom Cooksey <thomas.cooksey@nokia.com> | 2010-04-29 14:49:25 (GMT) |
commit | 385d2d14bc7994c3abb1de11dacf9a81eea01d4a (patch) | |
tree | 5acc5f4bc1bf2eb84dc46392f5be91707a2e07dc | |
parent | d8a7d478681eaa6d92b70e3836eddc0fd52e79ab (diff) | |
download | Qt-385d2d14bc7994c3abb1de11dacf9a81eea01d4a.zip Qt-385d2d14bc7994c3abb1de11dacf9a81eea01d4a.tar.gz Qt-385d2d14bc7994c3abb1de11dacf9a81eea01d4a.tar.bz2 |
Add QPlatformGLWidgetSurface to GL integrtation
This class is a way to for the GL platform integration to track the
movement and resizing of a QGLWidget with respect to the top-level.
Most platform implementations will seperate the surface from the
context anyway, so this is a natural abstraction.
-rw-r--r-- | src/gui/kernel/qplatformintegration_lite.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qplatformintegration_lite.h | 3 | ||||
-rw-r--r-- | src/opengl/qgl.h | 9 | ||||
-rw-r--r-- | src/opengl/qgl_lite.cpp | 47 | ||||
-rw-r--r-- | src/opengl/qgl_p.h | 4 | ||||
-rw-r--r-- | src/opengl/qglplatformintegration_lite.h | 26 | ||||
-rw-r--r-- | src/plugins/platforms/testlite/qglxintegration.cpp (renamed from src/plugins/platforms/testlite/qglxglcontext.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/platforms/testlite/qglxintegration.h (renamed from src/plugins/platforms/testlite/qglxglcontext.h) | 0 |
8 files changed, 60 insertions, 31 deletions
diff --git a/src/gui/kernel/qplatformintegration_lite.cpp b/src/gui/kernel/qplatformintegration_lite.cpp index 3fa874c..2d181f1 100644 --- a/src/gui/kernel/qplatformintegration_lite.cpp +++ b/src/gui/kernel/qplatformintegration_lite.cpp @@ -67,7 +67,7 @@ QPlatformGLContext * QPlatformIntegration::createGLContext() return 0; } -QPlatformGLWidgetSurface * QPlatformIntegration::createGLWidgetSurface(QGLWidget*) +QPlatformGLWidgetSurface * QPlatformIntegration::createGLWidgetSurface() { return 0; } diff --git a/src/gui/kernel/qplatformintegration_lite.h b/src/gui/kernel/qplatformintegration_lite.h index 70bd0ce..a509b52 100644 --- a/src/gui/kernel/qplatformintegration_lite.h +++ b/src/gui/kernel/qplatformintegration_lite.h @@ -54,7 +54,6 @@ QT_MODULE(Gui) #ifndef QT_NO_OPENGL class QPlatformGLContext; class QPlatformGLWidgetSurface; -class QGLWidget; #endif class Q_GUI_EXPORT QPlatformIntegration @@ -76,7 +75,7 @@ public: #ifndef QT_NO_OPENGL virtual bool hasOpenGL() const; virtual QPlatformGLContext * createGLContext(); - virtual QPlatformGLWidgetSurface * createGLWidgetSurface(QGLWidget*); + virtual QPlatformGLWidgetSurface * createGLWidgetSurface(); #endif }; diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index b1e2ede..e389e3f 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -128,6 +128,10 @@ class QGLOverlayWidget; class QGLWidgetPrivate; class QGLContextPrivate; +#ifdef Q_WS_LITE +class QPlatformGLWidgetSurface; +#endif + // Namespace class: namespace QGL { @@ -531,6 +535,11 @@ public: void drawTexture(const QPointF &point, QMacCompatGLuint textureId, QMacCompatGLenum textureTarget = GL_TEXTURE_2D); #endif +#ifdef Q_WS_LITE + // Used by the platform context to get at the surface which it created for the glwidget: + QPlatformGLWidgetSurface* platformSurface(); +#endif + public Q_SLOTS: virtual void updateGL(); virtual void updateOverlayGL(); diff --git a/src/opengl/qgl_lite.cpp b/src/opengl/qgl_lite.cpp index 2a70545..fa1439c 100644 --- a/src/opengl/qgl_lite.cpp +++ b/src/opengl/qgl_lite.cpp @@ -60,7 +60,7 @@ QPlatformGLContext::~QPlatformGLContext() { } -QPlatformGLWidgetSurface::QPlatformGLWidgetSurface(QGLWidget*) +QPlatformGLWidgetSurface::QPlatformGLWidgetSurface() { } @@ -149,22 +149,30 @@ void QGLWidget::setContext(QGLContext *context, QGLContext* oldcx = d->glcx; d->glcx = context; - // If the application has set WA_TranslucentBackground and not explicitly set - // the alpha buffer size to zero, modify the format so it have an alpha channel - QGLFormat& fmt = d->glcx->d_func()->glFormat; - if (testAttribute(Qt::WA_TranslucentBackground) && fmt.alphaBufferSize() == -1) - fmt.setAlphaBufferSize(1); + if (!d->wsurf) { + // If the application has set WA_TranslucentBackground and not explicitly set + // the alpha buffer size to zero, modify the format so it have an alpha channel + QGLFormat format = d->glcx->d_func()->glFormat; + if (testAttribute(Qt::WA_TranslucentBackground) && format.alphaBufferSize() == -1) + format.setAlphaBufferSize(1); + + d->wsurf = QApplicationPrivate::platformIntegration()->createGLWidgetSurface(); + d->wsurf->create(this, format); + d->glcx->d_func()->glFormat = format; + } - bool success = false; if (!d->glcx->isValid()) - success = !d->glcx->create(shareContext ? shareContext : oldcx); + d->glcx->create(shareContext ? shareContext : oldcx); if (deleteOldContext) delete oldcx; } - - +QPlatformGLWidgetSurface* QGLWidget::platformSurface() +{ + Q_D(QGLWidget); + return d->wsurf; +} void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget *shareWidget) { @@ -181,7 +189,7 @@ QColor QGLContext::overlayTransparentColor() const return QColor(); // Invalid color } -uint QGLContext::colorIndex(const QColor& c) const +uint QGLContext::colorIndex(const QColor&) const { return 0; } @@ -214,7 +222,7 @@ QGLTemporaryContext::~QGLTemporaryContext() } -bool QGLWidgetPrivate::renderCxPm(QPixmap* pm) +bool QGLWidgetPrivate::renderCxPm(QPixmap*) { return false; } @@ -234,7 +242,7 @@ void QGLWidget::setMouseTracking(bool enable) bool QGLWidget::event(QEvent *e) { - QWidget::event(e); + return QWidget::event(e); } void QGLWidget::resizeEvent(QResizeEvent *) @@ -242,10 +250,17 @@ void QGLWidget::resizeEvent(QResizeEvent *) Q_D(QGLWidget); if (!isValid()) return; + + if (!d->wsurf) { + qWarning("QGLWidget::resizeEvent() - widget does not have a platform surface"); + return; + } + d->wsurf->setGeometry(geometry()); //### What about moveEvent? + makeCurrent(); -// if (!d->glcx->initialized()) -// glInit(); -// resizeGL(width(), height()); + if (!d->glcx->initialized()) + glInit(); + resizeGL(width(), height()); } diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index c7cd3fe..34cbdfc 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -165,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) || defined(Q_WS_LITE) , wsurf(0) #endif #if defined(Q_WS_X11) && !defined(QT_NO_EGL) @@ -207,6 +207,8 @@ public: void updatePaintDevice(); #elif defined(Q_WS_QWS) QWSGLWindowSurface *wsurf; +#elif defined (Q_WS_LITE) + QPlatformGLWidgetSurface* wsurf; #endif }; diff --git a/src/opengl/qglplatformintegration_lite.h b/src/opengl/qglplatformintegration_lite.h index d5bae45..94d4da0 100644 --- a/src/opengl/qglplatformintegration_lite.h +++ b/src/opengl/qglplatformintegration_lite.h @@ -48,13 +48,27 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE +// QGLPlatformWidgetSurface does _not_ inherit from QWindowSurface +// - The backing store may be totally unaware of it's existance. +class Q_OPENGL_EXPORT QPlatformGLWidgetSurface +{ +public: + QPlatformGLWidgetSurface(); + virtual ~QPlatformGLWidgetSurface(); + + virtual bool create(QGLWidget*, QGLFormat&) = 0; + + virtual void setGeometry(const QRect&) = 0; +}; + + class Q_OPENGL_EXPORT QPlatformGLContext { public: QPlatformGLContext(); virtual ~QPlatformGLContext(); - virtual bool create(QPaintDevice* device, const QGLFormat& format, QPlatformGLContext* shareContext) = 0; + virtual bool create(QPaintDevice* device, QGLFormat& format, QPlatformGLContext* shareContext) = 0; virtual void makeCurrent() = 0; virtual void doneCurrent() = 0; @@ -63,16 +77,6 @@ public: }; -// QGLPlatformWidgetSurface does _not_ inherit from QWindowSurface -// - The backing store may be totally unaware of it's existance. -class QPlatformGLWidgetSurface -{ -public: - QPlatformGLWidgetSurface(QGLWidget*); - virtual ~QPlatformGLWidgetSurface(); - - virtual void setGeometry(const QRect&) = 0; -}; QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qglxglcontext.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp index 6fdbb56..6fdbb56 100644 --- a/src/plugins/platforms/testlite/qglxglcontext.cpp +++ b/src/plugins/platforms/testlite/qglxintegration.cpp diff --git a/src/plugins/platforms/testlite/qglxglcontext.h b/src/plugins/platforms/testlite/qglxintegration.h index ff8fe85..ff8fe85 100644 --- a/src/plugins/platforms/testlite/qglxglcontext.h +++ b/src/plugins/platforms/testlite/qglxintegration.h |