summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2010-07-09 14:04:46 (GMT)
committerJørgen Lind <jorgen.lind@nokia.com>2010-07-09 14:04:46 (GMT)
commite7054204ff74bde531d293de5b360587724f6857 (patch)
treed334bfe4000ce606eb6e732923c915edfb7c3a07 /src/gui/kernel
parentc7590d9f255e1efd3dc528e1052f997f4f477009 (diff)
downloadQt-e7054204ff74bde531d293de5b360587724f6857.zip
Qt-e7054204ff74bde531d293de5b360587724f6857.tar.gz
Qt-e7054204ff74bde531d293de5b360587724f6857.tar.bz2
Added QPlatformWindowFormat
Its mostly a copy of QGLFormat Only plugin that uses it is the openkode, and thats just a poc.
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/kernel.pri6
-rw-r--r--src/gui/kernel/qplatformwindow_qpa.cpp41
-rw-r--r--src/gui/kernel/qplatformwindow_qpa.h2
-rw-r--r--src/gui/kernel/qplatformwindowformat_qpa.cpp1283
-rw-r--r--src/gui/kernel/qplatformwindowformat_qpa.h256
-rw-r--r--src/gui/kernel/qwidget.cpp37
-rw-r--r--src/gui/kernel/qwidget.h8
-rw-r--r--src/gui/kernel/qwidget_p.h1
-rw-r--r--src/gui/kernel/qwidget_qpa.cpp52
9 files changed, 1649 insertions, 37 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index f773906..e9b8f25 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -214,9 +214,10 @@ qpa {
kernel/qplatformintegrationfactory_qpa_p.h \
kernel/qplatformintegrationplugin_qpa.h \
kernel/qplatformwindow_qpa.h \
+ kernel/qplatformwindowformat_qpa.h \
kernel/qplatformglcontext_qpa.h \
kernel/qdesktopwidget_qpa_p.h
-
+
SOURCES += \
kernel/qapplication_qpa.cpp \
kernel/qclipboard_qpa.cpp \
@@ -233,7 +234,8 @@ qpa {
kernel/qplatformscreen_qpa.cpp \
kernel/qplatformintegrationfactory_qpa.cpp \
kernel/qplatformintegrationplugin_qpa.cpp \
- kernel/qplatformwindow_qpa.cpp
+ kernel/qplatformwindow_qpa.cpp \
+ kernel/qplatformwindowformat_qpa.cpp
contains(QT_CONFIG, glib) {
SOURCES += \
diff --git a/src/gui/kernel/qplatformwindow_qpa.cpp b/src/gui/kernel/qplatformwindow_qpa.cpp
index c0e642c..4cd8ead 100644
--- a/src/gui/kernel/qplatformwindow_qpa.cpp
+++ b/src/gui/kernel/qplatformwindow_qpa.cpp
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** 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 QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
#include "qplatformwindow_qpa.h"
#include <QtGui/qwidget.h>
diff --git a/src/gui/kernel/qplatformwindow_qpa.h b/src/gui/kernel/qplatformwindow_qpa.h
index 5f8d259..e8b5ad8 100644
--- a/src/gui/kernel/qplatformwindow_qpa.h
+++ b/src/gui/kernel/qplatformwindow_qpa.h
@@ -82,6 +82,8 @@ public:
virtual QPlatformGLContext *glContext();
protected:
QScopedPointer<QPlatformWindowPrivate> d_ptr;
+private:
+ Q_DISABLE_COPY(QPlatformWindow);
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformwindowformat_qpa.cpp b/src/gui/kernel/qplatformwindowformat_qpa.cpp
new file mode 100644
index 0000000..4ded26b
--- /dev/null
+++ b/src/gui/kernel/qplatformwindowformat_qpa.cpp
@@ -0,0 +1,1283 @@
+/****************************************************************************
+**
+** 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 QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformwindowformat_qpa.h"
+
+Q_GLOBAL_STATIC(QPlatformWindowFormat, q_platformwindow_default_format);
+
+class QPlatformWindowFormatPrivate
+{
+public:
+ QPlatformWindowFormatPrivate()
+ : ref(1)
+ , opts(QPlatformWindowFormat::DoubleBuffer | QPlatformWindowFormat::DepthBuffer
+ | QPlatformWindowFormat::Rgba | QPlatformWindowFormat::DirectRendering
+ | QPlatformWindowFormat::StencilBuffer | QPlatformWindowFormat::DeprecatedFunctions)
+ , depthSize(-1)
+ , accumSize(-1)
+ , stencilSize(-1)
+ , redSize(-1)
+ , greenSize(-1)
+ , blueSize(-1)
+ , alphaSize(-1)
+ , numSamples(-1)
+ , swapInterval(-1)
+ , majorVersion(1)
+ , minorVersion(0)
+ , profile(QPlatformWindowFormat::NoProfile)
+ {
+ }
+
+ QPlatformWindowFormatPrivate(const QPlatformWindowFormatPrivate *other)
+ : ref(1),
+ opts(other->opts),
+ depthSize(other->depthSize),
+ accumSize(other->accumSize),
+ stencilSize(other->stencilSize),
+ redSize(other->redSize),
+ greenSize(other->greenSize),
+ blueSize(other->blueSize),
+ alphaSize(other->alphaSize),
+ numSamples(other->numSamples),
+ swapInterval(other->swapInterval),
+ majorVersion(other->majorVersion),
+ minorVersion(other->minorVersion),
+ profile(other->profile)
+ {
+ }
+ QAtomicInt ref;
+ QPlatformWindowFormat::FormatOptions opts;
+ int depthSize;
+ int accumSize;
+ int stencilSize;
+ int redSize;
+ int greenSize;
+ int blueSize;
+ int alphaSize;
+ int numSamples;
+ int swapInterval;
+ int majorVersion;
+ int minorVersion;
+ QPlatformWindowFormat::OpenGLContextProfile profile;
+};
+
+/*!
+ \class QGLFormat
+ \brief The QGLFormat class specifies the display format of an OpenGL
+ rendering context.
+
+ \ingroup painting-3D
+
+ A display format has several characteristics:
+ \list
+ \i \link setDoubleBuffer() Double or single buffering.\endlink
+ \i \link setDepth() Depth buffer.\endlink
+ \i \link setRgba() RGBA or color index mode.\endlink
+ \i \link setAlpha() Alpha channel.\endlink
+ \i \link setAccum() Accumulation buffer.\endlink
+ \i \link setStencil() Stencil buffer.\endlink
+ \i \link setStereo() Stereo buffers.\endlink
+ \i \link setDirectRendering() Direct rendering.\endlink
+ \i \link setOverlay() Presence of an overlay.\endlink
+ \i \link setPlane() Plane of an overlay.\endlink
+ \i \link setSampleBuffers() Multisample buffers.\endlink
+ \endlist
+
+ You can also specify preferred bit depths for the color buffer,
+ depth buffer, alpha buffer, accumulation buffer and the stencil
+ buffer with the functions: setRedBufferSize(), setGreenBufferSize(),
+ setBlueBufferSize(), setDepthBufferSize(), setAlphaBufferSize(),
+ setAccumBufferSize() and setStencilBufferSize().
+
+ Note that even if you specify that you prefer a 32 bit depth
+ buffer (e.g. with setDepthBufferSize(32)), the format that is
+ chosen may not have a 32 bit depth buffer, even if there is a
+ format available with a 32 bit depth buffer. The main reason for
+ this is how the system dependant picking algorithms work on the
+ different platforms, and some format options may have higher
+ precedence than others.
+
+ You create and tell a QGLFormat object what rendering options you
+ want from an OpenGL rendering context.
+
+ OpenGL drivers or accelerated hardware may or may not support
+ advanced features such as alpha channel or stereographic viewing.
+ If you request some features that the driver/hardware does not
+ provide when you create a QGLWidget, you will get a rendering
+ context with the nearest subset of features.
+
+ There are different ways to define the display characteristics of
+ a rendering context. One is to create a QGLFormat and make it the
+ default for the entire application:
+ \snippet doc/src/snippets/code/src_opengl_qgl.cpp 0
+
+ Or you can specify the desired format when creating an object of
+ your QGLWidget subclass:
+ \snippet doc/src/snippets/code/src_opengl_qgl.cpp 1
+
+ After the widget has been created, you can find out which of the
+ requested features the system was able to provide:
+ \snippet doc/src/snippets/code/src_opengl_qgl.cpp 2
+
+ \legalese
+ OpenGL is a trademark of Silicon Graphics, Inc. in the
+ United States and other countries.
+ \endlegalese
+
+ \sa QGLContext, QGLWidget
+*/
+
+/*!
+ Constructs a QGLFormat object with the following default settings:
+ \list
+ \i \link setDoubleBuffer() Double buffer:\endlink Enabled.
+ \i \link setDepth() Depth buffer:\endlink Enabled.
+ \i \link setRgba() RGBA:\endlink Enabled (i.e., color index disabled).
+ \i \link setAlpha() Alpha channel:\endlink Disabled.
+ \i \link setAccum() Accumulator buffer:\endlink Disabled.
+ \i \link setStencil() Stencil buffer:\endlink Enabled.
+ \i \link setStereo() Stereo:\endlink Disabled.
+ \i \link setDirectRendering() Direct rendering:\endlink Enabled.
+ \i \link setOverlay() Overlay:\endlink Disabled.
+ \i \link setPlane() Plane:\endlink 0 (i.e., normal plane).
+ \i \link setSampleBuffers() Multisample buffers:\endlink Disabled.
+ \endlist
+*/
+
+QPlatformWindowFormat::QPlatformWindowFormat()
+{
+ d = new QPlatformWindowFormatPrivate;
+}
+
+
+/*!
+ Creates a QGLFormat object that is a copy of the current
+ defaultFormat().
+
+ If \a options is not 0, the default format is modified by the
+ specified format options. The \a options parameter should be
+ QGL::FormatOption values OR'ed together.
+
+ This constructor makes it easy to specify a certain desired format
+ in classes derived from QGLWidget, for example:
+ \snippet doc/src/snippets/code/src_opengl_qgl.cpp 3
+
+ Note that there are QGL::FormatOption values to turn format settings
+ both on and off, e.g. QGL::DepthBuffer and QGL::NoDepthBuffer,
+ QGL::DirectRendering and QGL::IndirectRendering, etc.
+
+ The \a plane parameter defaults to 0 and is the plane which this
+ format should be associated with. Not all OpenGL implementations
+ supports overlay/underlay rendering planes.
+
+ \sa defaultFormat(), setOption(), setPlane()
+*/
+
+QPlatformWindowFormat::QPlatformWindowFormat(QPlatformWindowFormat::FormatOptions options)
+{
+ d = new QPlatformWindowFormatPrivate;
+ QPlatformWindowFormat::FormatOptions newOpts = options;
+ d->opts = defaultFormat().d->opts;
+ d->opts |= (newOpts & 0xffff);
+ d->opts &= ~(newOpts >> 16);
+}
+
+/*!
+ \internal
+*/
+void QPlatformWindowFormat::detach()
+{
+ if (d->ref != 1) {
+ QPlatformWindowFormatPrivate *newd = new QPlatformWindowFormatPrivate(d);
+ if (!d->ref.deref())
+ delete d;
+ d = newd;
+ }
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+
+QPlatformWindowFormat::QPlatformWindowFormat(const QPlatformWindowFormat &other)
+{
+ d = other.d;
+ d->ref.ref();
+}
+
+/*!
+ Assigns \a other to this object.
+*/
+
+QPlatformWindowFormat &QPlatformWindowFormat::operator=(const QPlatformWindowFormat &other)
+{
+ if (d != other.d) {
+ other.d->ref.ref();
+ if (!d->ref.deref())
+ delete d;
+ d = other.d;
+ }
+ return *this;
+}
+
+/*!
+ Destroys the QGLFormat.
+*/
+QPlatformWindowFormat::~QPlatformWindowFormat()
+{
+ if (!d->ref.deref())
+ delete d;
+}
+
+/*!
+ \fn bool QGLFormat::doubleBuffer() const
+
+ Returns true if double buffering is enabled; otherwise returns
+ false. Double buffering is enabled by default.
+
+ \sa setDoubleBuffer()
+*/
+
+/*!
+ If \a enable is true sets double buffering; otherwise sets single
+ buffering.
+
+ Double buffering is enabled by default.
+
+ Double buffering is a technique where graphics are rendered on an
+ off-screen buffer and not directly to the screen. When the drawing
+ has been completed, the program calls a swapBuffers() function to
+ exchange the screen contents with the buffer. The result is
+ flicker-free drawing and often better performance.
+
+ \sa doubleBuffer(), QGLContext::swapBuffers(),
+ QGLWidget::swapBuffers()
+*/
+
+void QPlatformWindowFormat::setDoubleBuffer(bool enable)
+{
+ setOption(enable ? QPlatformWindowFormat::DoubleBuffer : QPlatformWindowFormat::SingleBuffer);
+}
+
+
+/*!
+ \fn bool QGLFormat::depth() const
+
+ Returns true if the depth buffer is enabled; otherwise returns
+ false. The depth buffer is enabled by default.
+
+ \sa setDepth(), setDepthBufferSize()
+*/
+
+/*!
+ If \a enable is true enables the depth buffer; otherwise disables
+ the depth buffer.
+
+ The depth buffer is enabled by default.
+
+ The purpose of a depth buffer (or Z-buffering) is to remove hidden
+ surfaces. Pixels are assigned Z values based on the distance to
+ the viewer. A pixel with a high Z value is closer to the viewer
+ than a pixel with a low Z value. This information is used to
+ decide whether to draw a pixel or not.
+
+ \sa depth(), setDepthBufferSize()
+*/
+
+void QPlatformWindowFormat::setDepth(bool enable)
+{
+ setOption(enable ? QPlatformWindowFormat::DepthBuffer : QPlatformWindowFormat::NoDepthBuffer);
+}
+
+
+/*!
+ \fn bool QGLFormat::rgba() const
+
+ Returns true if RGBA color mode is set. Returns false if color
+ index mode is set. The default color mode is RGBA.
+
+ \sa setRgba()
+*/
+
+/*!
+ If \a enable is true sets RGBA mode. If \a enable is false sets
+ color index mode.
+
+ The default color mode is RGBA.
+
+ RGBA is the preferred mode for most OpenGL applications. In RGBA
+ color mode you specify colors as red + green + blue + alpha
+ quadruplets.
+
+ In color index mode you specify an index into a color lookup
+ table.
+
+ \sa rgba()
+*/
+
+void QPlatformWindowFormat::setRgba(bool enable)
+{
+ setOption(enable ? QPlatformWindowFormat::Rgba : QPlatformWindowFormat::ColorIndex);
+}
+
+
+/*!
+ \fn bool QGLFormat::alpha() const
+
+ Returns true if the alpha buffer in the framebuffer is enabled;
+ otherwise returns false. The alpha buffer is disabled by default.
+
+ \sa setAlpha(), setAlphaBufferSize()
+*/
+
+/*!
+ If \a enable is true enables the alpha buffer; otherwise disables
+ the alpha buffer.
+
+ The alpha buffer is disabled by default.
+
+ The alpha buffer is typically used for implementing transparency
+ or translucency. The A in RGBA specifies the transparency of a
+ pixel.
+
+ \sa alpha(), setAlphaBufferSize()
+*/
+
+void QPlatformWindowFormat::setAlpha(bool enable)
+{
+ setOption(enable ? QPlatformWindowFormat::AlphaChannel : QPlatformWindowFormat::NoAlphaChannel);
+}
+
+
+/*!
+ \fn bool QGLFormat::accum() const
+
+ Returns true if the accumulation buffer is enabled; otherwise
+ returns false. The accumulation buffer is disabled by default.
+
+ \sa setAccum(), setAccumBufferSize()
+*/
+
+/*!
+ If \a enable is true enables the accumulation buffer; otherwise
+ disables the accumulation buffer.
+
+ The accumulation buffer is disabled by default.
+
+ The accumulation buffer is used to create blur effects and
+ multiple exposures.
+
+ \sa accum(), setAccumBufferSize()
+*/
+
+void QPlatformWindowFormat::setAccum(bool enable)
+{
+ setOption(enable ? QPlatformWindowFormat::AccumBuffer : QPlatformWindowFormat::NoAccumBuffer);
+}
+
+
+/*!
+ \fn bool QGLFormat::stencil() const
+
+ Returns true if the stencil buffer is enabled; otherwise returns
+ false. The stencil buffer is enabled by default.
+
+ \sa setStencil(), setStencilBufferSize()
+*/
+
+/*!
+ If \a enable is true enables the stencil buffer; otherwise
+ disables the stencil buffer.
+
+ The stencil buffer is enabled by default.
+
+ The stencil buffer masks certain parts of the drawing area so that
+ masked parts are not drawn on.
+
+ \sa stencil(), setStencilBufferSize()
+*/
+
+void QPlatformWindowFormat::setStencil(bool enable)
+{
+ setOption(enable ? QPlatformWindowFormat::StencilBuffer: QPlatformWindowFormat::NoStencilBuffer);
+}
+
+
+/*!
+ \fn bool QGLFormat::stereo() const
+
+ Returns true if stereo buffering is enabled; otherwise returns
+ false. Stereo buffering is disabled by default.
+
+ \sa setStereo()
+*/
+
+/*!
+ If \a enable is true enables stereo buffering; otherwise disables
+ stereo buffering.
+
+ Stereo buffering is disabled by default.
+
+ Stereo buffering provides extra color buffers to generate left-eye
+ and right-eye images.
+
+ \sa stereo()
+*/
+
+void QPlatformWindowFormat::setStereo(bool enable)
+{
+ setOption(enable ? QPlatformWindowFormat::StereoBuffers : QPlatformWindowFormat::NoStereoBuffers);
+}
+
+
+/*!
+ \fn bool QGLFormat::directRendering() const
+
+ Returns true if direct rendering is enabled; otherwise returns
+ false.
+
+ Direct rendering is enabled by default.
+
+ \sa setDirectRendering()
+*/
+
+/*!
+ If \a enable is true enables direct rendering; otherwise disables
+ direct rendering.
+
+ Direct rendering is enabled by default.
+
+ Enabling this option will make OpenGL bypass the underlying window
+ system and render directly from hardware to the screen, if this is
+ supported by the system.
+
+ \sa directRendering()
+*/
+
+void QPlatformWindowFormat::setDirectRendering(bool enable)
+{
+ setOption(enable ? QPlatformWindowFormat::DirectRendering : QPlatformWindowFormat::IndirectRendering);
+}
+
+/*!
+ \fn bool QGLFormat::sampleBuffers() const
+
+ Returns true if multisample buffer support is enabled; otherwise
+ returns false.
+
+ The multisample buffer is disabled by default.
+
+ \sa setSampleBuffers()
+*/
+
+/*!
+ If \a enable is true, a GL context with multisample buffer support
+ is picked; otherwise ignored.
+
+ \sa sampleBuffers(), setSamples(), samples()
+*/
+void QPlatformWindowFormat::setSampleBuffers(bool enable)
+{
+ setOption(enable ? QPlatformWindowFormat::SampleBuffers : QPlatformWindowFormat::NoSampleBuffers);
+}
+
+/*!
+ Returns the number of samples per pixel when multisampling is
+ enabled. By default, the highest number of samples that is
+ available is used.
+
+ \sa setSampleBuffers(), sampleBuffers(), setSamples()
+*/
+int QPlatformWindowFormat::samples() const
+{
+ return d->numSamples;
+}
+
+/*!
+ Set the preferred number of samples per pixel when multisampling
+ is enabled to \a numSamples. By default, the highest number of
+ samples available is used.
+
+ \sa setSampleBuffers(), sampleBuffers(), samples()
+*/
+void QPlatformWindowFormat::setSamples(int numSamples)
+{
+ detach();
+ if (numSamples < 0) {
+ qWarning("QGLFormat::setSamples: Cannot have negative number of samples per pixel %d", numSamples);
+ return;
+ }
+ d->numSamples = numSamples;
+ setSampleBuffers(numSamples > 0);
+}
+
+/*!
+ \since 4.2
+
+ Set the preferred swap interval. This can be used to sync the GL
+ drawing into a system window to the vertical refresh of the screen.
+ Setting an \a interval value of 0 will turn the vertical refresh syncing
+ off, any value higher than 0 will turn the vertical syncing on.
+
+ Under Windows and under X11, where the \c{WGL_EXT_swap_control}
+ and \c{GLX_SGI_video_sync} extensions are used, the \a interval
+ parameter can be used to set the minimum number of video frames
+ that are displayed before a buffer swap will occur. In effect,
+ setting the \a interval to 10, means there will be 10 vertical
+ retraces between every buffer swap.
+
+ Under Windows the \c{WGL_EXT_swap_control} extension has to be present,
+ and under X11 the \c{GLX_SGI_video_sync} extension has to be present.
+*/
+void QPlatformWindowFormat::setSwapInterval(int interval)
+{
+ detach();
+ d->swapInterval = interval;
+}
+
+/*!
+ \since 4.2
+
+ Returns the currently set swap interval. -1 is returned if setting
+ the swap interval isn't supported in the system GL implementation.
+*/
+int QPlatformWindowFormat::swapInterval() const
+{
+ return d->swapInterval;
+}
+
+///*!
+// \fn bool QGLFormat::hasOverlay() const
+
+// Returns true if overlay plane is enabled; otherwise returns false.
+
+// Overlay is disabled by default.
+
+// \sa setOverlay()
+//*/
+
+///*!
+// If \a enable is true enables an overlay plane; otherwise disables
+// the overlay plane.
+
+// Enabling the overlay plane will cause QGLWidget to create an
+// additional context in an overlay plane. See the QGLWidget
+// documentation for further information.
+
+// \sa hasOverlay()
+//*/
+
+//void QPlatformWindowFormat::setOverlay(bool enable)
+//{
+// setOption(enable ? QPlatformWindowFormat::HasOverlay : QPlatformWindowFormat::NoOverlay);
+//}
+
+/*!
+ Sets the format option to \a opt.
+
+ \sa testOption()
+*/
+
+void QPlatformWindowFormat::setOption(QPlatformWindowFormat::FormatOptions opt)
+{
+ detach();
+ if (opt & 0xffff)
+ d->opts |= opt;
+ else
+ d->opts &= ~(opt >> 16);
+}
+
+
+
+/*!
+ Returns true if format option \a opt is set; otherwise returns false.
+
+ \sa setOption()
+*/
+
+bool QPlatformWindowFormat::testOption(QPlatformWindowFormat::FormatOptions opt) const
+{
+ if (opt & 0xffff)
+ return (d->opts & opt) != 0;
+ else
+ return (d->opts & (opt >> 16)) == 0;
+}
+
+/*!
+ Set the minimum depth buffer size to \a size.
+
+ \sa depthBufferSize(), setDepth(), depth()
+*/
+void QPlatformWindowFormat::setDepthBufferSize(int size)
+{
+ detach();
+ if (size < 0) {
+ qWarning("QGLFormat::setDepthBufferSize: Cannot set negative depth buffer size %d", size);
+ return;
+ }
+ d->depthSize = size;
+ setDepth(size > 0);
+}
+
+/*!
+ Returns the depth buffer size.
+
+ \sa depth(), setDepth(), setDepthBufferSize()
+*/
+int QPlatformWindowFormat::depthBufferSize() const
+{
+ return d->depthSize;
+}
+
+/*!
+ \since 4.2
+
+ Set the preferred red buffer size to \a size.
+
+ \sa setGreenBufferSize(), setBlueBufferSize(), setAlphaBufferSize()
+*/
+void QPlatformWindowFormat::setRedBufferSize(int size)
+{
+ detach();
+ if (size < 0) {
+ qWarning("QGLFormat::setRedBufferSize: Cannot set negative red buffer size %d", size);
+ return;
+ }
+ d->redSize = size;
+}
+
+/*!
+ \since 4.2
+
+ Returns the red buffer size.
+
+ \sa setRedBufferSize()
+*/
+int QPlatformWindowFormat::redBufferSize() const
+{
+ return d->redSize;
+}
+
+/*!
+ \since 4.2
+
+ Set the preferred green buffer size to \a size.
+
+ \sa setRedBufferSize(), setBlueBufferSize(), setAlphaBufferSize()
+*/
+void QPlatformWindowFormat::setGreenBufferSize(int size)
+{
+ detach();
+ if (size < 0) {
+ qWarning("QGLFormat::setGreenBufferSize: Cannot set negative green buffer size %d", size);
+ return;
+ }
+ d->greenSize = size;
+}
+
+/*!
+ \since 4.2
+
+ Returns the green buffer size.
+
+ \sa setGreenBufferSize()
+*/
+int QPlatformWindowFormat::greenBufferSize() const
+{
+ return d->greenSize;
+}
+
+/*!
+ \since 4.2
+
+ Set the preferred blue buffer size to \a size.
+
+ \sa setRedBufferSize(), setGreenBufferSize(), setAlphaBufferSize()
+*/
+void QPlatformWindowFormat::setBlueBufferSize(int size)
+{
+ detach();
+ if (size < 0) {
+ qWarning("QGLFormat::setBlueBufferSize: Cannot set negative blue buffer size %d", size);
+ return;
+ }
+ d->blueSize = size;
+}
+
+/*!
+ \since 4.2
+
+ Returns the blue buffer size.
+
+ \sa setBlueBufferSize()
+*/
+int QPlatformWindowFormat::blueBufferSize() const
+{
+ return d->blueSize;
+}
+
+/*!
+ Set the preferred alpha buffer size to \a size.
+ This function implicitly enables the alpha channel.
+
+ \sa setRedBufferSize(), setGreenBufferSize(), alphaBufferSize()
+*/
+void QPlatformWindowFormat::setAlphaBufferSize(int size)
+{
+ detach();
+ if (size < 0) {
+ qWarning("QGLFormat::setAlphaBufferSize: Cannot set negative alpha buffer size %d", size);
+ return;
+ }
+ d->alphaSize = size;
+ setAlpha(size > 0);
+}
+
+/*!
+ Returns the alpha buffer size.
+
+ \sa alpha(), setAlpha(), setAlphaBufferSize()
+*/
+int QPlatformWindowFormat::alphaBufferSize() const
+{
+ return d->alphaSize;
+}
+
+/*!
+ Set the preferred accumulation buffer size, where \a size is the
+ bit depth for each RGBA component.
+
+ \sa accum(), setAccum(), accumBufferSize()
+*/
+void QPlatformWindowFormat::setAccumBufferSize(int size)
+{
+ detach();
+ if (size < 0) {
+ qWarning("QGLFormat::setAccumBufferSize: Cannot set negative accumulate buffer size %d", size);
+ return;
+ }
+ d->accumSize = size;
+ setAccum(size > 0);
+}
+
+/*!
+ Returns the accumulation buffer size.
+
+ \sa setAccumBufferSize(), accum(), setAccum()
+*/
+int QPlatformWindowFormat::accumBufferSize() const
+{
+ return d->accumSize;
+}
+
+/*!
+ Set the preferred stencil buffer size to \a size.
+
+ \sa stencilBufferSize(), setStencil(), stencil()
+*/
+void QPlatformWindowFormat::setStencilBufferSize(int size)
+{
+ detach();
+ if (size < 0) {
+ qWarning("QGLFormat::setStencilBufferSize: Cannot set negative stencil buffer size %d", size);
+ return;
+ }
+ d->stencilSize = size;
+ setStencil(size > 0);
+}
+
+/*!
+ Returns the stencil buffer size.
+
+ \sa stencil(), setStencil(), setStencilBufferSize()
+*/
+int QPlatformWindowFormat::stencilBufferSize() const
+{
+ return d->stencilSize;
+}
+
+/*!
+ \since 4.7
+
+ Set the OpenGL version to the \a major and \a minor numbers. If a
+ context compatible with the requested OpenGL version cannot be
+ created, a context compatible with version 1.x is created instead.
+
+ \sa majorVersion(), minorVersion()
+*/
+void QPlatformWindowFormat::setVersion(int major, int minor)
+{
+ if (major < 1 || minor < 0) {
+ qWarning("QGLFormat::setVersion: Cannot set zero or negative version number %d.%d", major, minor);
+ return;
+ }
+ detach();
+ d->majorVersion = major;
+ d->minorVersion = minor;
+}
+
+/*!
+ \since 4.7
+
+ Returns the OpenGL major version.
+
+ \sa setVersion(), minorVersion()
+*/
+int QPlatformWindowFormat::majorVersion() const
+{
+ return d->majorVersion;
+}
+
+/*!
+ \since 4.7
+
+ Returns the OpenGL minor version.
+
+ \sa setVersion(), majorVersion()
+*/
+int QPlatformWindowFormat::minorVersion() const
+{
+ return d->minorVersion;
+}
+
+/*!
+ \enum QGLFormat::OpenGLContextProfile
+ \since 4.7
+
+ This enum describes the OpenGL context profiles that can be
+ specified for contexts implementing OpenGL version 3.2 or
+ higher. These profiles are different from OpenGL ES profiles.
+
+ \value NoProfile OpenGL version is lower than 3.2.
+ \value CoreProfile Functionality deprecated in OpenGL version 3.0 is not available.
+ \value CompatibilityProfile Functionality from earlier OpenGL versions is available.
+*/
+
+/*!
+ \since 4.7
+
+ Set the OpenGL context profile to \a profile. The \a profile is
+ ignored if the requested OpenGL version is less than 3.2.
+
+ \sa profile()
+*/
+void QPlatformWindowFormat::setProfile(OpenGLContextProfile profile)
+{
+ detach();
+ d->profile = profile;
+}
+
+/*!
+ \since 4.7
+
+ Returns the OpenGL context profile.
+
+ \sa setProfile()
+*/
+QPlatformWindowFormat::OpenGLContextProfile QPlatformWindowFormat::profile() const
+{
+ return d->profile;
+}
+
+
+/*!
+ \fn bool QGLFormat::hasOpenGL()
+
+ Returns true if the window system has any OpenGL support;
+ otherwise returns false.
+
+ \warning This function must not be called until the QApplication
+ object has been created.
+*/
+
+
+
+/*!
+ \fn bool QGLFormat::hasOpenGLOverlays()
+
+ Returns true if the window system supports OpenGL overlays;
+ otherwise returns false.
+
+ \warning This function must not be called until the QApplication
+ object has been created.
+*/
+
+QPlatformWindowFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(const QString &versionString)
+{
+ QPlatformWindowFormat::OpenGLVersionFlags versionFlags = QPlatformWindowFormat::OpenGL_Version_None;
+
+ if (versionString.startsWith(QLatin1String("OpenGL ES"))) {
+ QStringList parts = versionString.split(QLatin1Char(' '));
+ if (parts.size() >= 3) {
+ if (parts[2].startsWith(QLatin1String("1."))) {
+ if (parts[1].endsWith(QLatin1String("-CM"))) {
+ versionFlags |= QPlatformWindowFormat::OpenGL_ES_Common_Version_1_0 |
+ QPlatformWindowFormat::OpenGL_ES_CommonLite_Version_1_0;
+ if (parts[2].startsWith(QLatin1String("1.1")))
+ versionFlags |= QPlatformWindowFormat::OpenGL_ES_Common_Version_1_1 |
+ QPlatformWindowFormat::OpenGL_ES_CommonLite_Version_1_1;
+ } else {
+ // Not -CM, must be CL, CommonLite
+ versionFlags |= QPlatformWindowFormat::OpenGL_ES_CommonLite_Version_1_0;
+ if (parts[2].startsWith(QLatin1String("1.1")))
+ versionFlags |= QPlatformWindowFormat::OpenGL_ES_CommonLite_Version_1_1;
+ }
+ } else {
+ // OpenGL ES version 2.0 or higher
+ versionFlags |= QPlatformWindowFormat::OpenGL_ES_Version_2_0;
+ }
+ } else {
+ // if < 3 parts to the name, it is an unrecognised OpenGL ES
+ qWarning("Unrecognised OpenGL ES version");
+ }
+ } else {
+ // not ES, regular OpenGL, the version numbers are first in the string
+ if (versionString.startsWith(QLatin1String("1."))) {
+ switch (versionString[2].toAscii()) {
+ case '5':
+ versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_5;
+ case '4':
+ versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_4;
+ case '3':
+ versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_3;
+ case '2':
+ versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_2;
+ case '1':
+ versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_1;
+ default:
+ break;
+ }
+ } else if (versionString.startsWith(QLatin1String("2."))) {
+ versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_1 |
+ QPlatformWindowFormat::OpenGL_Version_1_2 |
+ QPlatformWindowFormat::OpenGL_Version_1_3 |
+ QPlatformWindowFormat::OpenGL_Version_1_4 |
+ QPlatformWindowFormat::OpenGL_Version_1_5 |
+ QPlatformWindowFormat::OpenGL_Version_2_0;
+ if (versionString[2].toAscii() == '1')
+ versionFlags |= QPlatformWindowFormat::OpenGL_Version_2_1;
+ } else if (versionString.startsWith(QLatin1String("3."))) {
+ versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_1 |
+ QPlatformWindowFormat::OpenGL_Version_1_2 |
+ QPlatformWindowFormat::OpenGL_Version_1_3 |
+ QPlatformWindowFormat::OpenGL_Version_1_4 |
+ QPlatformWindowFormat::OpenGL_Version_1_5 |
+ QPlatformWindowFormat::OpenGL_Version_2_0 |
+ QPlatformWindowFormat::OpenGL_Version_2_1 |
+ QPlatformWindowFormat::OpenGL_Version_3_0;
+ switch (versionString[2].toAscii()) {
+ case '3':
+ versionFlags |= QPlatformWindowFormat::OpenGL_Version_3_3;
+ case '2':
+ versionFlags |= QPlatformWindowFormat::OpenGL_Version_3_2;
+ case '1':
+ versionFlags |= QPlatformWindowFormat::OpenGL_Version_3_1;
+ case '0':
+ break;
+ default:
+ versionFlags |= QPlatformWindowFormat::OpenGL_Version_3_1 |
+ QPlatformWindowFormat::OpenGL_Version_3_2 |
+ QPlatformWindowFormat::OpenGL_Version_3_3;
+ break;
+ }
+ } else if (versionString.startsWith(QLatin1String("4."))) {
+ versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_1 |
+ QPlatformWindowFormat::OpenGL_Version_1_2 |
+ QPlatformWindowFormat::OpenGL_Version_1_3 |
+ QPlatformWindowFormat::OpenGL_Version_1_4 |
+ QPlatformWindowFormat::OpenGL_Version_1_5 |
+ QPlatformWindowFormat::OpenGL_Version_2_0 |
+ QPlatformWindowFormat::OpenGL_Version_2_1 |
+ QPlatformWindowFormat::OpenGL_Version_3_0 |
+ QPlatformWindowFormat::OpenGL_Version_3_1 |
+ QPlatformWindowFormat::OpenGL_Version_3_2 |
+ QPlatformWindowFormat::OpenGL_Version_3_3 |
+ QPlatformWindowFormat::OpenGL_Version_4_0;
+ } else {
+ versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_1 |
+ QPlatformWindowFormat::OpenGL_Version_1_2 |
+ QPlatformWindowFormat::OpenGL_Version_1_3 |
+ QPlatformWindowFormat::OpenGL_Version_1_4 |
+ QPlatformWindowFormat::OpenGL_Version_1_5 |
+ QPlatformWindowFormat::OpenGL_Version_2_0 |
+ QPlatformWindowFormat::OpenGL_Version_2_1 |
+ QPlatformWindowFormat::OpenGL_Version_3_0 |
+ QPlatformWindowFormat::OpenGL_Version_3_1 |
+ QPlatformWindowFormat::OpenGL_Version_3_2 |
+ QPlatformWindowFormat::OpenGL_Version_3_3 |
+ QPlatformWindowFormat::OpenGL_Version_4_0;
+ }
+ }
+ return versionFlags;
+}
+
+/*!
+ \enum QGLFormat::OpenGLVersionFlag
+ \since 4.2
+
+ This enum describes the various OpenGL versions that are
+ recognized by Qt. Use the QGLFormat::openGLVersionFlags() function
+ to identify which versions that are supported at runtime.
+
+ \value OpenGL_Version_None If no OpenGL is present or if no OpenGL context is current.
+
+ \value OpenGL_Version_1_1 OpenGL version 1.1 or higher is present.
+
+ \value OpenGL_Version_1_2 OpenGL version 1.2 or higher is present.
+
+ \value OpenGL_Version_1_3 OpenGL version 1.3 or higher is present.
+
+ \value OpenGL_Version_1_4 OpenGL version 1.4 or higher is present.
+
+ \value OpenGL_Version_1_5 OpenGL version 1.5 or higher is present.
+
+ \value OpenGL_Version_2_0 OpenGL version 2.0 or higher is present.
+ Note that version 2.0 supports all the functionality of version 1.5.
+
+ \value OpenGL_Version_2_1 OpenGL version 2.1 or higher is present.
+
+ \value OpenGL_Version_3_0 OpenGL version 3.0 or higher is present.
+
+ \value OpenGL_Version_3_1 OpenGL version 3.1 or higher is present.
+ Note that OpenGL version 3.1 or higher does not necessarily support all the features of
+ version 3.0 and lower.
+
+ \value OpenGL_Version_3_2 OpenGL version 3.2 or higher is present.
+
+ \value OpenGL_ES_CommonLite_Version_1_0 OpenGL ES version 1.0 Common Lite or higher is present.
+
+ \value OpenGL_ES_Common_Version_1_0 OpenGL ES version 1.0 Common or higher is present.
+ The Common profile supports all the features of Common Lite.
+
+ \value OpenGL_ES_CommonLite_Version_1_1 OpenGL ES version 1.1 Common Lite or higher is present.
+
+ \value OpenGL_ES_Common_Version_1_1 OpenGL ES version 1.1 Common or higher is present.
+ The Common profile supports all the features of Common Lite.
+
+ \value OpenGL_ES_Version_2_0 OpenGL ES version 2.0 or higher is present.
+ Note that OpenGL ES version 2.0 does not support all the features of OpenGL ES 1.x.
+ So if OpenGL_ES_Version_2_0 is returned, none of the ES 1.x flags are returned.
+
+ See also \l{http://www.opengl.org} for more information about the different
+ revisions of OpenGL.
+
+ \sa openGLVersionFlags()
+*/
+
+/*!
+ \since 4.2
+
+ Identifies, at runtime, which OpenGL versions that are supported
+ by the current platform.
+
+ Note that if OpenGL version 1.5 is supported, its predecessors
+ (i.e., version 1.4 and lower) are also supported. To identify the
+ support of a particular feature, like multi texturing, test for
+ the version in which the feature was first introduced (i.e.,
+ version 1.3 in the case of multi texturing) to adapt to the largest
+ possible group of runtime platforms.
+
+ This function needs a valid current OpenGL context to work;
+ otherwise it will return OpenGL_Version_None.
+
+ \sa hasOpenGL(), hasOpenGLOverlays()
+*/
+QPlatformWindowFormat::OpenGLVersionFlags QPlatformWindowFormat::openGLVersionFlags()
+{
+// static bool cachedDefault = false;
+ static OpenGLVersionFlags defaultVersionFlags = OpenGL_Version_None;
+// QGLContext *currentCtx = const_cast<QGLContext *>(QGLContext::currentContext());
+// QGLTemporaryContext *tmpContext = 0;
+
+// if (currentCtx && currentCtx->d_func()->version_flags_cached)
+// return currentCtx->d_func()->version_flags;
+
+// if (!currentCtx) {
+// if (cachedDefault) {
+// return defaultVersionFlags;
+// } else {
+// if (!hasOpenGL())
+// return defaultVersionFlags;
+// tmpContext = new QGLTemporaryContext;
+// cachedDefault = true;
+// }
+// }
+
+// QString versionString(QLatin1String(reinterpret_cast<const char*>(glGetString(GL_VERSION))));
+// OpenGLVersionFlags versionFlags = qOpenGLVersionFlagsFromString(versionString);
+// if (currentCtx) {
+// currentCtx->d_func()->version_flags_cached = true;
+// currentCtx->d_func()->version_flags = versionFlags;
+// }
+// if (tmpContext) {
+// defaultVersionFlags = versionFlags;
+// delete tmpContext;
+// }
+
+// return versionFlags;
+ return defaultVersionFlags;
+}
+
+
+/*!
+ Returns the default QGLFormat for the application. All QGLWidget
+ objects that are created use this format unless another format is
+ specified, e.g. when they are constructed.
+
+ If no special default format has been set using
+ setDefaultFormat(), the default format is the same as that created
+ with QGLFormat().
+
+ \sa setDefaultFormat()
+*/
+
+QPlatformWindowFormat QPlatformWindowFormat::defaultFormat()
+{
+ return *q_platformwindow_default_format();
+}
+
+/*!
+ Sets a new default QGLFormat for the application to \a f. For
+ example, to set single buffering as the default instead of double
+ buffering, your main() might contain code like this:
+ \snippet doc/src/snippets/code/src_opengl_qgl.cpp 4
+
+ \sa defaultFormat()
+*/
+
+void QPlatformWindowFormat::setDefaultFormat(const QPlatformWindowFormat &f)
+{
+ *q_platformwindow_default_format() = f;
+}
+
+
+/*!
+ Returns the default QGLFormat for overlay contexts.
+
+ The default overlay format is:
+ \list
+ \i \link setDoubleBuffer() Double buffer:\endlink Disabled.
+ \i \link setDepth() Depth buffer:\endlink Disabled.
+ \i \link setRgba() RGBA:\endlink Disabled (i.e., color index enabled).
+ \i \link setAlpha() Alpha channel:\endlink Disabled.
+ \i \link setAccum() Accumulator buffer:\endlink Disabled.
+ \i \link setStencil() Stencil buffer:\endlink Disabled.
+ \i \link setStereo() Stereo:\endlink Disabled.
+ \i \link setDirectRendering() Direct rendering:\endlink Enabled.
+ \i \link setOverlay() Overlay:\endlink Disabled.
+ \i \link setSampleBuffers() Multisample buffers:\endlink Disabled.
+ \i \link setPlane() Plane:\endlink 1 (i.e., first overlay plane).
+ \endlist
+
+ \sa setDefaultFormat()
+*/
+
+//QPlatformWindowFormat QPlatformWindowFormat::defaultOverlayFormat()
+//{
+// return *defaultOverlayFormatInstance();
+//}
+
+///*!
+// Sets a new default QGLFormat for overlay contexts to \a f. This
+// format is used whenever a QGLWidget is created with a format that
+// hasOverlay() enabled.
+
+// For example, to get a double buffered overlay context (if
+// available), use code like this:
+
+// \snippet doc/src/snippets/code/src_opengl_qgl.cpp 5
+
+// As usual, you can find out after widget creation whether the
+// underlying OpenGL system was able to provide the requested
+// specification:
+
+// \snippet doc/src/snippets/code/src_opengl_qgl.cpp 6
+
+// \sa defaultOverlayFormat()
+//*/
+
+//void QPlatformWindowFormat::setDefaultOverlayFormat(const QPlatformWindowFormat &f)
+//{
+// QPlatformWindowFormat *defaultFormat = defaultOverlayFormatInstance();
+// *defaultFormat = f;
+// // Make sure the user doesn't request that the overlays themselves
+// // have overlays, since it is unlikely that the system supports
+// // infinitely many planes...
+// defaultFormat->setOverlay(false);
+//}
+
+
+/*!
+ Returns true if all the options of the two QGLFormat objects
+ \a a and \a b are equal; otherwise returns false.
+
+ \relates QGLFormat
+*/
+
+bool operator==(const QPlatformWindowFormat& a, const QPlatformWindowFormat& b)
+{
+ return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts
+ && a.d->alphaSize == b.d->alphaSize
+ && a.d->accumSize == b.d->accumSize
+ && a.d->stencilSize == b.d->stencilSize
+ && a.d->depthSize == b.d->depthSize
+ && a.d->redSize == b.d->redSize
+ && a.d->greenSize == b.d->greenSize
+ && a.d->blueSize == b.d->blueSize
+ && a.d->numSamples == b.d->numSamples
+ && a.d->swapInterval == b.d->swapInterval
+ && a.d->majorVersion == b.d->majorVersion
+ && a.d->minorVersion == b.d->minorVersion
+ && a.d->profile == b.d->profile);
+}
+
+
+/*!
+ Returns false if all the options of the two QGLFormat objects
+ \a a and \a b are equal; otherwise returns true.
+
+ \relates QGLFormat
+*/
+
+bool operator!=(const QPlatformWindowFormat& a, const QPlatformWindowFormat& b)
+{
+ return !(a == b);
+}
diff --git a/src/gui/kernel/qplatformwindowformat_qpa.h b/src/gui/kernel/qplatformwindowformat_qpa.h
new file mode 100644
index 0000000..929ad7a
--- /dev/null
+++ b/src/gui/kernel/qplatformwindowformat_qpa.h
@@ -0,0 +1,256 @@
+/****************************************************************************
+**
+** 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 QtGui 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 QPLATFORMWINDOWFORMAT_QPA_H
+#define QPLATFORMWINDOWFORMAT_QPA_H
+
+#include <QPlatformWindow>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QPlatformWindowFormatPrivate;
+
+class Q_GUI_EXPORT QPlatformWindowFormat
+{
+public:
+ enum FormatOption {
+ DoubleBuffer = 0x0001,
+ DepthBuffer = 0x0002,
+ Rgba = 0x0004,
+ AlphaChannel = 0x0008,
+ AccumBuffer = 0x0010,
+ StencilBuffer = 0x0020,
+ StereoBuffers = 0x0040,
+ DirectRendering = 0x0080,
+ HasOverlay = 0x0100,
+ SampleBuffers = 0x0200,
+ DeprecatedFunctions = 0x0400,
+ SingleBuffer = DoubleBuffer << 16,
+ NoDepthBuffer = DepthBuffer << 16,
+ ColorIndex = Rgba << 16,
+ NoAlphaChannel = AlphaChannel << 16,
+ NoAccumBuffer = AccumBuffer << 16,
+ NoStencilBuffer = StencilBuffer << 16,
+ NoStereoBuffers = StereoBuffers << 16,
+ IndirectRendering = DirectRendering << 16,
+ NoOverlay = HasOverlay << 16,
+ NoSampleBuffers = SampleBuffers << 16,
+ NoDeprecatedFunctions = DeprecatedFunctions << 16
+ };
+ Q_DECLARE_FLAGS(FormatOptions, FormatOption)
+
+ enum OpenGLVersionFlag {
+ OpenGL_Version_None = 0x00000000,
+ OpenGL_Version_1_1 = 0x00000001,
+ OpenGL_Version_1_2 = 0x00000002,
+ OpenGL_Version_1_3 = 0x00000004,
+ OpenGL_Version_1_4 = 0x00000008,
+ OpenGL_Version_1_5 = 0x00000010,
+ OpenGL_Version_2_0 = 0x00000020,
+ OpenGL_Version_2_1 = 0x00000040,
+ OpenGL_ES_Common_Version_1_0 = 0x00000080,
+ OpenGL_ES_CommonLite_Version_1_0 = 0x00000100,
+ OpenGL_ES_Common_Version_1_1 = 0x00000200,
+ OpenGL_ES_CommonLite_Version_1_1 = 0x00000400,
+ OpenGL_ES_Version_2_0 = 0x00000800,
+ OpenGL_Version_3_0 = 0x00001000,
+ OpenGL_Version_3_1 = 0x00002000,
+ OpenGL_Version_3_2 = 0x00004000,
+ OpenGL_Version_3_3 = 0x00008000,
+ OpenGL_Version_4_0 = 0x00010000
+ };
+ Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag)
+
+ QPlatformWindowFormat();
+ QPlatformWindowFormat(FormatOptions options);
+ QPlatformWindowFormat(const QPlatformWindowFormat &other);
+ QPlatformWindowFormat &operator=(const QPlatformWindowFormat &other);
+ ~QPlatformWindowFormat();
+
+ void setDepthBufferSize(int size);
+ int depthBufferSize() const;
+
+ void setAccumBufferSize(int size);
+ int accumBufferSize() const;
+
+ void setRedBufferSize(int size);
+ int redBufferSize() const;
+
+ void setGreenBufferSize(int size);
+ int greenBufferSize() const;
+
+ void setBlueBufferSize(int size);
+ int blueBufferSize() const;
+
+ void setAlphaBufferSize(int size);
+ int alphaBufferSize() const;
+
+ void setStencilBufferSize(int size);
+ int stencilBufferSize() const;
+
+ void setSampleBuffers(bool enable);
+ bool sampleBuffers() const;
+
+ void setSamples(int numSamples);
+ int samples() const;
+
+ void setSwapInterval(int interval);
+ int swapInterval() const;
+
+ bool doubleBuffer() const;
+ void setDoubleBuffer(bool enable);
+ bool depth() const;
+ void setDepth(bool enable);
+ bool rgba() const;
+ void setRgba(bool enable);
+ bool alpha() const;
+ void setAlpha(bool enable);
+ bool accum() const;
+ void setAccum(bool enable);
+ bool stencil() const;
+ void setStencil(bool enable);
+ bool stereo() const;
+ void setStereo(bool enable);
+ bool directRendering() const;
+ void setDirectRendering(bool enable);
+// bool hasOverlay() const;
+// void setOverlay(bool enable);
+
+ void setOption(QPlatformWindowFormat::FormatOptions opt);
+ bool testOption(QPlatformWindowFormat::FormatOptions opt) const;
+
+ static QPlatformWindowFormat defaultFormat();
+ static void setDefaultFormat(const QPlatformWindowFormat& f);
+
+// static QPlatformWindowFormat defaultOverlayFormat();
+// static void setDefaultOverlayFormat(const QPlatformWindowFormat& f);
+
+ static bool hasOpenGL();
+ static bool hasOpenGLOverlays();
+
+ void setVersion(int major, int minor);
+ int majorVersion() const;
+ int minorVersion() const;
+
+ enum OpenGLContextProfile {
+ NoProfile,
+ CoreProfile,
+ CompatibilityProfile
+ };
+
+ void setProfile(OpenGLContextProfile profile);
+ OpenGLContextProfile profile() const;
+
+
+ static OpenGLVersionFlags openGLVersionFlags();
+
+private:
+ QPlatformWindowFormatPrivate *d;
+
+ void detach();
+
+ friend Q_GUI_EXPORT bool operator==(const QPlatformWindowFormat&, const QPlatformWindowFormat&);
+ friend Q_GUI_EXPORT bool operator!=(const QPlatformWindowFormat&, const QPlatformWindowFormat&);
+};
+
+Q_GUI_EXPORT bool operator==(const QPlatformWindowFormat&, const QPlatformWindowFormat&);
+Q_GUI_EXPORT bool operator!=(const QPlatformWindowFormat&, const QPlatformWindowFormat&);
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformWindowFormat::FormatOptions)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformWindowFormat::OpenGLVersionFlags)
+
+inline bool QPlatformWindowFormat::doubleBuffer() const
+{
+ return testOption(QPlatformWindowFormat::DoubleBuffer);
+}
+
+inline bool QPlatformWindowFormat::depth() const
+{
+ return testOption(QPlatformWindowFormat::DepthBuffer);
+}
+
+inline bool QPlatformWindowFormat::rgba() const
+{
+ return testOption(QPlatformWindowFormat::Rgba);
+}
+
+inline bool QPlatformWindowFormat::alpha() const
+{
+ return testOption(QPlatformWindowFormat::AlphaChannel);
+}
+
+inline bool QPlatformWindowFormat::accum() const
+{
+ return testOption(QPlatformWindowFormat::AccumBuffer);
+}
+
+inline bool QPlatformWindowFormat::stencil() const
+{
+ return testOption(QPlatformWindowFormat::StencilBuffer);
+}
+
+inline bool QPlatformWindowFormat::stereo() const
+{
+ return testOption(QPlatformWindowFormat::StereoBuffers);
+}
+
+inline bool QPlatformWindowFormat::directRendering() const
+{
+ return testOption(QPlatformWindowFormat::DirectRendering);
+}
+
+//inline bool QPlatformWindowFormat::hasOverlay() const
+//{
+// return testOption(QPlatformWindowFormat::HasOverlay);
+//}
+
+inline bool QPlatformWindowFormat::sampleBuffers() const
+{
+ return testOption(QPlatformWindowFormat::SampleBuffers);
+}
+
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif //QPLATFORMWINDOWFORMAT_QPA_H
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 53b35dd..943da79 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -1662,6 +1662,7 @@ void QWidgetPrivate::createTLExtra()
#endif
#if defined(Q_WS_QPA)
x->platformWindow = 0;
+ x->platformWindowFormat = QPlatformWindowFormat::defaultFormat();
#endif
}
}
@@ -2455,6 +2456,7 @@ void QWidgetPrivate::createWinId(WId winid)
q->create();
}
#else
+ Q_UNUSED(winid);
q->create();
#endif //Q_WS_QPA
@@ -11937,41 +11939,6 @@ QWindowSurface *QWidget::windowSurface() const
return bs ? bs->windowSurface : 0;
}
-#if defined(Q_WS_QPA)
-/*!
- \preliminary
-
- Sets the window to be the \a window specified.
- The QWidget takes ownership of the \a surface.
-*/
-void QWidget::setPlatformWindow(QPlatformWindow *window)
-{
- Q_D(QWidget);
-
- QTLWExtra *topData = d->topData();
- if (topData->platformWindow == window)
- return;
-
- delete topData->platformWindow;
- topData->platformWindow = window;
-}
-
-/*!
- \preliminary
-
- Returns the QPlatformWindow this widget will be drawn into.
-*/
-QPlatformWindow *QWidget::platformWindow() const
-{
- Q_D(const QWidget);
- QTLWExtra *extra = d->maybeTopData();
- if (extra && extra->platformWindow)
- return extra->platformWindow;
-
- return 0;
-}
-#endif //defined(Q_WS_QPA)
-
void QWidgetPrivate::getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const
{
if (left)
diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h
index 8e08ce5..c750465 100644
--- a/src/gui/kernel/qwidget.h
+++ b/src/gui/kernel/qwidget.h
@@ -56,6 +56,10 @@
#include <QtGui/qcursor.h>
#include <QtGui/qkeysequence.h>
+#ifdef Q_WS_QPA //should this go somewhere else?
+#include <QtGui/qplatformwindowformat_qpa.h>
+#endif
+
#ifdef QT_INCLUDE_COMPAT
#include <QtGui/qevent.h>
#endif
@@ -631,6 +635,10 @@ public:
#if defined(Q_WS_QPA)
void setPlatformWindow(QPlatformWindow *window);
QPlatformWindow *platformWindow() const;
+
+ void setPlatformWindowFormat(const QPlatformWindowFormat &format);
+ QPlatformWindowFormat platformWindowFormat() const;
+
friend class QDesktopScreenWidget;
#endif
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index 5274c3b..3903124 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -229,6 +229,7 @@ struct QTLWExtra {
uint inExpose : 1; // Prevents drawing recursion
#elif defined(Q_WS_QPA)
QPlatformWindow *platformWindow;
+ QPlatformWindowFormat platformWindowFormat;
#endif
};
diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp
index 1acf398..4229a05 100644
--- a/src/gui/kernel/qwidget_qpa.cpp
+++ b/src/gui/kernel/qwidget_qpa.cpp
@@ -691,6 +691,58 @@ int QWidget::metric(PaintDeviceMetric m) const
return val;
}
+/*!
+ \preliminary
+
+ Sets the window to be the \a window specified.
+ The QWidget takes ownership of the \a surface.
+*/
+void QWidget::setPlatformWindow(QPlatformWindow *window)
+{
+ Q_D(QWidget);
+
+ QTLWExtra *topData = d->topData();
+ if (topData->platformWindow == window)
+ return;
+
+ delete topData->platformWindow;
+ topData->platformWindow = window;
+}
+
+/*!
+ \preliminary
+
+ Returns the QPlatformWindow this widget will be drawn into.
+*/
+QPlatformWindow *QWidget::platformWindow() const
+{
+ Q_D(const QWidget);
+ QTLWExtra *extra = d->maybeTopData();
+ if (extra && extra->platformWindow)
+ return extra->platformWindow;
+
+ return 0;
+}
+
+void QWidget::setPlatformWindowFormat(const QPlatformWindowFormat &format)
+{
+ Q_D(QWidget);
+ QTLWExtra *topData = d->topData();
+ topData->platformWindowFormat = format;
+}
+
+QPlatformWindowFormat QWidget::platformWindowFormat() const
+{
+ Q_D(const QWidget);
+
+ QTLWExtra *extra = d->maybeTopData();
+ if (extra){
+ return extra->platformWindowFormat;
+ } else {
+ return QPlatformWindowFormat::defaultFormat();
+ }
+}
+
void QWidgetPrivate::createSysExtra()
{
}