diff options
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 4 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qtriangulator.cpp | 2 | ||||
-rw-r--r-- | src/opengl/opengl.pro | 23 | ||||
-rw-r--r-- | src/opengl/qgl.cpp | 8 | ||||
-rw-r--r-- | src/opengl/qgl.h | 14 | ||||
-rw-r--r-- | src/opengl/qgl_p.h | 6 | ||||
-rw-r--r-- | src/opengl/qgl_qpa.cpp | 157 | ||||
-rw-r--r-- | src/opengl/qgl_qws.cpp | 318 | ||||
-rw-r--r-- | src/opengl/qglpaintdevice_p.h | 2 | ||||
-rw-r--r-- | src/opengl/qglpixmapfilter.cpp | 1 | ||||
-rw-r--r-- | src/opengl/qglscreen_qws.cpp | 242 | ||||
-rw-r--r-- | src/opengl/qglscreen_qws.h | 127 | ||||
-rw-r--r-- | src/opengl/qglwindowsurface_qws.cpp | 133 | ||||
-rw-r--r-- | src/opengl/qglwindowsurface_qws_p.h | 90 | ||||
-rw-r--r-- | src/opengl/qgraphicsshadereffect.cpp | 4 | ||||
-rw-r--r-- | src/opengl/qgraphicsshadereffect_p.h | 2 | ||||
-rw-r--r-- | src/opengl/qgraphicssystem_gl.cpp | 114 | ||||
-rw-r--r-- | src/opengl/qgraphicssystem_gl_p.h | 80 | ||||
-rw-r--r-- | src/opengl/qpaintengine_opengl.cpp | 4 | ||||
-rw-r--r-- | src/opengl/qwindowsurface_gl.cpp | 168 | ||||
-rw-r--r-- | src/opengl/qwindowsurface_gl_p.h | 10 |
21 files changed, 148 insertions, 1361 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 3ac759c7ec..0aa2b8b202 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -2374,8 +2374,8 @@ void QGL2PaintEngineExPrivate::systemStateChanged() if (systemClip.isEmpty()) { useSystemClip = false; } else { - if (q->paintDevice()->devType() == QInternal::Widget && currentClipWidget) { - QWidgetPrivate *widgetPrivate = qt_widget_private(currentClipWidget->window()); + if (q->paintDevice()->devType() == QInternal::Widget && currentClipDevice) { + QWidgetPrivate *widgetPrivate = qt_widget_private(static_cast<QWidget *>(currentClipDevice)->window()); useSystemClip = widgetPrivate->extra && widgetPrivate->extra->inRenderWithPainter; } else { useSystemClip = true; diff --git a/src/opengl/gl2paintengineex/qtriangulator.cpp b/src/opengl/gl2paintengineex/qtriangulator.cpp index c1cad7e881..02cb52169e 100644 --- a/src/opengl/gl2paintengineex/qtriangulator.cpp +++ b/src/opengl/gl2paintengineex/qtriangulator.cpp @@ -41,7 +41,7 @@ #include "qtriangulator_p.h" -#include <QtGui/qdialog.h> +#include <QtWidgets/qdialog.h> #include <QtGui/qevent.h> #include <QtGui/qpainter.h> #include <QtGui/qpainterpath.h> diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index b30d4057db..2ff4ce0f31 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -1,6 +1,6 @@ TARGET = QtOpenGL QPRO_PWD = $$PWD -QT = core-private gui-private +QT = core-private gui-private widgets-private CONFIG += module MODULE_PRI = ../modules/qt_opengl.pri @@ -55,7 +55,6 @@ SOURCES += qgl.cpp \ HEADERS += qglshaderprogram.h \ qglpixmapfilter_p.h \ qgraphicsshadereffect_p.h \ - qgraphicssystem_gl_p.h \ qwindowsurface_gl_p.h \ qpixmapdata_gl_p.h \ gl2paintengineex/qglgradientcache_p.h \ @@ -73,7 +72,6 @@ SOURCES += qgl.cpp \ SOURCES += qglshaderprogram.cpp \ qglpixmapfilter.cpp \ qgraphicsshadereffect.cpp \ - qgraphicssystem_gl.cpp \ qwindowsurface_gl.cpp \ qpixmapdata_gl.cpp \ gl2paintengineex/qglgradientcache.cpp \ @@ -111,7 +109,6 @@ x11 { contains(QT_CONFIG, fontconfig) { contains(QT_CONFIG, system-freetype) { - embedded:CONFIG += opentype # pull in the proper freetype2 include directory include($$QT_SOURCE_TREE/config.tests/unix/freetype/freetype.pri) LIBS_PRIVATE += -lfreetype @@ -144,24 +141,6 @@ wince*: { HEADERS += qgl_egl_p.h } -embedded { - SOURCES += qgl_qws.cpp \ - qglpixelbuffer_egl.cpp \ - qglscreen_qws.cpp \ - qglwindowsurface_qws.cpp \ - qgl_egl.cpp - - HEADERS += qglscreen_qws.h \ - qglwindowsurface_qws_p.h \ - qgl_egl_p.h - - contains(QT_CONFIG, fontconfig) { - include($$QT_SOURCE_TREE/config.tests/unix/freetype/freetype.pri) - } else { - DEFINES *= QT_NO_FREETYPE - } -} - symbian { DEFINES += QGL_USE_TEXTURE_POOL QGL_NO_PRESERVED_SWAP SOURCES -= qpixmapdata_gl.cpp diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index f1fb2b4e7f..dc07a6f77d 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1711,7 +1711,7 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) vi = 0; #endif #if defined(Q_WS_QPA) - platformContext = 0; + windowContext = 0; #endif #if !defined(QT_NO_EGL) ownsEglContext = false; @@ -3330,7 +3330,7 @@ bool QGLContext::create(const QGLContext* shareContext) { Q_D(QGLContext); #ifdef Q_WS_QPA - if (!d->paintDevice && !d->platformContext) + if (!d->paintDevice && !d->windowContext) #else if (!d->paintDevice) #endif @@ -3420,8 +3420,8 @@ void QGLContext::setInitialized(bool on) const QGLContext* QGLContext::currentContext() { #ifdef Q_WS_QPA - if (const QPlatformGLContext *threadContext = QPlatformGLContext::currentContext()) { - return QGLContext::fromPlatformGLContext(const_cast<QPlatformGLContext *>(threadContext)); + if (const QWindowContext *threadContext = QWindowContext::currentContext()) { + return QGLContext::fromWindowContext(const_cast<QWindowContext *>(threadContext)); } return 0; #else diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index 4feaa83c64..7e151184c8 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -42,14 +42,14 @@ #ifndef QGL_H #define QGL_H -#include <QtGui/qwidget.h> +#include <QtWidgets/qwidget.h> #include <QtGui/qpaintengine.h> #include <QtOpenGL/qglcolormap.h> #include <QtCore/qmap.h> #include <QtCore/qscopedpointer.h> #ifdef Q_WS_QPA -#include <QtGui/QPlatformWindowFormat> +#include <QtGui/QWindowFormat> #endif QT_BEGIN_HEADER @@ -58,7 +58,7 @@ QT_BEGIN_HEADER # include <QtCore/qt_windows.h> #endif -#if defined(Q_WS_MAC) +#if defined(Q_OS_MAC) # include <OpenGL/gl.h> #elif defined(QT_OPENGL_ES_1) # if defined(Q_OS_MAC) @@ -283,8 +283,8 @@ public: static OpenGLVersionFlags openGLVersionFlags(); #if defined(Q_WS_QPA) - static QGLFormat fromPlatformWindowFormat(const QPlatformWindowFormat &format); - static QPlatformWindowFormat toPlatformWindowFormat(const QGLFormat &format); + static QGLFormat fromWindowFormat(const QWindowFormat &format); + static QWindowFormat toWindowFormat(const QGLFormat &format); #endif private: QGLFormatPrivate *d; @@ -397,7 +397,7 @@ public: static const QGLContext* currentContext(); #ifdef Q_WS_QPA - static QGLContext *fromPlatformGLContext(QPlatformGLContext *platformContext); + static QGLContext *fromWindowContext(QWindowContext *platformContext); #endif protected: virtual bool chooseContext(const QGLContext* shareContext = 0); @@ -429,7 +429,7 @@ protected: private: #ifdef Q_WS_QPA - QGLContext(QPlatformGLContext *platformContext); + QGLContext(QWindowContext *windowContext); #endif QScopedPointer<QGLContextPrivate> d_ptr; diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 4c22f0f3d7..ec5edf3ba1 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -60,7 +60,7 @@ #include "QtCore/qthreadstorage.h" #include "QtCore/qhash.h" #include "QtCore/qatomic.h" -#include "private/qwidget_p.h" +#include "QtWidgets/private/qwidget_p.h" #include "qcache.h" #include "qglpaintdevice_p.h" @@ -69,7 +69,7 @@ #endif #if defined(Q_WS_QPA) -#include <QtGui/QPlatformGLContext> +#include <QtGui/QWindowContext> #endif QT_BEGIN_NAMESPACE @@ -375,7 +375,7 @@ public: #endif #if defined(Q_WS_QPA) - QPlatformGLContext *platformContext; + QWindowContext *windowContext; void setupSharing(); #elif defined(Q_WS_X11) || defined(Q_WS_MAC) diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index 9ba8b75362..57c87d1238 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -40,12 +40,14 @@ ****************************************************************************/ #include <QApplication> -#include <QtGui/private/qapplication_p.h> +#include <private/qapplication_p.h> #include <QPixmap> #include <QDebug> -#include <QtGui/private/qapplication_p.h> +#include <private/qapplication_p.h> +#include <QtGui/QPlatformGLContext> #include <QtGui/QPlatformWindow> +#include <QtGui/QWindowContext> #include "qgl.h" #include "qgl_p.h" @@ -53,79 +55,64 @@ QT_BEGIN_NAMESPACE /*! - Returns an OpenGL format for the platform window format specified by \a format. + Returns an OpenGL format for the window format specified by \a format. */ -QGLFormat QGLFormat::fromPlatformWindowFormat(const QPlatformWindowFormat &format) +QGLFormat QGLFormat::fromWindowFormat(const QWindowFormat &format) { QGLFormat retFormat; - retFormat.setAccum(format.accum()); - if (format.accumBufferSize() >= 0) - retFormat.setAccumBufferSize(format.accumBufferSize()); - retFormat.setAlpha(format.alpha()); if (format.alphaBufferSize() >= 0) retFormat.setAlphaBufferSize(format.alphaBufferSize()); if (format.blueBufferSize() >= 0) retFormat.setBlueBufferSize(format.blueBufferSize()); - retFormat.setDepth(format.depth()); - if (format.depthBufferSize() >= 0) - retFormat.setDepthBufferSize(format.depthBufferSize()); - retFormat.setDirectRendering(format.directRendering()); - retFormat.setDoubleBuffer(format.doubleBuffer()); if (format.greenBufferSize() >= 0) retFormat.setGreenBufferSize(format.greenBufferSize()); if (format.redBufferSize() >= 0) retFormat.setRedBufferSize(format.redBufferSize()); - retFormat.setRgba(format.rgba()); - retFormat.setSampleBuffers(format.sampleBuffers()); - retFormat.setSamples(format.sampleBuffers()); - retFormat.setStencil(format.stencil()); - if (format.stencilBufferSize() >= 0) + if (format.depthBufferSize() >= 0) + retFormat.setDepthBufferSize(format.depthBufferSize()); + if (format.samples() > 1) { + retFormat.setSampleBuffers(format.samples()); + retFormat.setSamples(true); + } + if (format.stencilBufferSize() > 0) { + retFormat.setStencil(true); retFormat.setStencilBufferSize(format.stencilBufferSize()); + } + retFormat.setDoubleBuffer(format.swapBehavior() != QWindowFormat::SingleBuffer); retFormat.setStereo(format.stereo()); - retFormat.setSwapInterval(format.swapInterval()); return retFormat; } /*! - Returns a platform window format for the OpenGL format specified by \a format. + Returns a window format for the OpenGL format specified by \a format. */ -QPlatformWindowFormat QGLFormat::toPlatformWindowFormat(const QGLFormat &format) +QWindowFormat QGLFormat::toWindowFormat(const QGLFormat &format) { - QPlatformWindowFormat retFormat; - retFormat.setAccum(format.accum()); - if (format.accumBufferSize() >= 0) - retFormat.setAccumBufferSize(format.accumBufferSize()); - retFormat.setAlpha(format.alpha()); - if (format.alphaBufferSize() >= 0) - retFormat.setAlphaBufferSize(format.alphaBufferSize()); + QWindowFormat retFormat; + if (format.alpha()) + retFormat.setAlphaBufferSize(format.alphaBufferSize() == -1 ? 1 : format.alphaBufferSize()); if (format.blueBufferSize() >= 0) retFormat.setBlueBufferSize(format.blueBufferSize()); - retFormat.setDepth(format.depth()); - if (format.depthBufferSize() >= 0) - retFormat.setDepthBufferSize(format.depthBufferSize()); - retFormat.setDirectRendering(format.directRendering()); - retFormat.setDoubleBuffer(format.doubleBuffer()); if (format.greenBufferSize() >= 0) retFormat.setGreenBufferSize(format.greenBufferSize()); if (format.redBufferSize() >= 0) retFormat.setRedBufferSize(format.redBufferSize()); - retFormat.setRgba(format.rgba()); - retFormat.setSampleBuffers(format.sampleBuffers()); - if (format.samples() >= 0) - retFormat.setSamples(format.samples()); - retFormat.setStencil(format.stencil()); - if (format.stencilBufferSize() >= 0) - retFormat.setStencilBufferSize(format.stencilBufferSize()); + if (format.depth()) + retFormat.setDepthBufferSize(format.depthBufferSize() == -1 ? 1 : format.depthBufferSize()); + retFormat.setSwapBehavior(format.doubleBuffer() ? QWindowFormat::DoubleBuffer : QWindowFormat::DefaultSwapBehavior); + if (format.sampleBuffers()) + retFormat.setSamples(format.samples() == -1 ? 4 : format.samples()); + if (format.stencil()) + retFormat.setStencilBufferSize(format.stencilBufferSize() == -1 ? 1 : format.stencilBufferSize()); retFormat.setStereo(format.stereo()); - retFormat.setSwapInterval(format.swapInterval()); return retFormat; } void QGLContextPrivate::setupSharing() { Q_Q(QGLContext); - QPlatformGLContext *sharedPlatformGLContext = platformContext->platformWindowFormat().sharedGLContext(); - if (sharedPlatformGLContext) { - QGLContext *actualSharedContext = QGLContext::fromPlatformGLContext(sharedPlatformGLContext); + QWindowContext *sharedContext = windowContext->handle()->windowFormat().sharedContext(); + if (sharedContext) { + QGLContext *actualSharedContext = QGLContext::fromWindowContext(sharedContext); sharing = true; QGLContextGroup::addShare(q,actualSharedContext); } @@ -150,25 +137,25 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) d->valid = false; }else { QWidget *widget = static_cast<QWidget *>(d->paintDevice); - if (!widget->platformWindow()){ + if (!widget->windowHandle()->handle()) { QGLFormat glformat = format(); - QPlatformWindowFormat winFormat = QGLFormat::toPlatformWindowFormat(glformat); + QWindowFormat winFormat = QGLFormat::toWindowFormat(glformat); if (shareContext) { - winFormat.setSharedContext(shareContext->d_func()->platformContext); + winFormat.setSharedContext(shareContext->d_func()->windowContext); } + widget->windowHandle()->setSurfaceType(QWindow::OpenGLSurface); if (widget->testAttribute(Qt::WA_TranslucentBackground)) - winFormat.setAlpha(true); - winFormat.setWindowApi(QPlatformWindowFormat::OpenGL); + winFormat.setAlphaBufferSize(qMax(winFormat.alphaBufferSize(), 8)); winFormat.setWindowSurface(false); - widget->setPlatformWindowFormat(winFormat); + widget->windowHandle()->setWindowFormat(winFormat); widget->winId();//make window } - d->platformContext = widget->platformWindow()->glContext(); - Q_ASSERT(d->platformContext); - d->glFormat = QGLFormat::fromPlatformWindowFormat(d->platformContext->platformWindowFormat()); - d->valid =(bool) d->platformContext; + d->windowContext = widget->windowHandle()->glContext(); + Q_ASSERT(d->windowContext); + d->glFormat = QGLFormat::fromWindowFormat(d->windowContext->handle()->windowFormat()); + d->valid =(bool) d->windowContext; if (d->valid) { - d->platformContext->setQGLContextHandle(this,qDeleteQGLContext); + d->windowContext->setQGLContextHandle(this,qDeleteQGLContext); } d->setupSharing(); } @@ -190,15 +177,15 @@ void QGLContext::reset() d->transpColor = QColor(); d->initDone = false; QGLContextGroup::removeShare(this); - if (d->platformContext) { - d->platformContext->setQGLContextHandle(0,0); + if (d->windowContext) { + d->windowContext->setQGLContextHandle(0,0); } } void QGLContext::makeCurrent() { Q_D(QGLContext); - d->platformContext->makeCurrent(); + d->windowContext->makeCurrent(); if (!d->workaroundsCached) { d->workaroundsCached = true; @@ -213,19 +200,19 @@ void QGLContext::makeCurrent() void QGLContext::doneCurrent() { Q_D(QGLContext); - d->platformContext->doneCurrent(); + d->windowContext->doneCurrent(); } void QGLContext::swapBuffers() const { Q_D(const QGLContext); - d->platformContext->swapBuffers(); + d->windowContext->swapBuffers(); } void *QGLContext::getProcAddress(const QString &procName) const { Q_D(const QGLContext); - return d->platformContext->getProcAddress(procName); + return (void *)d->windowContext->getProcAddress(procName.toAscii()); } void QGLWidget::setContext(QGLContext *context, @@ -283,33 +270,32 @@ void QGLContext::generateFontDisplayLists(const QFont & fnt, int listBase) class QGLTemporaryContextPrivate { public: - QWidget *widget; - QPlatformGLContext *context; + QWindow *window; + QWindowContext *context; }; QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) : d(new QGLTemporaryContextPrivate) { - d->context = const_cast<QPlatformGLContext *>(QPlatformGLContext::currentContext()); + d->context = const_cast<QWindowContext *>(QWindowContext::currentContext()); if (d->context) d->context->doneCurrent(); - d->widget = new QWidget; - d->widget->setGeometry(0,0,3,3); - QPlatformWindowFormat format = d->widget->platformWindowFormat(); - format.setWindowApi(QPlatformWindowFormat::OpenGL); - format.setWindowSurface(false); - d->widget->setPlatformWindowFormat(format); - d->widget->winId(); - - d->widget->platformWindow()->glContext()->makeCurrent(); + + d->window = new QWindow; + d->window->setGeometry(QRect(0, 0, 3, 3)); + d->window->setSurfaceType(QWindow::OpenGLSurface); + d->window->create(); + + d->window->glContext()->makeCurrent(); } QGLTemporaryContext::~QGLTemporaryContext() { - d->widget->platformWindow()->glContext()->doneCurrent(); if (d->context) d->context->makeCurrent(); - delete d->widget; + else + d->window->glContext()->doneCurrent(); + delete d->window; } @@ -375,29 +361,28 @@ void QGLWidget::setColormap(const QGLColormap & c) Q_UNUSED(c); } -QGLContext::QGLContext(QPlatformGLContext *platformContext) +QGLContext::QGLContext(QWindowContext *windowContext) : d_ptr(new QGLContextPrivate(this)) { Q_D(QGLContext); - d->init(0,QGLFormat::fromPlatformWindowFormat(platformContext->platformWindowFormat())); - d->platformContext = platformContext; - d->platformContext->setQGLContextHandle(this,qDeleteQGLContext); + d->init(0,QGLFormat::fromWindowFormat(windowContext->handle()->windowFormat())); + d->windowContext = windowContext; + d->windowContext->setQGLContextHandle(this,qDeleteQGLContext); d->valid = true; d->setupSharing(); } /*! - Returns a OpenGL context for the platform-specific OpenGL context given by - \a platformContext. + Returns a OpenGL context for the window context specified by \a windowContext */ -QGLContext *QGLContext::fromPlatformGLContext(QPlatformGLContext *platformContext) +QGLContext *QGLContext::fromWindowContext(QWindowContext *windowContext) { - if (!platformContext) + if (!windowContext) return 0; - if (platformContext->qGLContextHandle()) { - return reinterpret_cast<QGLContext *>(platformContext->qGLContextHandle()); + if (windowContext->qGLContextHandle()) { + return reinterpret_cast<QGLContext *>(windowContext->qGLContextHandle()); } - QGLContext *glContext = new QGLContext(platformContext); + QGLContext *glContext = new QGLContext(windowContext); //Dont call create on context. This can cause the platformFormat to be set on the widget, which //will cause the platformWindow to be recreated. return glContext; diff --git a/src/opengl/qgl_qws.cpp b/src/opengl/qgl_qws.cpp deleted file mode 100644 index c0844786e2..0000000000 --- a/src/opengl/qgl_qws.cpp +++ /dev/null @@ -1,318 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgl.h" -#include "qgl_egl_p.h" -#include "qglpixelbuffer.h" - -#include <qglscreen_qws.h> -#include <qscreenproxy_qws.h> -#include <private/qglwindowsurface_qws_p.h> - -#include <private/qbackingstore_p.h> -#include <private/qfont_p.h> -#include <private/qfontengine_p.h> -#include <private/qgl_p.h> -#include <private/qpaintengine_opengl_p.h> -#include <qpixmap.h> -#include <qtimer.h> -#include <qapplication.h> -#include <qstack.h> -#include <qdesktopwidget.h> -#include <qdebug.h> -#include <qvarlengtharray.h> - -QT_BEGIN_NAMESPACE - -static QGLScreen *glScreenForDevice(QPaintDevice *device) -{ - QScreen *screen = qt_screen; - if (screen->classId() == QScreen::MultiClass) { - int screenNumber; - if (device && device->devType() == QInternal::Widget) - screenNumber = qApp->desktop()->screenNumber(static_cast<QWidget *>(device)); - else - screenNumber = 0; - screen = screen->subScreens()[screenNumber]; - } - while (screen->classId() == QScreen::ProxyClass || - screen->classId() == QScreen::TransformedClass) { - screen = static_cast<QProxyScreen *>(screen)->screen(); - } - if (screen->classId() == QScreen::GLClass) - return static_cast<QGLScreen *>(screen); - else - return 0; -} - -/* - QGLTemporaryContext implementation -*/ - -class QGLTemporaryContextPrivate -{ -public: - QGLWidget *widget; -}; - -QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) - : d(new QGLTemporaryContextPrivate) -{ - d->widget = new QGLWidget; - d->widget->makeCurrent(); -} - -QGLTemporaryContext::~QGLTemporaryContext() -{ - delete d->widget; -} - -/***************************************************************************** - QOpenGL debug facilities - *****************************************************************************/ -//#define DEBUG_OPENGL_REGION_UPDATE - -bool QGLFormat::hasOpenGLOverlays() -{ - QGLScreen *glScreen = glScreenForDevice(0); - if (glScreen) - return (glScreen->options() & QGLScreen::Overlays); - else - return false; -} - -static EGLSurface qt_egl_create_surface - (QEglContext *context, QPaintDevice *device, - const QEglProperties *properties = 0) -{ - // Get the screen surface functions, which are used to create native ids. - QGLScreen *glScreen = glScreenForDevice(device); - if (!glScreen) - return EGL_NO_SURFACE; - QGLScreenSurfaceFunctions *funcs = glScreen->surfaceFunctions(); - if (!funcs) - return EGL_NO_SURFACE; - - // Create the native drawable for the paint device. - int devType = device->devType(); - EGLNativePixmapType pixmapDrawable = 0; - EGLNativeWindowType windowDrawable = 0; - bool ok; - if (devType == QInternal::Pixmap) { - ok = funcs->createNativePixmap(static_cast<QPixmap *>(device), &pixmapDrawable); - } else if (devType == QInternal::Image) { - ok = funcs->createNativeImage(static_cast<QImage *>(device), &pixmapDrawable); - } else { - ok = funcs->createNativeWindow(static_cast<QWidget *>(device), &windowDrawable); - } - if (!ok) { - qWarning("QEglContext::createSurface(): Cannot create the native EGL drawable"); - return EGL_NO_SURFACE; - } - - // Create the EGL surface to draw into, based on the native drawable. - const int *props; - if (properties) - props = properties->properties(); - else - props = 0; - EGLSurface surf; - if (devType == QInternal::Widget) { - surf = eglCreateWindowSurface - (context->display(), context->config(), windowDrawable, props); - } else { - surf = eglCreatePixmapSurface - (context->display(), context->config(), pixmapDrawable, props); - } - if (surf == EGL_NO_SURFACE) - qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError()); - return surf; -} - -bool QGLContext::chooseContext(const QGLContext* shareContext) -{ - Q_D(QGLContext); - - // Validate the device. - if (!device()) - return false; - int devType = device()->devType(); - if (devType != QInternal::Pixmap && devType != QInternal::Image && devType != QInternal::Widget) { - qWarning("QGLContext::chooseContext(): Cannot create QGLContext's for paint device type %d", devType); - return false; - } - - // Get the display and initialize it. - d->eglContext = new QEglContext(); - d->ownsEglContext = true; - d->eglContext->setApi(QEgl::OpenGL); - - // Construct the configuration we need for this surface. - QEglProperties configProps; - qt_eglproperties_set_glformat(configProps, d->glFormat); - configProps.setDeviceType(devType); - configProps.setPaintDeviceFormat(device()); - configProps.setRenderableType(QEgl::OpenGL); - - // Search for a matching configuration, reducing the complexity - // each time until we get something that matches. - if (!d->eglContext->chooseConfig(configProps)) { - delete d->eglContext; - d->eglContext = 0; - return false; - } - - // Inform the higher layers about the actual format properties. - qt_glformat_from_eglconfig(d->glFormat, d->eglContext->config()); - - // Create a new context for the configuration. - if (!d->eglContext->createContext - (shareContext ? shareContext->d_func()->eglContext : 0)) { - delete d->eglContext; - d->eglContext = 0; - return false; - } - d->sharing = d->eglContext->isSharing(); - if (d->sharing && shareContext) - const_cast<QGLContext *>(shareContext)->d_func()->sharing = true; - -#if defined(EGL_VERSION_1_1) - if (d->glFormat.swapInterval() != -1 && devType == QInternal::Widget) - eglSwapInterval(d->eglContext->display(), d->glFormat.swapInterval()); -#endif - - // Create the EGL surface to draw into. We cannot use - // QEglContext::createSurface() because it does not have - // access to the QGLScreen. - d->eglSurface = qt_egl_create_surface(d->eglContext, device()); - if (d->eglSurface == EGL_NO_SURFACE) { - delete d->eglContext; - d->eglContext = 0; - return false; - } - - return true; -} - - -bool QGLWidget::event(QEvent *e) -{ - return QWidget::event(e); -} - - -void QGLWidget::resizeEvent(QResizeEvent *) -{ - Q_D(QGLWidget); - if (!isValid()) - return; - makeCurrent(); - if (!d->glcx->initialized()) - glInit(); - resizeGL(width(), height()); - //handle overlay -} - -const QGLContext* QGLWidget::overlayContext() const -{ - return 0; -} - -void QGLWidget::makeOverlayCurrent() -{ - //handle overlay -} - -void QGLWidget::updateOverlayGL() -{ - //handle overlay -} - -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(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) -{ - Q_Q(QGLWidget); - - QGLScreen *glScreen = glScreenForDevice(q); - if (glScreen) { - wsurf = static_cast<QWSGLWindowSurface*>(glScreen->createSurface(q)); - q->setWindowSurface(wsurf); - } - - initContext(context, shareWidget); - - if(q->isValid() && glcx->format().hasOverlay()) { - //no overlay - qWarning("QtOpenGL ES doesn't currently support overlays"); - } -} - -void QGLWidgetPrivate::cleanupColormaps() -{ -} - -const QGLColormap & QGLWidget::colormap() const -{ - return d_func()->cmap; -} - -void QGLWidget::setColormap(const QGLColormap &) -{ -} - -QT_END_NAMESPACE diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h index c5390645e2..32ae85dc90 100644 --- a/src/opengl/qglpaintdevice_p.h +++ b/src/opengl/qglpaintdevice_p.h @@ -55,7 +55,7 @@ #include <qpaintdevice.h> -#include <qgl.h> +#include <QtOpenGL/qgl.h> QT_BEGIN_NAMESPACE diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp index 7546d84064..c1318ffa47 100644 --- a/src/opengl/qglpixmapfilter.cpp +++ b/src/opengl/qglpixmapfilter.cpp @@ -46,7 +46,6 @@ #include "private/qpixmapdata_p.h" #include "private/qimagepixmapcleanuphooks_p.h" #include "qglpixmapfilter_p.h" -#include "qgraphicssystem_gl_p.h" #include "qpaintengine_opengl_p.h" #include "qcache.h" diff --git a/src/opengl/qglscreen_qws.cpp b/src/opengl/qglscreen_qws.cpp deleted file mode 100644 index 517813e628..0000000000 --- a/src/opengl/qglscreen_qws.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QGLScreen> -#include <QGLContext> -#include <QGLWidget> -#include "private/qglwindowsurface_qws_p.h" - -QT_BEGIN_NAMESPACE - -class QGLScreenPrivate -{ -public: - QGLScreen::Options options; - QGLScreenSurfaceFunctions *functions; -}; - -/*! - \internal - \preliminary - \class QGLScreen - - \brief This class encapsulates an OpenGL screen driver. -*/ - -QGLScreen::QGLScreen(int displayId) - : QScreen(displayId, GLClass), d_ptr(new QGLScreenPrivate) -{ - d_ptr->options = NoOptions; - d_ptr->functions = new QGLScreenSurfaceFunctions(); -} - -QGLScreen::~QGLScreen() -{ - delete d_ptr->functions; - delete d_ptr; -} - -/*! - \since 4.3 - \obsolete - - Initializes the \a context and sets up the QGLWindowSurface of the - QWidget of \a context based on the parameters of \a context and - based on its own requirements. The format() of \a context needs - to be updated with the actual parameters of the OpenGLES drawable - that was set up. - - \a shareContext is used in the same way as for QGLContext. It is - the context with which \a context shares display lists and texture - ids etc. The window surface must be set up so that this sharing - works. - - Returns true in case of success and false if it is not possible to - create the necessary OpenGLES drawable/context. - - Since 4.4.2, this function will be not be called if options() - indicates that a native window or pixmap drawable can be created - via the functions in the surfaceFunctions() object. - - This function is obsolete in Qt 4.5 and higher. Use surfaceFunctions() - instead. - - \sa options(), surfaceFunctions() -*/ -bool -QGLScreen::chooseContext(QGLContext *context, const QGLContext *shareContext) -{ - Q_UNUSED(context); - Q_UNUSED(shareContext); - return false; -} - -/*! - \enum QGLScreen::Option - This enum defines options that can be set on QGLScreen instances. - - \value NoOptions There are no special options on the screen. This is the default. - \value NativeWindows Native windows can be created with QGLScreenSurfaceFunctions::createNativeWindow(). - \value NativePixmaps Native pixmaps can be created with QGLScreenSurfaceFunctions::createNativePixmap(). - \value NativeImages Native images can be created with QGLScreenSurfaceFunctions::createNativeImage(). - \value Overlays The screen supports GL overlays. -*/ - -/*! - \since 4.4.2 - - Returns the options associated with this QGLScreen. - - \sa setOptions() -*/ -QGLScreen::Options QGLScreen::options() const -{ - return d_ptr->options; -} - -/*! - \since 4.4.2 - - Sets the options associated with this QGLScreen to \a value. - - \sa options() -*/ -void QGLScreen::setOptions(QGLScreen::Options value) -{ - d_ptr->options = value; -} - -/*! - \since 4.4.2 - - Returns the surface functions object for this QGLScreen. - - \sa setSurfaceFunctions() -*/ -QGLScreenSurfaceFunctions *QGLScreen::surfaceFunctions() const -{ - return d_ptr->functions; -} - -/*! - \since 4.4.2 - - Sets the surface functions object for this QGLScreen to \a functions. - The QGLScreen will take over ownership of \a functions and delete - it when the QGLScreen is deleted. - - \sa setSurfaceFunctions() -*/ -void QGLScreen::setSurfaceFunctions(QGLScreenSurfaceFunctions *functions) -{ - if (functions && functions != d_ptr->functions) { - delete d_ptr->functions; - d_ptr->functions = functions; - } -} - -/*! - \internal - \preliminary - \class QGLScreenSurfaceFunctions - \brief The QGLScreenSurfaceFunctions class encapsulates the functions for creating native windows and pixmaps for OpenGL ES. -*/ - -/*! - \since 4.4.2 - - Creates a native OpenGLES drawable for the surface of \a widget and - returns it in \a native. Returns true if the OpenGLES drawable could - be created, or false if windows are not supported. - - This function will be called if the NativeWindows option is set on - the screen. - - \sa createNativePixmap(), createNativeImage(), QGLScreen::options() -*/ -bool QGLScreenSurfaceFunctions::createNativeWindow(QWidget *widget, EGLNativeWindowType *native) -{ - Q_UNUSED(widget); - Q_UNUSED(native); - return false; -} - -/*! - \since 4.4.2 - - Creates a native OpenGLES drawable for directly rendering into - \a pixmap and returns it in \a native. Returns true if the OpenGLES - drawable could be created, or false if direct rendering into pixmaps - is not supported. - - This function will be called if the NativePixmaps option is set on - the screen. - - \sa createNativeWindow(), createNativeImage(), QGLScreen::options() -*/ -bool QGLScreenSurfaceFunctions::createNativePixmap(QPixmap *pixmap, EGLNativePixmapType *native) -{ - Q_UNUSED(pixmap); - Q_UNUSED(native); - return false; -} - -/*! - \since 4.4.2 - - Creates a native OpenGLES drawable for directly rendering into - \a image and returns it in \a native. Returns true if the OpenGLES - drawable could be created, or false if direct rendering into images - is not supported. - - This function will be called if the NativeImages option is set on - the screen. - - \sa createNativeWindow(), createNativePixmap(), QGLScreen::options() -*/ -bool QGLScreenSurfaceFunctions::createNativeImage(QImage *image, EGLNativePixmapType *native) -{ - Q_UNUSED(image); - Q_UNUSED(native); - return false; -} - -QT_END_NAMESPACE diff --git a/src/opengl/qglscreen_qws.h b/src/opengl/qglscreen_qws.h deleted file mode 100644 index a033b6badb..0000000000 --- a/src/opengl/qglscreen_qws.h +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSCREENEGL_P_H -#define QSCREENEGL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of the QScreenEGL class. This header file may change from -// version to version without notice, or even be removed. -// -// We mean it. -// - -#include <QtGui/QScreen> -#include <QtOpenGL/qgl.h> -#if defined(QT_OPENGL_ES_2) -#include <EGL/egl.h> -#else -#include <GLES/egl.h> -#endif -#if !defined(EGL_VERSION_1_3) && !defined(QEGL_NATIVE_TYPES_DEFINED) -#undef EGLNativeWindowType -#undef EGLNativePixmapType -#undef EGLNativeDisplayType -typedef NativeWindowType EGLNativeWindowType; -typedef NativePixmapType EGLNativePixmapType; -typedef NativeDisplayType EGLNativeDisplayType; -#define QEGL_NATIVE_TYPES_DEFINED 1 -#endif - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(OpenGL) - -class QGLScreenPrivate; - -class Q_OPENGL_EXPORT QGLScreenSurfaceFunctions -{ -public: - virtual bool createNativeWindow(QWidget *widget, EGLNativeWindowType *native); - virtual bool createNativePixmap(QPixmap *pixmap, EGLNativePixmapType *native); - virtual bool createNativeImage(QImage *image, EGLNativePixmapType *native); -}; - -class Q_OPENGL_EXPORT QGLScreen : public QScreen -{ - Q_DECLARE_PRIVATE(QGLScreen) -public: - QGLScreen(int displayId); - virtual ~QGLScreen(); - - enum Option - { - NoOptions = 0, - NativeWindows = 1, - NativePixmaps = 2, - NativeImages = 4, - Overlays = 8 - }; - Q_DECLARE_FLAGS(Options, Option) - - QGLScreen::Options options() const; - - virtual bool chooseContext(QGLContext *context, const QGLContext *shareContext); - virtual bool hasOpenGL() = 0; - - QGLScreenSurfaceFunctions *surfaceFunctions() const; - -protected: - void setOptions(QGLScreen::Options value); - void setSurfaceFunctions(QGLScreenSurfaceFunctions *functions); - -private: - QGLScreenPrivate *d_ptr; -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QGLScreen::Options) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QSCREENEGL_P_H diff --git a/src/opengl/qglwindowsurface_qws.cpp b/src/opengl/qglwindowsurface_qws.cpp deleted file mode 100644 index b3ad45185e..0000000000 --- a/src/opengl/qglwindowsurface_qws.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtGui/QPaintDevice> -#include <QtGui/QWidget> -#include <QtOpenGL/QGLWidget> -#include "private/qglwindowsurface_qws_p.h" -#include "private/qpaintengine_opengl_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QWSGLWindowSurface - \since 4.3 - \ingroup qws - \preliminary - - \brief The QWSGLWindowSurface class provides the drawing area for top-level - windows with Qt for Embedded Linux on EGL/OpenGL ES. It also provides the - drawing area for \l{QGLWidget}s whether they are top-level windows or - children of another QWidget. - - Note that this class is only available in Qt for Embedded Linux and only - available if Qt is configured with OpenGL support. -*/ - -class QWSGLWindowSurfacePrivate -{ -public: - QWSGLWindowSurfacePrivate() : - qglContext(0), ownsContext(false) {} - - QGLContext *qglContext; - bool ownsContext; -}; - -/*! - Constructs an empty QWSGLWindowSurface for the given top-level \a window. - The window surface is later initialized from chooseContext() and resources for it - is typically allocated in setGeometry(). -*/ -QWSGLWindowSurface::QWSGLWindowSurface(QWidget *window) - : QWSWindowSurface(window), - d_ptr(new QWSGLWindowSurfacePrivate) -{ -} - -/*! - Constructs an empty QWSGLWindowSurface. -*/ -QWSGLWindowSurface::QWSGLWindowSurface() - : d_ptr(new QWSGLWindowSurfacePrivate) -{ -} - -/*! - Destroys the QWSGLWindowSurface object and frees any - allocated resources. - */ -QWSGLWindowSurface::~QWSGLWindowSurface() -{ - Q_D(QWSGLWindowSurface); - if (d->ownsContext) - delete d->qglContext; - delete d; -} - -/*! - Returns the QGLContext of the window surface. -*/ -QGLContext *QWSGLWindowSurface::context() const -{ - Q_D(const QWSGLWindowSurface); - if (!d->qglContext) { - QWSGLWindowSurface *that = const_cast<QWSGLWindowSurface*>(this); - that->setContext(new QGLContext(QGLFormat::defaultFormat())); - that->d_func()->ownsContext = true; - } - return d->qglContext; -} - -/*! - Sets the QGLContext for this window surface to \a context. -*/ -void QWSGLWindowSurface::setContext(QGLContext *context) -{ - Q_D(QWSGLWindowSurface); - if (d->ownsContext) { - delete d->qglContext; - d->ownsContext = false; - } - d->qglContext = context; -} - -QT_END_NAMESPACE diff --git a/src/opengl/qglwindowsurface_qws_p.h b/src/opengl/qglwindowsurface_qws_p.h deleted file mode 100644 index 07362b1b88..0000000000 --- a/src/opengl/qglwindowsurface_qws_p.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLWINDOWSURFACE_QWS_P_H -#define QGLWINDOWSURFACE_QWS_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of the QWSGLWindowSurface class. This header file may change from -// version to version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/qglobal.h> -#include <QPaintDevice> -#include "private/qwindowsurface_qws_p.h" - -QT_BEGIN_NAMESPACE - -class QPaintDevice; -class QPoint; -class QRegion; -class QSize; -class QWidget; -class QGLContext; - -class QWSGLWindowSurfacePrivate; - -class Q_OPENGL_EXPORT QWSGLWindowSurface : public QWSWindowSurface -{ - Q_DECLARE_PRIVATE(QWSGLWindowSurface) - -public: - QWSGLWindowSurface(QWidget *widget); - QWSGLWindowSurface(); - ~QWSGLWindowSurface(); - - QGLContext *context() const; - void setContext(QGLContext *context); - -private: - QWSGLWindowSurfacePrivate *d_ptr; -}; - - -QT_END_NAMESPACE - -#endif // QGLWINDOWSURFACE_QWS_P_H diff --git a/src/opengl/qgraphicsshadereffect.cpp b/src/opengl/qgraphicsshadereffect.cpp index c7a058e9ef..8cca7eae1c 100644 --- a/src/opengl/qgraphicsshadereffect.cpp +++ b/src/opengl/qgraphicsshadereffect.cpp @@ -46,8 +46,8 @@ #define QGL_HAVE_CUSTOM_SHADERS 1 #endif #include <QtGui/qpainter.h> -#include <QtGui/qgraphicsitem.h> -#include <QtGui/private/qgraphicseffect_p.h> +#include <QtWidgets/qgraphicsitem.h> +#include <private/qgraphicseffect_p.h> QT_BEGIN_NAMESPACE diff --git a/src/opengl/qgraphicsshadereffect_p.h b/src/opengl/qgraphicsshadereffect_p.h index 12d716524b..7ae5f53d7e 100644 --- a/src/opengl/qgraphicsshadereffect_p.h +++ b/src/opengl/qgraphicsshadereffect_p.h @@ -53,7 +53,7 @@ // We mean it. // -#include <QtGui/qgraphicseffect.h> +#include <QtWidgets/qgraphicseffect.h> QT_BEGIN_HEADER diff --git a/src/opengl/qgraphicssystem_gl.cpp b/src/opengl/qgraphicssystem_gl.cpp deleted file mode 100644 index 01a2864ecc..0000000000 --- a/src/opengl/qgraphicssystem_gl.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgraphicssystem_gl_p.h" -#include <QGraphicsView> - -#include "private/qpixmap_raster_p.h" -#include "private/qpixmapdata_gl_p.h" -#include "private/qwindowsurface_gl_p.h" -#include "private/qgl_p.h" -#include <private/qwindowsurface_raster_p.h> - -#if defined(Q_WS_X11) && !defined(QT_NO_EGL) -#include "private/qpixmapdata_x11gl_p.h" -#include "private/qwindowsurface_x11gl_p.h" -#endif - -#if defined(Q_OS_SYMBIAN) -#include <QtGui/private/qapplication_p.h> -#endif - -#ifdef QGL_USE_TEXTURE_POOL -#include "private/qgltexturepool_p.h" -#endif - -QT_BEGIN_NAMESPACE - -extern QGLWidget *qt_gl_getShareWidget(); - -QPixmapData *QGLGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const -{ - return new QGLPixmapData(type); -} - -QWindowSurface *QGLGraphicsSystem::createWindowSurface(QWidget *widget) const -{ -#ifdef Q_WS_WIN - // On Windows the QGLWindowSurface class can't handle - // drop shadows and native effects, e.g. fading a menu in/out using - // top level window opacity. - if (widget->windowType() == Qt::Popup) - return new QRasterWindowSurface(widget); -#endif - -#if defined(Q_WS_X11) && !defined(QT_NO_EGL) - if (m_useX11GL && QX11GLPixmapData::hasX11GLPixmaps()) { - // If the widget is a QGraphicsView which will be re-drawing the entire - // scene each frame anyway, we should use QGLWindowSurface as this may - // provide proper buffer flipping, which should be faster than QX11GL's - // blitting approach: - QGraphicsView* qgv = qobject_cast<QGraphicsView*>(widget); - if (qgv && qgv->viewportUpdateMode() == QGraphicsView::FullViewportUpdate) - return new QGLWindowSurface(widget); - else - return new QX11GLWindowSurface(widget); - } -#endif - -#if defined(Q_OS_SYMBIAN) - if (!QApplicationPrivate::instance()->useTranslucentEGLSurfaces) { - QWidgetPrivate *d = qt_widget_private(widget); - if (!d->isOpaque && widget->testAttribute(Qt::WA_TranslucentBackground)) - return d->createDefaultWindowSurface_sys(); - } -#endif - - return new QGLWindowSurface(widget); -} -#ifdef QGL_USE_TEXTURE_POOL -void QGLGraphicsSystem::releaseCachedResources() -{ - QGLTexturePool::instance()->hibernate(); -} -#endif -QT_END_NAMESPACE - diff --git a/src/opengl/qgraphicssystem_gl_p.h b/src/opengl/qgraphicssystem_gl_p.h deleted file mode 100644 index 6e8e9a8966..0000000000 --- a/src/opengl/qgraphicssystem_gl_p.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSSYSTEM_RASTER_P_H -#define QGRAPHICSSYSTEM_RASTER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "private/qgraphicssystem_p.h" - -#include <QMap> - -QT_BEGIN_NAMESPACE - -class Q_OPENGL_EXPORT QGLGraphicsSystem : public QGraphicsSystem -{ -public: - QGLGraphicsSystem(bool useX11GL); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; - -#ifdef QGL_USE_TEXTURE_POOL - void releaseCachedResources(); -#endif -private: - bool m_useX11GL; -}; - -QT_END_NAMESPACE - -#endif - diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 31fe02c1b3..e05f312404 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -2361,8 +2361,8 @@ void QOpenGLPaintEngine::updateClipRegion(const QRegion &clipRegion, Qt::ClipOpe } else { #ifndef Q_WS_QWS // Only use the system clip if we're currently rendering a widget with a GL painter. - if (d->currentClipWidget) { - QWidgetPrivate *widgetPrivate = qt_widget_private(d->currentClipWidget->window()); + if (d->currentClipDevice) { + QWidgetPrivate *widgetPrivate = qt_widget_private(static_cast<QWidget *>(d->currentClipDevice)->window()); d->use_system_clip = widgetPrivate->extra && widgetPrivate->extra->inRenderWithPainter; } #endif diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index ff551427ec..d3e7e5178e 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -39,11 +39,11 @@ ** ****************************************************************************/ -#include <QtGui/QApplication> +#include <QtWidgets/QApplication> #include <QtGui/QColormap> -#include <QtGui/QDesktopWidget> +#include <QtWidgets/QDesktopWidget> #include <QtGui/QPaintDevice> -#include <QtGui/QWidget> +#include <QtWidgets/QWidget> #include <qglframebufferobject.h> #include <qglpixelbuffer.h> @@ -68,7 +68,6 @@ #include <private/qgl_p.h> #include <private/qglpixelbuffer_p.h> -#include <private/qgraphicssystem_gl_p.h> #include <private/qpaintengineex_opengl2_p.h> #include <private/qpixmapdata_gl_p.h> @@ -86,97 +85,11 @@ #include <private/qeglcontext_p.h> #endif -QT_BEGIN_NAMESPACE - -// -// QGLGraphicsSystem -// -#ifdef Q_WS_WIN -extern Q_GUI_EXPORT bool qt_win_owndc_required; +#ifdef Q_WS_QPA +#include <qplatformscreen_qpa.h> #endif -QGLGraphicsSystem::QGLGraphicsSystem(bool useX11GL) - : QGraphicsSystem(), m_useX11GL(useX11GL) -{ -#if defined(Q_WS_X11) && !defined(QT_OPENGL_ES) - // only override the system defaults if the user hasn't already - // picked a visual - if (X11->visual == 0 && X11->visual_id == -1 && X11->visual_class == -1) { - // find a double buffered, RGBA visual that supports OpenGL - // and set that as the default visual for windows in Qt - int i = 0; - int spec[16]; - spec[i++] = GLX_RGBA; - spec[i++] = GLX_DOUBLEBUFFER; - - if (!qgetenv("QT_GL_SWAPBUFFER_PRESERVE").isNull()) { - spec[i++] = GLX_DEPTH_SIZE; - spec[i++] = 8; - spec[i++] = GLX_STENCIL_SIZE; - spec[i++] = 8; - spec[i++] = GLX_SAMPLE_BUFFERS_ARB; - spec[i++] = 1; - spec[i++] = GLX_SAMPLES_ARB; - spec[i++] = 4; - } - - spec[i++] = XNone; - - XVisualInfo *vi = glXChooseVisual(X11->display, X11->defaultScreen, spec); - if (vi) { - X11->visual_id = vi->visualid; - X11->visual_class = vi->c_class; - - QGLFormat format; - int res; - glXGetConfig(X11->display, vi, GLX_LEVEL, &res); - format.setPlane(res); - glXGetConfig(X11->display, vi, GLX_DOUBLEBUFFER, &res); - format.setDoubleBuffer(res); - glXGetConfig(X11->display, vi, GLX_DEPTH_SIZE, &res); - format.setDepth(res); - if (format.depth()) - format.setDepthBufferSize(res); - glXGetConfig(X11->display, vi, GLX_RGBA, &res); - format.setRgba(res); - glXGetConfig(X11->display, vi, GLX_RED_SIZE, &res); - format.setRedBufferSize(res); - glXGetConfig(X11->display, vi, GLX_GREEN_SIZE, &res); - format.setGreenBufferSize(res); - glXGetConfig(X11->display, vi, GLX_BLUE_SIZE, &res); - format.setBlueBufferSize(res); - glXGetConfig(X11->display, vi, GLX_ALPHA_SIZE, &res); - format.setAlpha(res); - if (format.alpha()) - format.setAlphaBufferSize(res); - glXGetConfig(X11->display, vi, GLX_ACCUM_RED_SIZE, &res); - format.setAccum(res); - if (format.accum()) - format.setAccumBufferSize(res); - glXGetConfig(X11->display, vi, GLX_STENCIL_SIZE, &res); - format.setStencil(res); - if (format.stencil()) - format.setStencilBufferSize(res); - glXGetConfig(X11->display, vi, GLX_STEREO, &res); - format.setStereo(res); - glXGetConfig(X11->display, vi, GLX_SAMPLE_BUFFERS_ARB, &res); - format.setSampleBuffers(res); - if (format.sampleBuffers()) { - glXGetConfig(X11->display, vi, GLX_SAMPLES_ARB, &res); - format.setSamples(res); - } - - QGLWindowSurface::surfaceFormat = format; - XFree(vi); - - printf("using visual class %x, id %x\n", X11->visual_class, X11->visual_id); - } - } -#elif defined(Q_WS_WIN) - QGLWindowSurface::surfaceFormat.setDoubleBuffer(true); - qt_win_owndc_required = true; -#endif -} +QT_BEGIN_NAMESPACE // // QGLWindowSurface @@ -359,7 +272,31 @@ QGLContext* QGLWindowSurfaceGLPaintDevice::context() const int QGLWindowSurfaceGLPaintDevice::metric(PaintDeviceMetric m) const { - return qt_paint_device_metric(d->q_ptr->window(), m); + QWindow *window = d->q_ptr->window(); + QPlatformScreen *screen = QPlatformScreen::platformScreenForWindow(window); + if (!screen) { + if (m == PdmDpiX || m == PdmDpiY) + return 72; + } + int val; + if (m == PdmWidth) { + val = window->geometry().width(); + } else if (m == PdmWidthMM) { + val = window->geometry().width() * screen->physicalSize().width() / screen->geometry().width(); + } else if (m == PdmHeight) { + val = window->geometry().height(); + } else if (m == PdmHeightMM) { + val = window->geometry().height() * screen->physicalSize().height() / screen->geometry().height(); + } else if (m == PdmDepth) { + val = screen->depth(); + } else if (m == PdmDpiX || m == PdmPhysicalDpiX) { + val = qRound(screen->geometry().width() / double(screen->physicalSize().width() / 25.4)); + } else if (m == PdmDpiY || m == PdmPhysicalDpiY) { + val = qRound(screen->geometry().height() / double(screen->physicalSize().height() / 25.4)); + } else { + val = 1 << qMax(24, screen->depth()); + } + return val; } QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const @@ -367,7 +304,7 @@ QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const return qt_qgl_paint_engine(); } -QGLWindowSurface::QGLWindowSurface(QWidget *window) +QGLWindowSurface::QGLWindowSurface(QWindow *window) : QWindowSurface(window), d_ptr(new QGLWindowSurfacePrivate) { // Q_ASSERT(window->isTopLevel()); @@ -428,6 +365,7 @@ QGLWindowSurface::~QGLWindowSurface() void QGLWindowSurface::deleted(QObject *object) { +#if 0 QWidget *widget = qobject_cast<QWidget *>(object); if (widget) { if (widget == window()) { @@ -450,10 +388,12 @@ void QGLWindowSurface::deleted(QObject *object) } #endif } +#endif } -void QGLWindowSurface::hijackWindow(QWidget *widget) +void QGLWindowSurface::hijackWindow(QWindow *window) { +#if 0 QWidgetPrivate *widgetPrivate = widget->d_func(); widgetPrivate->createExtra(); if (widgetPrivate->extraData()->glContext) @@ -511,6 +451,7 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) #ifndef Q_OS_SYMBIAN qDebug() << "hijackWindow() context created for" << widget << d_ptr->contexts.size(); #endif +#endif } QGLContext *QGLWindowSurface::context() const @@ -528,8 +469,10 @@ QPaintDevice *QGLWindowSurface::paintDevice() if (d_ptr->ctx) return &d_ptr->glDevice; +#if 0 QGLContext *ctx = reinterpret_cast<QGLContext *>(window()->d_func()->extraData()->glContext); ctx->makeCurrent(); +#endif Q_ASSERT(d_ptr->fbo); return d_ptr->fbo; @@ -544,7 +487,10 @@ void QGLWindowSurface::beginPaint(const QRegion &) int clearFlags = 0; +#if 0 QGLContext *ctx = reinterpret_cast<QGLContext *>(window()->d_func()->extraData()->glContext); +#endif + const QGLContext *ctx = QGLContext::currentContext(); if (!ctx) return; @@ -608,8 +554,9 @@ static void blitTexture(QGLContext *ctx, GLuint texture, const QSize &viewport, } -void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &offset) +void QGLWindowSurface::flush(QWindow *window, const QRegion &rgn, const QPoint &offset) { +#if 0 //### Find out why d_ptr->geometry_updated isn't always false. // flush() should not be called when d_ptr->geometry_updated is true. It assumes that either // d_ptr->fbo or d_ptr->pb is allocated and has the correct size. @@ -872,7 +819,7 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & ctx->swapBuffers(); else glFlush(); - +#endif d_ptr->did_paint = false; } @@ -892,6 +839,7 @@ void QGLWindowSurface::resize(const QSize &size) #endif void QGLWindowSurface::updateGeometry() { +#if 0 if (!d_ptr->geometry_updated) return; d_ptr->geometry_updated = false; @@ -1026,6 +974,7 @@ void QGLWindowSurface::updateGeometry() { #endif d_ptr->ctx = ctx; d_ptr->ctx->d_ptr->internal_context = true; +#endif } bool QGLWindowSurface::initializeOffscreenTexture(const QSize &size) @@ -1047,6 +996,7 @@ bool QGLWindowSurface::initializeOffscreenTexture(const QSize &size) bool QGLWindowSurface::scroll(const QRegion &area, int dx, int dy) { +#if 0 // this code randomly fails currently for unknown reasons return false; @@ -1075,7 +1025,7 @@ bool QGLWindowSurface::scroll(const QRegion &area, int dx, int dy) glBindTexture(target, 0); drawTexture(br.translated(dx, dy), d_ptr->tex_id, window()->size()); - +#endif return true; } @@ -1140,26 +1090,6 @@ static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize, #endif } -QImage *QGLWindowSurface::buffer(const QWidget *widget) -{ - QImage image; - - if (d_ptr->pb) - image = d_ptr->pb->toImage(); - else if (d_ptr->fbo) - image = d_ptr->fbo->toImage(); - - if (image.isNull()) - return 0; - - QRect rect = widget->rect(); - rect.translate(widget->mapTo(widget->window(), QPoint())); - - QImage subImage = image.copy(rect); - d_ptr->buffers << subImage; - return &d_ptr->buffers.last(); -} - QWindowSurface::WindowSurfaceFeatures QGLWindowSurface::features() const { WindowSurfaceFeatures features = 0; diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h index 91d1f9e245..c7b0d10efa 100644 --- a/src/opengl/qwindowsurface_gl_p.h +++ b/src/opengl/qwindowsurface_gl_p.h @@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE class QPaintDevice; class QPoint; class QRegion; -class QWidget; +class QWindow; struct QGLWindowSurfacePrivate; Q_OPENGL_EXPORT QGLWidget* qt_gl_share_widget(); @@ -84,11 +84,11 @@ class Q_OPENGL_EXPORT QGLWindowSurface : public QObject, public QWindowSurface / { Q_OBJECT public: - QGLWindowSurface(QWidget *window); + QGLWindowSurface(QWindow *window); ~QGLWindowSurface(); QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void flush(QWindow *window, const QRegion ®ion, const QPoint &offset); #if !defined(Q_WS_QPA) void setGeometry(const QRect &rect); @@ -102,8 +102,6 @@ public: void beginPaint(const QRegion ®ion); void endPaint(const QRegion ®ion); - QImage *buffer(const QWidget *widget); - WindowSurfaceFeatures features() const; QGLContext *context() const; @@ -117,7 +115,7 @@ private slots: void deleted(QObject *object); private: - void hijackWindow(QWidget *widget); + void hijackWindow(QWindow *window); bool initializeOffscreenTexture(const QSize &size); QGLWindowSurfacePrivate *d_ptr; |