summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/kernel.pri4
-rw-r--r--src/gui/kernel/qoffscreensurface.cpp345
-rw-r--r--src/gui/kernel/qoffscreensurface.h98
-rw-r--r--src/gui/kernel/qplatformintegration.cpp11
-rw-r--r--src/gui/kernel/qplatformintegration.h4
-rw-r--r--src/gui/kernel/qplatformoffscreensurface.cpp93
-rw-r--r--src/gui/kernel/qplatformoffscreensurface.h85
-rw-r--r--src/gui/kernel/qplatformsurface.h1
-rw-r--r--src/gui/kernel/qsurface.cpp1
-rw-r--r--src/gui/kernel/qsurface.h3
10 files changed, 644 insertions, 1 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index f766b5fbaf..eb87a8c31b 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -24,6 +24,7 @@ HEADERS += \
kernel/qplatformthemefactory_p.h \
kernel/qplatformthemeplugin.h \
kernel/qplatformwindow.h \
+ kernel/qplatformoffscreensurface.h \
kernel/qplatformwindow_p.h \
kernel/qplatformcursor.h \
kernel/qplatformclipboard.h \
@@ -34,6 +35,7 @@ HEADERS += \
kernel/qguiapplication_p.h \
kernel/qwindow_p.h \
kernel/qwindow.h \
+ kernel/qoffscreensurface.h \
kernel/qplatformsurface.h \
kernel/qsurface.h \
kernel/qclipboard.h \
@@ -81,6 +83,7 @@ SOURCES += \
kernel/qplatformthemefactory.cpp \
kernel/qplatformthemeplugin.cpp \
kernel/qplatformwindow.cpp \
+ kernel/qplatformoffscreensurface.cpp \
kernel/qplatformcursor.cpp \
kernel/qplatformclipboard.cpp \
kernel/qplatformnativeinterface.cpp \
@@ -88,6 +91,7 @@ SOURCES += \
kernel/qsurfaceformat.cpp \
kernel/qguiapplication.cpp \
kernel/qwindow.cpp \
+ kernel/qoffscreensurface.cpp \
kernel/qplatformsurface.cpp \
kernel/qsurface.cpp \
kernel/qclipboard.cpp \
diff --git a/src/gui/kernel/qoffscreensurface.cpp b/src/gui/kernel/qoffscreensurface.cpp
new file mode 100644
index 0000000000..e2306050dd
--- /dev/null
+++ b/src/gui/kernel/qoffscreensurface.cpp
@@ -0,0 +1,345 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qoffscreensurface.h"
+
+#include "qguiapplication_p.h"
+#include "qscreen.h"
+#include "qplatformintegration.h"
+#include "qplatformoffscreensurface.h"
+#include "qwindow.h"
+#include "qplatformwindow.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QOffscreenSurface
+ \inmodule QtGui
+ \since 5.1
+ \brief The QOffscreenSurface class represents an offscreen surface in the underlying platform.
+
+ QOffscreenSurface is intended to be used with QOpenGLContext to allow rendering with OpenGL in
+ an arbitrary thread without the need to create a QWindow.
+
+ Even though the surface is renderable, the surface's pixels are not accessible.
+ QOffscreenSurface should only be used to create OpenGL resources such as textures
+ or framebuffer objects.
+
+ An application will typically use QOffscreenSurface to perform some time-consuming tasks in a
+ separate thread in order to avoid stalling the main rendering thread. Resources created in the
+ QOffscreenSurface's context can be shared with the main OpenGL context. Some common use cases
+ are asynchronous texture uploads or rendering into a QOpenGLFramebufferObject.
+
+ How the offscreen surface is implemented depends on the underlying platform, but it will
+ typically use a pixel buffer (pbuffer). If the platform doesn't implement or support
+ offscreen surfaces, QOffscreenSurface will use an invisible QWindow internally.
+*/
+class Q_GUI_EXPORT QOffscreenSurfacePrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QOffscreenSurface)
+
+public:
+ QOffscreenSurfacePrivate()
+ : QObjectPrivate()
+ , surfaceType(QSurface::OpenGLSurface)
+ , platformOffscreenSurface(0)
+ , offscreenWindow(0)
+ , screen(0)
+ , size(1, 1)
+ {
+ }
+
+ ~QOffscreenSurfacePrivate()
+ {
+ }
+
+ QSurface::SurfaceType surfaceType;
+ QPlatformOffscreenSurface *platformOffscreenSurface;
+ QWindow *offscreenWindow;
+ QSurfaceFormat requestedFormat;
+ QScreen *screen;
+ QSize size;
+};
+
+
+/*!
+ Creates an offscreen surface for the \a targetScreen.
+
+ The underlying platform surface is not created until create() is called.
+
+ \sa setScreen(), create()
+*/
+QOffscreenSurface::QOffscreenSurface(QScreen *targetScreen)
+ : QObject(*new QOffscreenSurfacePrivate(), 0)
+ , QSurface(Offscreen)
+{
+ Q_D(QOffscreenSurface);
+ d->screen = targetScreen;
+ if (!d->screen)
+ d->screen = QGuiApplication::primaryScreen();
+
+ //if your applications aborts here, then chances are your creating a QOffscreenSurface before
+ //the screen list is populated.
+ Q_ASSERT(d->screen);
+
+ connect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(screenDestroyed(QObject*)));
+}
+
+
+/*!
+ Destroys the offscreen surface.
+*/
+QOffscreenSurface::~QOffscreenSurface()
+{
+ destroy();
+}
+
+/*!
+ Returns the surface type of the offscreen surface.
+
+ The surface type of an offscreen surface is always QSurface::OpenGLSurface.
+*/
+QOffscreenSurface::SurfaceType QOffscreenSurface::surfaceType() const
+{
+ Q_D(const QOffscreenSurface);
+ return d->surfaceType;
+}
+
+/*!
+ Allocates the platform resources associated with the offscreen surface.
+
+ It is at this point that the surface format set using setFormat() gets resolved
+ into an actual native surface.
+
+ Call destroy() to free the platform resources if necessary.
+
+ \sa destroy()
+*/
+void QOffscreenSurface::create()
+{
+ Q_D(QOffscreenSurface);
+ if (!d->platformOffscreenSurface && !d->offscreenWindow) {
+ d->platformOffscreenSurface = QGuiApplicationPrivate::platformIntegration()->createPlatformOffscreenSurface(this);
+ // No platform offscreen surface, fallback to an invisible window
+ if (!d->platformOffscreenSurface) {
+ d->offscreenWindow = new QWindow(d->screen);
+ d->offscreenWindow->setSurfaceType(QWindow::OpenGLSurface);
+ d->offscreenWindow->setFormat(d->requestedFormat);
+ d->offscreenWindow->setGeometry(0, 0, d->size.width(), d->size.height());
+ d->offscreenWindow->create();
+ }
+ }
+}
+
+/*!
+ Releases the native platform resources associated with this offscreen surface.
+
+ \sa create()
+*/
+void QOffscreenSurface::destroy()
+{
+ Q_D(QOffscreenSurface);
+ delete d->platformOffscreenSurface;
+ d->platformOffscreenSurface = 0;
+ if (d->offscreenWindow) {
+ d->offscreenWindow->destroy();
+ delete d->offscreenWindow;
+ d->offscreenWindow = 0;
+ }
+}
+
+/*!
+ Returns \c true if this offscreen surface is valid; otherwise returns \c false.
+
+ The offscreen surface is valid if the platform resources have been successfuly allocated.
+
+ \sa create()
+*/
+bool QOffscreenSurface::isValid() const
+{
+ Q_D(const QOffscreenSurface);
+ return (d->platformOffscreenSurface && d->platformOffscreenSurface->isValid())
+ || (d->offscreenWindow && d->offscreenWindow->handle());
+}
+
+/*!
+ Sets the offscreen surface \a format.
+
+ The surface format will be resolved in the create() function. Calling
+ this function after create() will not re-resolve the surface format of the native surface.
+
+ \sa create(), destroy()
+*/
+void QOffscreenSurface::setFormat(const QSurfaceFormat &format)
+{
+ Q_D(QOffscreenSurface);
+ d->requestedFormat = format;
+}
+
+/*!
+ Returns the requested surfaceformat of this offscreen surface.
+
+ If the requested format was not supported by the platform implementation,
+ the requestedFormat will differ from the actual offscreen surface format.
+
+ This is the value set with setFormat().
+
+ \sa setFormat(), format()
+ */
+QSurfaceFormat QOffscreenSurface::requestedFormat() const
+{
+ Q_D(const QOffscreenSurface);
+ return d->requestedFormat;
+}
+
+/*!
+ Returns the actual format of this offscreen surface.
+
+ After the offscreen surface has been created, this function will return the actual
+ surface format of the surface. It might differ from the requested format if the requested
+ format could not be fulfilled by the platform.
+
+ \sa create(), requestedFormat()
+*/
+QSurfaceFormat QOffscreenSurface::format() const
+{
+ Q_D(const QOffscreenSurface);
+ if (d->platformOffscreenSurface)
+ return d->platformOffscreenSurface->format();
+ if (d->offscreenWindow)
+ return d->offscreenWindow->format();
+ return d->requestedFormat;
+}
+
+/*!
+ Returns the size of the offscreen surface.
+*/
+QSize QOffscreenSurface::size() const
+{
+ Q_D(const QOffscreenSurface);
+ return d->size;
+}
+
+/*!
+ Returns the screen to which the offscreen surface is connected.
+
+ \sa setScreen()
+*/
+QScreen *QOffscreenSurface::screen() const
+{
+ Q_D(const QOffscreenSurface);
+ return d->screen;
+}
+
+/*!
+ Sets the screen to which the offscreen surface is connected.
+
+ If the offscreen surface has been created, it will be recreated on the \a newScreen.
+
+ \sa screen()
+*/
+void QOffscreenSurface::setScreen(QScreen *newScreen)
+{
+ Q_D(QOffscreenSurface);
+ if (!newScreen)
+ newScreen = QGuiApplication::primaryScreen();
+ if (newScreen != d->screen) {
+ const bool wasCreated = d->platformOffscreenSurface != 0 || d->offscreenWindow != 0;
+ if (wasCreated)
+ destroy();
+ if (d->screen)
+ disconnect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(screenDestroyed(QObject*)));
+ d->screen = newScreen;
+ if (newScreen) {
+ connect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(screenDestroyed(QObject*)));
+ if (wasCreated)
+ create();
+ }
+ emit screenChanged(newScreen);
+ }
+}
+
+/*!
+ Called when the offscreen surface's screen is destroyed.
+
+ \internal
+*/
+void QOffscreenSurface::screenDestroyed(QObject *object)
+{
+ Q_D(QOffscreenSurface);
+ if (object == static_cast<QObject *>(d->screen))
+ setScreen(0);
+}
+
+/*!
+ \fn QOffscreenSurface::screenChanged(QScreen *screen)
+
+ This signal is emitted when an offscreen surface's \a screen changes, either
+ by being set explicitly with setScreen(), or automatically when
+ the window's screen is removed.
+*/
+
+/*!
+ Returns the platform offscreen surface corresponding to the offscreen surface.
+
+ \internal
+*/
+QPlatformOffscreenSurface *QOffscreenSurface::handle() const
+{
+ Q_D(const QOffscreenSurface);
+ return d->platformOffscreenSurface;
+}
+
+/*!
+ Returns the platform surface corresponding to the offscreen surface.
+
+ \internal
+*/
+QPlatformSurface *QOffscreenSurface::surfaceHandle() const
+{
+ Q_D(const QOffscreenSurface);
+ if (d->offscreenWindow)
+ return d->offscreenWindow->handle();
+
+ return d->platformOffscreenSurface;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qoffscreensurface.h b/src/gui/kernel/qoffscreensurface.h
new file mode 100644
index 0000000000..a1b46f9b88
--- /dev/null
+++ b/src/gui/kernel/qoffscreensurface.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QOFFSCREENSURFACE_H
+#define QOFFSCREENSURFACE_H
+
+#include <QtCore/QObject>
+#include <QtGui/qsurface.h>
+
+QT_BEGIN_NAMESPACE
+
+class QOffscreenSurfacePrivate;
+
+class QScreen;
+class QPlatformOffscreenSurface;
+
+class Q_GUI_EXPORT QOffscreenSurface : public QObject, public QSurface
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QOffscreenSurface)
+
+public:
+
+ explicit QOffscreenSurface(QScreen *screen = 0);
+ virtual ~QOffscreenSurface();
+
+ SurfaceType surfaceType() const;
+
+ void create();
+ void destroy();
+
+ bool isValid() const;
+
+ void setFormat(const QSurfaceFormat &format);
+ QSurfaceFormat format() const;
+ QSurfaceFormat requestedFormat() const;
+
+ QSize size() const;
+
+ QScreen *screen() const;
+ void setScreen(QScreen *screen);
+
+ QPlatformOffscreenSurface *handle() const;
+
+Q_SIGNALS:
+ void screenChanged(QScreen *screen);
+
+private Q_SLOTS:
+ void screenDestroyed(QObject *screen);
+
+private:
+
+ QPlatformSurface *surfaceHandle() const;
+
+ Q_DISABLE_COPY(QOffscreenSurface)
+};
+
+QT_END_NAMESPACE
+
+#endif // QOFFSCREENSURFACE_H
diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp
index 980e45742e..027b9fc9f1 100644
--- a/src/gui/kernel/qplatformintegration.cpp
+++ b/src/gui/kernel/qplatformintegration.cpp
@@ -360,4 +360,15 @@ class QPlatformTheme *QPlatformIntegration::createPlatformTheme(const QString &n
return new QPlatformTheme;
}
+/*!
+ Factory function for QOffscreenSurface. An offscreen surface will typically be implemented with a
+ pixel buffer (pbuffer). If the platform doesn't support offscreen surfaces, an invisible window
+ will be used by QOffscreenSurface instead.
+*/
+QPlatformOffscreenSurface *QPlatformIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
+{
+ Q_UNUSED(surface)
+ return 0;
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h
index 0b6cbb5a5c..6e10df9495 100644
--- a/src/gui/kernel/qplatformintegration.h
+++ b/src/gui/kernel/qplatformintegration.h
@@ -75,6 +75,8 @@ class QPlatformDialogHelper;
class QPlatformSharedGraphicsCache;
class QPlatformServices;
class QKeyEvent;
+class QPlatformOffscreenSurface;
+class QOffscreenSurface;
class Q_GUI_EXPORT QPlatformIntegration
{
@@ -146,6 +148,8 @@ public:
virtual QStringList themeNames() const;
virtual QPlatformTheme *createPlatformTheme(const QString &name) const;
+ virtual QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const;
+
protected:
void screenAdded(QPlatformScreen *screen);
};
diff --git a/src/gui/kernel/qplatformoffscreensurface.cpp b/src/gui/kernel/qplatformoffscreensurface.cpp
new file mode 100644
index 0000000000..dd354f465e
--- /dev/null
+++ b/src/gui/kernel/qplatformoffscreensurface.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformoffscreensurface.h"
+
+#include "qoffscreensurface.h"
+#include "qscreen.h"
+
+QT_BEGIN_NAMESPACE
+
+class QPlatformOffscreenSurfacePrivate
+{
+public:
+};
+
+QPlatformOffscreenSurface::QPlatformOffscreenSurface(QOffscreenSurface *offscreenSurface)
+ : QPlatformSurface(offscreenSurface)
+ , d_ptr(new QPlatformOffscreenSurfacePrivate)
+{
+}
+
+QPlatformOffscreenSurface::~QPlatformOffscreenSurface()
+{
+}
+
+QOffscreenSurface *QPlatformOffscreenSurface::offscreenSurface() const
+{
+ return static_cast<QOffscreenSurface*>(m_surface);
+}
+
+/*!
+ Returns the platform screen handle corresponding to this QPlatformOffscreenSurface.
+*/
+QPlatformScreen *QPlatformOffscreenSurface::screen() const
+{
+ return offscreenSurface()->screen()->handle();
+}
+
+/*!
+ Returns the actual surface format of the offscreen surface.
+*/
+QSurfaceFormat QPlatformOffscreenSurface::format() const
+{
+ return QSurfaceFormat();
+}
+
+/*!
+ Returns \c true if the platform offscreen surface has been allocated.
+*/
+bool QPlatformOffscreenSurface::isValid() const
+{
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformoffscreensurface.h b/src/gui/kernel/qplatformoffscreensurface.h
new file mode 100644
index 0000000000..099d8ee94a
--- /dev/null
+++ b/src/gui/kernel/qplatformoffscreensurface.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMOFFSCREENSURFACE_H
+#define QPLATFORMOFFSCREENSURFACE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is part of the QPA API and is not meant to be used
+// in applications. Usage of this API may make your code
+// source and binary incompatible with future versions of Qt.
+//
+
+#include "qplatformsurface.h"
+#include <QtCore/qscopedpointer.h>
+
+QT_BEGIN_NAMESPACE
+
+class QOffscreenSurface;
+class QPlatformScreen;
+class QPlatformOffscreenSurfacePrivate;
+
+class Q_GUI_EXPORT QPlatformOffscreenSurface : public QPlatformSurface
+{
+ Q_DECLARE_PRIVATE(QPlatformOffscreenSurface)
+public:
+ explicit QPlatformOffscreenSurface(QOffscreenSurface *offscreenSurface);
+ virtual ~QPlatformOffscreenSurface();
+
+ QOffscreenSurface *offscreenSurface() const;
+
+ QPlatformScreen *screen() const;
+
+ virtual QSurfaceFormat format() const;
+ virtual bool isValid() const;
+
+protected:
+ QScopedPointer<QPlatformOffscreenSurfacePrivate> d_ptr;
+private:
+ Q_DISABLE_COPY(QPlatformOffscreenSurface)
+};
+
+QT_END_NAMESPACE
+
+#endif // QPLATFORMOFFSCREENSURFACE_H
diff --git a/src/gui/kernel/qplatformsurface.h b/src/gui/kernel/qplatformsurface.h
index 18af7927bf..b96e494f74 100644
--- a/src/gui/kernel/qplatformsurface.h
+++ b/src/gui/kernel/qplatformsurface.h
@@ -72,6 +72,7 @@ private:
QSurface *m_surface;
friend class QPlatformWindow;
+ friend class QPlatformOffscreenSurface;
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qsurface.cpp b/src/gui/kernel/qsurface.cpp
index 97b8220124..a943639d5f 100644
--- a/src/gui/kernel/qsurface.cpp
+++ b/src/gui/kernel/qsurface.cpp
@@ -61,6 +61,7 @@ QT_BEGIN_NAMESPACE
The SurfaceClass enum describes the actual subclass of the surface.
\value Window The surface is an instance of QWindow.
+ \value Offscreen The surface is an instance of QOffscreenSurface.
*/
diff --git a/src/gui/kernel/qsurface.h b/src/gui/kernel/qsurface.h
index a2589c733b..8dbc230c10 100644
--- a/src/gui/kernel/qsurface.h
+++ b/src/gui/kernel/qsurface.h
@@ -58,7 +58,8 @@ class Q_GUI_EXPORT QSurface
{
public:
enum SurfaceClass {
- Window
+ Window,
+ Offscreen
};
enum SurfaceType {