diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-06-11 09:54:24 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2010-06-11 11:23:50 (GMT) |
commit | 7497ae0504a4186103c835c3c0cfca5133f2d50e (patch) | |
tree | 5b7828d2afab72354030030bc09fb1fd1e0fd347 | |
parent | a498db43a02972e90df5f1cdd73e90260471f5f8 (diff) | |
download | Qt-7497ae0504a4186103c835c3c0cfca5133f2d50e.zip Qt-7497ae0504a4186103c835c3c0cfca5133f2d50e.tar.gz Qt-7497ae0504a4186103c835c3c0cfca5133f2d50e.tar.bz2 |
Added QPlatformGLContext to QPlatformWindow
and removed the the creator function. Child QGLWidgets don't work
-rw-r--r-- | src/gui/kernel/kernel.pri | 3 | ||||
-rw-r--r-- | src/gui/kernel/qplatformglcontext_lite.h (renamed from src/opengl/qglplatformintegration_lite.h) | 23 | ||||
-rw-r--r-- | src/gui/kernel/qplatformintegration_lite.cpp | 12 | ||||
-rw-r--r-- | src/gui/kernel/qplatformintegration_lite.h | 10 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow_lite.cpp | 5 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow_lite.h | 4 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_lite.cpp | 12 | ||||
-rw-r--r-- | src/opengl/opengl.pro | 6 | ||||
-rw-r--r-- | src/opengl/qgl_lite.cpp | 80 | ||||
-rw-r--r-- | src/opengl/qgl_p.h | 6 | ||||
-rw-r--r-- | src/plugins/platforms/testlite/qglxintegration.cpp | 157 | ||||
-rw-r--r-- | src/plugins/platforms/testlite/qglxintegration.h | 25 | ||||
-rw-r--r-- | src/plugins/platforms/testlite/qtestliteintegration.cpp | 18 | ||||
-rw-r--r-- | src/plugins/platforms/testlite/qtestliteintegration.h | 6 | ||||
-rw-r--r-- | src/plugins/platforms/testlite/qtestlitewindow.cpp | 27 | ||||
-rw-r--r-- | src/plugins/platforms/testlite/qtestlitewindow.h | 4 |
16 files changed, 76 insertions, 322 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index bc9e70c..f849ad7 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -208,7 +208,8 @@ embedded_lite { kernel/qplatformscreen_lite.h \ kernel/qplatformintegrationfactory_lite_p.h \ kernel/qplatformintegrationplugin_lite.h \ - kernel/qplatformwindow_lite.h + kernel/qplatformwindow_lite.h \ + kernel/qplatformglcontext_lite.h SOURCES += \ kernel/qapplication_lite.cpp \ diff --git a/src/opengl/qglplatformintegration_lite.h b/src/gui/kernel/qplatformglcontext_lite.h index bec920c..8aeb635 100644 --- a/src/opengl/qglplatformintegration_lite.h +++ b/src/gui/kernel/qplatformglcontext_lite.h @@ -48,28 +48,13 @@ 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; - virtual bool filterEvent(QEvent*); -}; - - class Q_OPENGL_EXPORT QPlatformGLContext { public: - QPlatformGLContext(); - virtual ~QPlatformGLContext(); + //QPlatformGLContext(); + //virtual ~QPlatformGLContext(); - virtual bool create(QPaintDevice* device, QGLFormat& format, QPlatformGLContext* shareContext) = 0; + //virtual bool create(QPaintDevice* device, QPlatformGLContext* shareContext) = 0; virtual void makeCurrent() = 0; virtual void doneCurrent() = 0; @@ -78,8 +63,6 @@ public: }; - - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/gui/kernel/qplatformintegration_lite.cpp b/src/gui/kernel/qplatformintegration_lite.cpp index 2d181f1..6499570 100644 --- a/src/gui/kernel/qplatformintegration_lite.cpp +++ b/src/gui/kernel/qplatformintegration_lite.cpp @@ -56,21 +56,9 @@ QPixmap QPlatformIntegration::grabWindow(WId window, int x, int y, int width, in return QPixmap(); } -#ifndef QT_NO_OPENGL bool QPlatformIntegration::hasOpenGL() const { return false; } -QPlatformGLContext * QPlatformIntegration::createGLContext() -{ - return 0; -} - -QPlatformGLWidgetSurface * QPlatformIntegration::createGLWidgetSurface() -{ - return 0; -} -#endif - QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformintegration_lite.h b/src/gui/kernel/qplatformintegration_lite.h index aa71c3d..88c3049 100644 --- a/src/gui/kernel/qplatformintegration_lite.h +++ b/src/gui/kernel/qplatformintegration_lite.h @@ -51,11 +51,6 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) -#ifndef QT_NO_OPENGL -class QPlatformGLContext; -class QPlatformGLWidgetSurface; -#endif - class Q_GUI_EXPORT QPlatformIntegration { public: @@ -73,12 +68,7 @@ public: virtual bool isVirtualDesktop() { return false; } virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; -// OpenGL Integration functions -#ifndef QT_NO_OPENGL virtual bool hasOpenGL() const; - virtual QPlatformGLContext * createGLContext(); - virtual QPlatformGLWidgetSurface * createGLWidgetSurface(); -#endif }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformwindow_lite.cpp b/src/gui/kernel/qplatformwindow_lite.cpp index c8a3ed5..151e93d 100644 --- a/src/gui/kernel/qplatformwindow_lite.cpp +++ b/src/gui/kernel/qplatformwindow_lite.cpp @@ -76,3 +76,8 @@ void QPlatformWindow::setOpacity(qreal level) Q_UNUSED(level); qWarning("This plugin does not support setting window opacity"); } + +QPlatformGLContext *QPlatformWindow::glContext() +{ + return 0; +} diff --git a/src/gui/kernel/qplatformwindow_lite.h b/src/gui/kernel/qplatformwindow_lite.h index 583ac28..0a94fc0 100644 --- a/src/gui/kernel/qplatformwindow_lite.h +++ b/src/gui/kernel/qplatformwindow_lite.h @@ -54,6 +54,8 @@ QT_BEGIN_NAMESPACE class QPlatformWindowPrivate; class QWidget; +class QPlatformGLContext; + class Q_GUI_EXPORT QPlatformWindow { Q_DECLARE_PRIVATE(QPlatformWindow); @@ -75,6 +77,8 @@ public: virtual void lower(); virtual void setOpacity(qreal level); + + virtual QPlatformGLContext *glContext(); protected: QScopedPointer<QPlatformWindowPrivate> d_ptr; }; diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index 25cd0f6..e1a8d0d 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -77,7 +77,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO Q_ASSERT(platformWindow); // QGLWidget does not need/work with a windowsurface - if (!surface && !q->inherits("QGLWidget")) { + if (!surface) {// && !q->inherits("QGLWidget")) { surface = QApplicationPrivate::platformIntegration()->createWindowSurface(q,platformWindow->winId()); } @@ -343,18 +343,20 @@ void QWidgetPrivate::show_sys() if (!q->isWindow()) return; - if (QWindowSurface *surface = q->windowSurface()) { + if (QPlatformWindow *window = q->platformWindow()) { const QRect geomRect = q->geometry(); - const QRect windowRect = q->platformWindow()->geometry(); + const QRect windowRect = window->geometry(); if (windowRect != geomRect) { q->platformWindow()->setGeometry(geomRect); - if (windowRect.size() != geomRect.size()) { - surface->resize(geomRect.size()); + if (QWindowSurface *surface = q->windowSurface()) + if (windowRect.size() != geomRect.size()) { + surface->resize(geomRect.size()); } } q->platformWindow()->setVisible(true); } + if (q->windowType() != Qt::Popup && q->windowType() != Qt::ToolTip && !(q->windowFlags() & Qt::X11BypassWindowManagerHint)) q->activateWindow(); //### } diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 53f9d3e..6670d14 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -79,10 +79,8 @@ SOURCES += qgl.cpp \ embedded_lite { DEFINES += QT_NO_EGL - SOURCES += qgl_lite.cpp - HEADERS += qglplatformintegration_lite.h - - SOURCES += qglpixelbuffer_stub.cpp + SOURCES += qgl_lite.cpp \ + qglpixelbuffer_stub.cpp } x11 { diff --git a/src/opengl/qgl_lite.cpp b/src/opengl/qgl_lite.cpp index 636c711..2003cc1 100644 --- a/src/opengl/qgl_lite.cpp +++ b/src/opengl/qgl_lite.cpp @@ -40,39 +40,18 @@ ****************************************************************************/ #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" -#include "qglplatformintegration_lite.h" QT_BEGIN_NAMESPACE -QPlatformGLContext::QPlatformGLContext() -{ -} - -QPlatformGLContext::~QPlatformGLContext() -{ -} - -QPlatformGLWidgetSurface::QPlatformGLWidgetSurface() -{ -} - -QPlatformGLWidgetSurface::~QPlatformGLWidgetSurface() -{ -} - -bool QPlatformGLWidgetSurface::filterEvent(QEvent*) -{ - // By default, return false to allow the event to pass through - return false; -} - bool QGLFormat::hasOpenGL() { @@ -82,8 +61,16 @@ bool QGLFormat::hasOpenGL() bool QGLContext::chooseContext(const QGLContext* shareContext) { Q_D(QGLContext); - d->platformContext = QApplicationPrivate::platformIntegration()->createGLContext(); - d->valid = d->platformContext->create(d->paintDevice, d->glFormat, shareContext ? shareContext->d_func()->platformContext : 0); + 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; } @@ -154,18 +141,6 @@ void QGLWidget::setContext(QGLContext *context, QGLContext* oldcx = d->glcx; d->glcx = context; - 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; - } - if (!d->glcx->isValid()) d->glcx->create(shareContext ? shareContext : oldcx); @@ -173,12 +148,6 @@ void QGLWidget::setContext(QGLContext *context, delete oldcx; } -QPlatformGLWidgetSurface* QGLWidget::platformSurface() -{ - Q_D(QGLWidget); - return d->wsurf; -} - void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget *shareWidget) { initContext(context, shareWidget); @@ -247,33 +216,12 @@ void QGLWidget::setMouseTracking(bool enable) bool QGLWidget::event(QEvent *e) { - Q_D(QGLWidget); - - if (d->wsurf) { - bool eventFiltered = d->wsurf->filterEvent(e); - if (eventFiltered) - return true; - } - return QWidget::event(e); } -void QGLWidget::resizeEvent(QResizeEvent *) +void QGLWidget::resizeEvent(QResizeEvent *e) { - 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()); + return QWidget::resizeEvent(e); } diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 37466d8..042d5ae 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -69,7 +69,7 @@ #endif #if defined(Q_WS_LITE) -#include <qglplatformintegration_lite.h> +#include <QtGui/QPlatformGLContext> #endif QT_BEGIN_NAMESPACE @@ -165,7 +165,7 @@ class QGLWidgetPrivate : public QWidgetPrivate public: QGLWidgetPrivate() : QWidgetPrivate() , disable_clear_on_painter_begin(false) -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) +#if defined(Q_WS_QWS) , wsurf(0) #endif #if defined(Q_WS_X11) && !defined(QT_NO_EGL) @@ -207,8 +207,6 @@ public: void updatePaintDevice(); #elif defined(Q_WS_QWS) QWSGLWindowSurface *wsurf; -#elif defined (Q_WS_LITE) - QPlatformGLWidgetSurface* wsurf; #endif }; diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp index 79596f5..ba89dbd 100644 --- a/src/plugins/platforms/testlite/qglxintegration.cpp +++ b/src/plugins/platforms/testlite/qglxintegration.cpp @@ -128,106 +128,24 @@ GLXFBConfig qt_glx_integration_choose_config(MyDisplay* xd, QGLFormat& format, i return chosenConfig; } - -QGLXGLWidgetSurface::QGLXGLWidgetSurface(MyDisplay* xd) - : QPlatformGLWidgetSurface() +QGLXGLContext::QGLXGLContext(WId winId, MyDisplay *xd, QGLFormat& format, QPlatformGLContext* shareContext) + : QPlatformGLContext() , m_xd(xd) + , m_drawable((Drawable)winId) , m_config(0) - , m_winId(0) - , m_widget(0) -{ -} - -QGLXGLWidgetSurface::~QGLXGLWidgetSurface() -{ -} - -static Colormap qt_glx_integration_colormap = 0; - - -bool QGLXGLWidgetSurface::create(QGLWidget *widget, QGLFormat& format) + , m_context(0) { - m_widget = widget; + GLXContext shareGlxContext = 0; + if (shareContext) + shareGlxContext = static_cast<QGLXGLContext*>(shareContext)->glxContext(); m_config = qt_glx_integration_choose_config(m_xd, format, GLX_WINDOW_BIT); - Window parentWindow = widget->window()->winId(); - - XVisualInfo* visualInfo; - visualInfo = glXGetVisualFromFBConfig(m_xd->display, m_config); - - // ### This will leak the colormap, but we need a colormap for each visual -// if (!qt_glx_integration_colormap) { - qt_glx_integration_colormap = XCreateColormap(m_xd->display, parentWindow, - visualInfo->visual, AllocNone); -// } - - XSetWindowAttributes windowAttribs; - windowAttribs.background_pixel = m_xd->whitePixel(); - windowAttribs.border_pixel = m_xd->blackPixel(); - windowAttribs.colormap = qt_glx_integration_colormap; - - m_winId = XCreateWindow(m_xd->display, parentWindow, - widget->x(), widget->y(), widget->width(), widget->height(), - 0, visualInfo->depth, InputOutput, visualInfo->visual, - CWBackPixel|CWBorderPixel|CWColormap, &windowAttribs); + m_context = glXCreateNewContext(m_xd->display, m_config, GLX_RGBA_TYPE, shareGlxContext, True); #ifdef MYX11_DEBUG - qDebug() << "QGLXGLWidgetSurface::create" << hex << "parent" << parentWindow << "win:" << m_winId << widget; + qDebug() << "QGLXGLContext::create context" << m_context; #endif - XSetWindowBackgroundPixmap(m_xd->display, m_winId, XNone); - XMapWindow(m_xd->display, m_winId); - - XFree(visualInfo); - return true; -} - -void QGLXGLWidgetSurface::setGeometry(const QRect& rect) -{ -#ifdef MYX11_DEBUG - qDebug() << "QGLXGLWidgetSurface::setGeometry" << rect << hex << m_xd->display << m_winId << "toplevel?" << m_widget->isWindow(); -#endif - //### toplevel QGLWidgets do have a separate X window owned by the surface, but it has a - // local geometry - if (m_widget->isWindow()) - XMoveResizeWindow(m_xd->display, m_winId, 0, 0, rect.width(), rect.height()); - else - XMoveResizeWindow(m_xd->display, m_winId, rect.x(), rect.y(), rect.width(), rect.height()); -} - -bool QGLXGLWidgetSurface::filterEvent(QEvent *e) -{ - if (e->type() == QEvent::ParentAboutToChange) { - // We temporarily hide the window and re-parent it with the root window - // as it's quite likely that the parent window is about to be deleted, - // which would otherwise destroy our window along with it. - XUnmapWindow(m_xd->display, m_winId); - XReparentWindow(m_xd->display, m_winId, m_xd->rootWindow(), 0, 0); -#ifdef MYX11_DEBUG - qDebug() << "filterEvent unmap" << hex << m_winId; -#endif - } - - if (e->type() == QEvent::ParentChange) { - // Once we've got a new parent, we need to reparent the window and show it again: - XReparentWindow(m_xd->display, m_winId, m_widget->window()->winId(), m_widget->x(), m_widget->y()); - XMapWindow(m_xd->display, m_winId); -#ifdef MYX11_DEBUG - qDebug() << "filterEvent reparent" << hex << m_winId << "to:" << m_widget->window()->winId(); -#endif - } - - return false; // Allow the event to pass through to QGLWidget -} - - -QGLXGLContext::QGLXGLContext(MyDisplay *xd) - : QPlatformGLContext() - , m_xd(xd) - , m_drawable(0) - , m_config(0) - , m_context(0) -{ } QGLXGLContext::~QGLXGLContext() @@ -238,63 +156,6 @@ QGLXGLContext::~QGLXGLContext() } } -bool QGLXGLContext::create(QPaintDevice* device, QGLFormat& format, QPlatformGLContext* shareContext) -{ - Q_UNUSED(format); - - if (device->devType() != QInternal::Widget) { - qWarning("Creating a GL context is only supported on QWidgets"); - return false; - } - - GLXContext shareGlxContext = 0; - if (shareContext) - shareGlxContext = static_cast<QGLXGLContext*>(shareContext)->glxContext(); - - - QWidget* widget = static_cast<QWidget*>(device); - QGLWidget* glWidget = qobject_cast<QGLWidget*>(widget); - if (glWidget) { - // Take the config from the QGLWidget's glx surface: - QGLXGLWidgetSurface* surface = static_cast<QGLXGLWidgetSurface*>(glWidget->platformSurface()); - m_config = surface->config(); - m_drawable = (Drawable)surface->winId(); -#ifdef MYX11_DEBUG - qDebug() << "QGLXGLContext::create" << hex << m_config << m_drawable; -#endif - } - else { - if (!widget->isTopLevel()) { - qWarning("Creating a GL context is only supported on top-level QWidgets"); - return false; - } - m_drawable = (Drawable)widget->platformWindow()->winId(); - - // ### This might choose a config with a visual that isn't compatable with the native window: - m_config = qt_glx_integration_choose_config(m_xd, format, GLX_WINDOW_BIT); - } - - m_context = glXCreateNewContext(m_xd->display, m_config, GLX_RGBA_TYPE, shareGlxContext, True); -#ifdef MYX11_DEBUG - qDebug() << "QGLXGLContext::create context" << m_context; -#endif - - // Get the XVisualInfo for the window: -// XWindowAttributes windowAttribs; -// XGetWindowAttributes(m_display, m_widget->winId(), &windowAttribs); -// XVisualInfo visualInfoTemplate; -// visualInfoTemplate.visualid = 33; //XVisualIDFromVisual(windowAttribs.visual); -// XVisualInfo *visualInfo; -// int matchingCount = 0; -// visualInfo = XGetVisualInfo(m_xd->display, VisualIDMask, &visualInfoTemplate, &matchingCount); - -// m_context = glXCreateContext(m_xd->display, visualInfo, 0, True); - -// qDebug("Created GLX context 0x%x for visual ID %d", m_context, visualInfoTemplate.visualid); - - return true; -} - void QGLXGLContext::makeCurrent() { #ifdef MYX11_DEBUG diff --git a/src/plugins/platforms/testlite/qglxintegration.h b/src/plugins/platforms/testlite/qglxintegration.h index 0302950..6d9a216 100644 --- a/src/plugins/platforms/testlite/qglxintegration.h +++ b/src/plugins/platforms/testlite/qglxintegration.h @@ -42,40 +42,19 @@ #ifndef Q_GLX_CONTEXT_H #define Q_GLX_CONTEXT_H -#include <QtOpenGL/qglplatformintegration_lite.h> +#include <QtGui/QPlatformGLContext> #include <GL/glx.h> QT_BEGIN_NAMESPACE class MyDisplay; -class QGLXGLWidgetSurface : public QPlatformGLWidgetSurface -{ -public: - QGLXGLWidgetSurface(MyDisplay* xd); - virtual ~QGLXGLWidgetSurface(); - - virtual bool create(QGLWidget*, QGLFormat&); - virtual void setGeometry(const QRect&); - virtual bool filterEvent(QEvent*); - - GLXFBConfig config() {return m_config;} - Window winId() {return m_winId;} - -private: - MyDisplay *m_xd; - GLXFBConfig m_config; - Window m_winId; - QGLWidget* m_widget; -}; - class QGLXGLContext : public QPlatformGLContext { public: - QGLXGLContext(MyDisplay* xd); + QGLXGLContext(WId winId, MyDisplay *xd, QGLFormat& format, QPlatformGLContext* shareContext); ~QGLXGLContext(); - virtual bool create(QPaintDevice* device, QGLFormat& format, QPlatformGLContext* shareContext); virtual void makeCurrent(); virtual void doneCurrent(); virtual void swapBuffers(); diff --git a/src/plugins/platforms/testlite/qtestliteintegration.cpp b/src/plugins/platforms/testlite/qtestliteintegration.cpp index 3fa3495..3ce9b7c 100644 --- a/src/plugins/platforms/testlite/qtestliteintegration.cpp +++ b/src/plugins/platforms/testlite/qtestliteintegration.cpp @@ -109,19 +109,15 @@ QTestLiteIntegration::QTestLiteIntegration(bool useOpenGL) QPixmapData *QTestLiteIntegration::createPixmapData(QPixmapData::PixelType type) const { -#ifndef QT_NO_OPENGL if (mUseOpenGL) return new QGLPixmapData(type); -#endif return new QRasterPixmapData(type); } QWindowSurface *QTestLiteIntegration::createWindowSurface(QWidget *widget, WId) const { -#ifndef QT_NO_OPENGL if (mUseOpenGL) return new QGLWindowSurface(widget); -#endif return new QTestLiteWindowSurface(mPrimaryScreen, widget); } @@ -140,23 +136,9 @@ QPixmap QTestLiteIntegration::grabWindow(WId window, int x, int y, int width, in return QPixmap::fromImage(img); } -#ifndef QT_NO_OPENGL bool QTestLiteIntegration::hasOpenGL() const { return glXQueryExtension(xd->display, 0, 0) != 0; } -QPlatformGLContext *QTestLiteIntegration::createGLContext() -{ - return new QGLXGLContext(xd); -} - -QPlatformGLWidgetSurface *QTestLiteIntegration::createGLWidgetSurface() -{ - return new QGLXGLWidgetSurface(xd); -} - -#endif // QT_NO_OPENGL - - QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qtestliteintegration.h b/src/plugins/platforms/testlite/qtestliteintegration.h index 8289a5c..01d428c 100644 --- a/src/plugins/platforms/testlite/qtestliteintegration.h +++ b/src/plugins/platforms/testlite/qtestliteintegration.h @@ -81,18 +81,12 @@ public: QList<QPlatformScreen *> screens() const { return mScreens; } -#ifndef QT_NO_OPENGL bool hasOpenGL() const; - QPlatformGLContext * createGLContext(); - QPlatformGLWidgetSurface * createGLWidgetSurface(); -#endif MyDisplay *xd; private: -#ifndef QT_NO_OPENGL bool mUseOpenGL; -#endif QTestLiteScreen *mPrimaryScreen; QList<QPlatformScreen *> mScreens; }; diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/testlite/qtestlitewindow.cpp index b5ae4fc..4ddb7ca 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindow.cpp @@ -55,6 +55,9 @@ #include <QTimer> #include <QApplication> +#include <QtOpenGL/QGLFormat> +#include "qglxintegration.h" + #include <stdio.h> #include <stdlib.h> @@ -146,7 +149,7 @@ private: QTestLiteWindow::QTestLiteWindow(const QTestLiteIntegration *platformIntegration, QTestLiteScreen */*screen*/, QWidget *window) - :QPlatformWindow(window) + :QPlatformWindow(window), mGLContext(0) { xd = platformIntegration->xd; xd->windowList.append(this); @@ -191,6 +194,7 @@ QTestLiteWindow::QTestLiteWindow(const QTestLiteIntegration *platformIntegration setWindowFlags(window->windowFlags()); //##### This should not be the plugin's responsibility + //xw->windowTL = this; } @@ -661,8 +665,6 @@ void QTestLiteWindow::setWindowTitle(const QString &title) XSetWMName(xd->display, x_window, &windowName); } - - GC QTestLiteWindow::createGC() { GC gc; @@ -674,14 +676,14 @@ GC QTestLiteWindow::createGC() return gc; } - void QTestLiteWindow::paintEvent() { #ifdef MYX11_DEBUG // qDebug() << "QTestLiteWindow::paintEvent" << shm_img.size() << painted; #endif - widget()->windowSurface()->flush(widget(), QRect(xpos,ypos,width, height), QPoint()); + if (QWindowSurface *surface = widget()->windowSurface()) + surface->flush(widget(), QRect(xpos,ypos,width, height), QPoint()); } @@ -1005,6 +1007,21 @@ void QTestLiteWindow::setCursor(QCursor * cursor) XFlush(xd->display); } +QPlatformGLContext *QTestLiteWindow::glContext() +{ + if (!mGLContext) { + mGLContext = createGLContext(); + } + return mGLContext; +} + +QPlatformGLContext *QTestLiteWindow::createGLContext() +{ + QGLFormat format; + QPlatformGLContext *context = new QGLXGLContext(x_window, xd, format, 0); + return context; +} + Cursor QTestLiteWindow::createCursorBitmap(QCursor * cursor) { XColor bg, fg; diff --git a/src/plugins/platforms/testlite/qtestlitewindow.h b/src/plugins/platforms/testlite/qtestlitewindow.h index 28e49be..5d27f3a 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.h +++ b/src/plugins/platforms/testlite/qtestlitewindow.h @@ -126,6 +126,8 @@ public: void setCursor(QCursor * cursor); + QPlatformGLContext *glContext(); + private: int xpos, ypos; int width, height; @@ -135,6 +137,7 @@ private: GC createGC(); Cursor createCursorShape(int cshape); Cursor createCursorBitmap(QCursor * cursor); + QPlatformGLContext *createGLContext(); int currentCursor; @@ -142,6 +145,7 @@ private: QTestLiteScreen *mScreen; Qt::WindowFlags window_flags; + QPlatformGLContext *mGLContext; friend class QTestLiteWindowSurface; // x_window, gc and windowSurface }; |