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 /src/opengl | |
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
Diffstat (limited to 'src/opengl')
-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/opengl/qglplatformintegration_lite.h | 88 |
4 files changed, 18 insertions, 162 deletions
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/opengl/qglplatformintegration_lite.h b/src/opengl/qglplatformintegration_lite.h deleted file mode 100644 index bec920c..0000000 --- a/src/opengl/qglplatformintegration_lite.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QPLATFORM_GL_CONTEXT_H -#define QPLATFORM_GL_CONTEXT_H - -#include <QtOpenGL/qgl.h> - -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(); - - virtual bool create(QPaintDevice* device, QGLFormat& format, QPlatformGLContext* shareContext) = 0; - - virtual void makeCurrent() = 0; - virtual void doneCurrent() = 0; - virtual void swapBuffers() = 0; - virtual void* getProcAddress(const QString& procName) = 0; - -}; - - - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QPLATFORM_GL_INTEGRATION_P_H |