summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/opengl/hellowindow/hellowindow.cpp13
-rw-r--r--examples/opengl/hellowindow/hellowindow.h6
-rw-r--r--src/gui/kernel/kernel.pri4
-rw-r--r--src/gui/kernel/qguiglcontext_qpa.cpp17
-rw-r--r--src/gui/kernel/qguiglcontext_qpa.h11
-rw-r--r--src/gui/kernel/qplatformglcontext_qpa.h39
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.cpp2
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.h3
-rw-r--r--src/gui/kernel/qplatformwindow_qpa.cpp19
-rw-r--r--src/gui/kernel/qplatformwindow_qpa.h11
-rw-r--r--src/gui/kernel/qsurfaceformat.cpp (renamed from src/gui/kernel/qguiglformat_qpa.cpp)118
-rw-r--r--src/gui/kernel/qsurfaceformat.h (renamed from src/gui/kernel/qguiglformat_qpa.h)54
-rw-r--r--src/gui/kernel/qwindow.cpp38
-rw-r--r--src/gui/kernel/qwindow.h42
-rw-r--r--src/gui/kernel/qwindow_p.h6
-rw-r--r--src/opengl/qgl.h10
-rw-r--r--src/opengl/qgl_qpa.cpp29
-rw-r--r--src/platformsupport/eglconvenience/qeglconvenience.cpp10
-rw-r--r--src/platformsupport/eglconvenience/qeglconvenience_p.h8
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcontext.cpp21
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcontext_p.h25
-rw-r--r--src/platformsupport/glxconvenience/qglxconvenience.cpp20
-rw-r--r--src/platformsupport/glxconvenience/qglxconvenience_p.h12
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.h22
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm12
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm6
-rw-r--r--src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h4
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp33
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h24
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp5
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp30
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h18
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp7
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp33
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h23
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp7
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h2
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration.cpp13
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration.h2
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmwindow.cpp6
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmwindow.h2
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.cpp24
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.h20
-rw-r--r--src/plugins/platforms/xcb/qxcbbackingstore.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp8
-rw-r--r--src/plugins/platforms/xcb/qxcbeglsurface.h68
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp21
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp59
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h22
-rw-r--r--src/plugins/platforms/xcb/xcb.pro1
-rw-r--r--src/widgets/kernel/qwidget_qpa.cpp6
65 files changed, 475 insertions, 551 deletions
diff --git a/examples/opengl/hellowindow/hellowindow.cpp b/examples/opengl/hellowindow/hellowindow.cpp
index a88fcf1edb..afdf08026a 100644
--- a/examples/opengl/hellowindow/hellowindow.cpp
+++ b/examples/opengl/hellowindow/hellowindow.cpp
@@ -15,7 +15,7 @@ Renderer::Renderer()
m_context = new QGuiGLContext(m_format);
}
-QGuiGLFormat Renderer::format() const
+QSurfaceFormat Renderer::format() const
{
return m_format;
}
@@ -24,10 +24,9 @@ HelloWindow::HelloWindow(Renderer *renderer)
: m_colorIndex(0)
, m_renderer(renderer)
{
- setSurfaceType(OpenGLSurface);
setWindowTitle(QLatin1String("Hello Window"));
- setGLFormat(renderer->format());
+ setFormat(renderer->format());
setGeometry(QRect(10, 10, 640, 480));
@@ -62,13 +61,13 @@ void HelloWindow::updateColor()
void HelloWindow::render()
{
- if (glSurface())
- m_renderer->render(glSurface(), m_color, geometry().size());
+ m_renderer->render(this, m_color, geometry().size());
}
-void Renderer::render(QPlatformGLSurface *surface, const QColor &color, const QSize &viewSize)
+void Renderer::render(QSurface *surface, const QColor &color, const QSize &viewSize)
{
- m_context->makeCurrent(surface);
+ if (!m_context->makeCurrent(surface))
+ return;
if (!m_initialized) {
initialize();
diff --git a/examples/opengl/hellowindow/hellowindow.h b/examples/opengl/hellowindow/hellowindow.h
index 274dc9ca17..3c5388cb76 100644
--- a/examples/opengl/hellowindow/hellowindow.h
+++ b/examples/opengl/hellowindow/hellowindow.h
@@ -12,9 +12,9 @@ class Renderer : public QObject
public:
Renderer();
- QGuiGLFormat format() const;
+ QSurfaceFormat format() const;
- void render(QPlatformGLSurface *surface, const QColor &color, const QSize &viewSize);
+ void render(QSurface *surface, const QColor &color, const QSize &viewSize);
private:
void initialize();
@@ -35,7 +35,7 @@ private:
int colorUniform;
bool m_initialized;
- QGuiGLFormat m_format;
+ QSurfaceFormat m_format;
QGuiGLContext *m_context;
};
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index 1d708e85b2..09df411404 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -52,7 +52,7 @@ qpa {
kernel/qplatformcursor_qpa.h \
kernel/qplatformclipboard_qpa.h \
kernel/qplatformnativeinterface_qpa.h \
- kernel/qguiglformat_qpa.h \
+ kernel/qsurfaceformat.h \
kernel/qguiapplication.h \
kernel/qguiapplication_p.h \
kernel/qwindow_p.h \
@@ -76,7 +76,7 @@ qpa {
kernel/qplatformclipboard_qpa.cpp \
kernel/qplatformnativeinterface_qpa.cpp \
kernel/qsessionmanager_qpa.cpp \
- kernel/qguiglformat_qpa.cpp \
+ kernel/qsurfaceformat.cpp \
kernel/qguiapplication.cpp \
kernel/qwindow.cpp
diff --git a/src/gui/kernel/qguiglcontext_qpa.cpp b/src/gui/kernel/qguiglcontext_qpa.cpp
index 4b30b41ab8..fd827966c4 100644
--- a/src/gui/kernel/qguiglcontext_qpa.cpp
+++ b/src/gui/kernel/qguiglcontext_qpa.cpp
@@ -120,7 +120,7 @@ QPlatformGLContext *QGuiGLContext::handle() const
/*!
Creates a new GL context with the given format and shared context.
*/
-QGuiGLContext::QGuiGLContext(const QGuiGLFormat &format, QGuiGLContext *shareContext)
+QGuiGLContext::QGuiGLContext(const QSurfaceFormat &format, QGuiGLContext *shareContext)
: d_ptr(new QGuiGLContextPrivate())
{
Q_D(QGuiGLContext);
@@ -149,7 +149,7 @@ bool QGuiGLContext::isValid() const
/*!
If surface is 0 this is equivalent to calling doneCurrent().
*/
-bool QGuiGLContext::makeCurrent(QPlatformGLSurface *surface)
+bool QGuiGLContext::makeCurrent(QSurface *surface)
{
Q_D(QGuiGLContext);
if (!d->platformGLContext)
@@ -160,7 +160,10 @@ bool QGuiGLContext::makeCurrent(QPlatformGLSurface *surface)
return true;
}
- if (d->platformGLContext->makeCurrent(*surface)) {
+ if (!surface->surfaceHandle())
+ return false;
+
+ if (d->platformGLContext->makeCurrent(surface->surfaceHandle())) {
QGuiGLContextPrivate::setCurrentContext(this);
return true;
}
@@ -181,7 +184,7 @@ void QGuiGLContext::doneCurrent()
QGuiGLContextPrivate::setCurrentContext(0);
}
-void QGuiGLContext::swapBuffers(QPlatformGLSurface *surface)
+void QGuiGLContext::swapBuffers(QSurface *surface)
{
Q_D(QGuiGLContext);
if (!d->platformGLContext)
@@ -192,7 +195,7 @@ void QGuiGLContext::swapBuffers(QPlatformGLSurface *surface)
return;
}
- d->platformGLContext->swapBuffers(*surface);
+ d->platformGLContext->swapBuffers(surface->surfaceHandle());
}
void (*QGuiGLContext::getProcAddress(const QByteArray &procName)) ()
@@ -203,11 +206,11 @@ void (*QGuiGLContext::getProcAddress(const QByteArray &procName)) ()
return d->platformGLContext->getProcAddress(procName);
}
-QGuiGLFormat QGuiGLContext::format() const
+QSurfaceFormat QGuiGLContext::format() const
{
Q_D(const QGuiGLContext);
if (!d->platformGLContext)
- return QGuiGLFormat();
+ return QSurfaceFormat();
return d->platformGLContext->format();
}
diff --git a/src/gui/kernel/qguiglcontext_qpa.h b/src/gui/kernel/qguiglcontext_qpa.h
index 230be08029..65e9fb4c3f 100644
--- a/src/gui/kernel/qguiglcontext_qpa.h
+++ b/src/gui/kernel/qguiglcontext_qpa.h
@@ -53,24 +53,25 @@ QT_MODULE(Gui)
class QGuiGLContextPrivate;
class QPlatformGLContext;
-class QPlatformGLSurface;
+class QSurface;
+class QSurfaceFormat;
class Q_GUI_EXPORT QGuiGLContext
{
Q_DECLARE_PRIVATE(QGuiGLContext);
public:
- QGuiGLContext(const QGuiGLFormat &format = QGuiGLFormat(), QGuiGLContext *shareContext = 0);
+ QGuiGLContext(const QSurfaceFormat &format = QSurfaceFormat(), QGuiGLContext *shareContext = 0);
~QGuiGLContext();
bool isValid() const;
- bool makeCurrent(QPlatformGLSurface *surface);
+ bool makeCurrent(QSurface *surface);
void doneCurrent();
- void swapBuffers(QPlatformGLSurface *surface);
+ void swapBuffers(QSurface *surface);
void (*getProcAddress(const QByteArray &procName)) ();
- QGuiGLFormat format() const;
+ QSurfaceFormat format() const;
QGuiGLContext *shareContext() const;
diff --git a/src/gui/kernel/qplatformglcontext_qpa.h b/src/gui/kernel/qplatformglcontext_qpa.h
index 51c63d3fa1..e362e477c0 100644
--- a/src/gui/kernel/qplatformglcontext_qpa.h
+++ b/src/gui/kernel/qplatformglcontext_qpa.h
@@ -39,11 +39,12 @@
**
****************************************************************************/
-#ifndef QPLATFORM_GL_CONTEXT_H
-#define QPLATFORM_GL_CONTEXT_H
+#ifndef QPLATFORMGLCONTEXT_H
+#define QPLATFORMGLCONTEXT_H
#include <QtCore/qnamespace.h>
-#include <QtGui/qguiglformat_qpa.h>
+#include <QtGui/qsurfaceformat.h>
+#include <QtGui/qwindow.h>
QT_BEGIN_HEADER
@@ -51,29 +52,19 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
-class Q_GUI_EXPORT QPlatformGLSurface
+class Q_GUI_EXPORT QPlatformSurface
{
public:
- QPlatformGLSurface(const QGuiGLFormat &format = QGuiGLFormat())
- : m_format(format)
- {
- }
+ virtual QSurfaceFormat format() const = 0;
- virtual ~QPlatformGLSurface() {}
+ QSurface::SurfaceType surfaceType() const { return m_type; }
- QGuiGLFormat format() const
- {
- return m_format;
- }
+private:
+ QPlatformSurface(QSurface::SurfaceType type) : m_type(type) {}
-protected:
- void setFormat(const QGuiGLFormat &format)
- {
- m_format = format;
- }
+ QSurface::SurfaceType m_type;
-private:
- QGuiGLFormat m_format;
+ friend class QPlatformWindow;
};
class Q_GUI_EXPORT QPlatformGLContext
@@ -81,11 +72,11 @@ class Q_GUI_EXPORT QPlatformGLContext
public:
virtual ~QPlatformGLContext() {}
- virtual QGuiGLFormat format() const = 0;
+ virtual QSurfaceFormat format() const = 0;
- virtual void swapBuffers(const QPlatformGLSurface &surface) = 0;
+ virtual void swapBuffers(QPlatformSurface *surface) = 0;
- virtual bool makeCurrent(const QPlatformGLSurface &surface) = 0;
+ virtual bool makeCurrent(QPlatformSurface *surface) = 0;
virtual void doneCurrent() = 0;
virtual void (*getProcAddress(const QByteArray &procName)) () = 0;
@@ -96,4 +87,4 @@ QT_END_NAMESPACE
QT_END_HEADER
-#endif // QPLATFORM_GL_CONTEXT_H
+#endif // QPLATFORMGLCONTEXT_H
diff --git a/src/gui/kernel/qplatformintegration_qpa.cpp b/src/gui/kernel/qplatformintegration_qpa.cpp
index 5db0366707..fe90ce86aa 100644
--- a/src/gui/kernel/qplatformintegration_qpa.cpp
+++ b/src/gui/kernel/qplatformintegration_qpa.cpp
@@ -171,7 +171,7 @@ QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const
*/
-QPlatformGLContext *QPlatformIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const
+QPlatformGLContext *QPlatformIntegration::createPlatformGLContext(const QSurfaceFormat &, QPlatformGLContext *) const
{
qWarning("This plugin does not support createPlatformGLContext!");
return 0;
diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h
index 8263999b2d..c1934ec83a 100644
--- a/src/gui/kernel/qplatformintegration_qpa.h
+++ b/src/gui/kernel/qplatformintegration_qpa.h
@@ -45,6 +45,7 @@
#include <QtGui/qwindowdefs.h>
#include <QtGui/private/qpixmapdata_p.h>
#include <QtGui/qplatformscreen_qpa.h>
+#include <QtGui/qsurfaceformat.h>
QT_BEGIN_HEADER
@@ -79,7 +80,7 @@ public:
virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0;
virtual QPlatformWindow *createPlatformWindow(QWindow *window) const = 0;
virtual QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const = 0;
- virtual QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const;
+ virtual QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &format, QPlatformGLContext *share) const;
// Window System functions
virtual QList<QPlatformScreen *> screens() const = 0;
diff --git a/src/gui/kernel/qplatformwindow_qpa.cpp b/src/gui/kernel/qplatformwindow_qpa.cpp
index feffd0cfed..b1fdc9734d 100644
--- a/src/gui/kernel/qplatformwindow_qpa.cpp
+++ b/src/gui/kernel/qplatformwindow_qpa.cpp
@@ -56,7 +56,8 @@ class QPlatformWindowPrivate
*/
QPlatformWindow::QPlatformWindow(QWindow *window)
- : d_ptr(new QPlatformWindowPrivate)
+ : QPlatformSurface(QSurface::Window)
+ , d_ptr(new QPlatformWindowPrivate)
{
Q_D(QPlatformWindow);
d->window = window;
@@ -88,6 +89,14 @@ QPlatformWindow *QPlatformWindow::parent() const
}
/*!
+ Returns the actual surface format of the window.
+*/
+QSurfaceFormat QPlatformWindow::format() const
+{
+ return QSurfaceFormat();
+}
+
+/*!
This function is called by Qt whenever a window is moved or the window is resized. The resize
can happen programatically(from ie. user application) or by the window manager. This means that
there is no need to call this function specifically from the window manager callback, instead
@@ -209,14 +218,6 @@ void QPlatformWindow::requestActivateWindow()
QWindowSystemInterface::handleWindowActivated(window());
}
-/*!
- Reimplement to create a GL surface for the window.
-*/
-QPlatformGLSurface *QPlatformWindow::createGLSurface() const
-{
- return 0;
-}
-
bool QPlatformWindow::setKeyboardGrabEnabled(bool grab)
{
Q_UNUSED(grab);
diff --git a/src/gui/kernel/qplatformwindow_qpa.h b/src/gui/kernel/qplatformwindow_qpa.h
index 8166344246..dc988e183e 100644
--- a/src/gui/kernel/qplatformwindow_qpa.h
+++ b/src/gui/kernel/qplatformwindow_qpa.h
@@ -41,13 +41,13 @@
#ifndef QPLATFORMWINDOW_H
#define QPLATFORMWINDOW_H
-
#include <QtCore/qscopedpointer.h>
#include <QtCore/qrect.h>
#include <QtCore/qmargins.h>
#include <QtCore/qstring.h>
#include <QtGui/qwindowdefs.h>
-
+#include <QtGui/qwindow.h>
+#include <QtGui/qplatformglcontext_qpa.h>
QT_BEGIN_HEADER
@@ -57,9 +57,8 @@ QT_MODULE(Gui)
class QPlatformWindowPrivate;
class QWindow;
-class QPlatformGLSurface;
-class Q_GUI_EXPORT QPlatformWindow
+class Q_GUI_EXPORT QPlatformWindow : public QPlatformSurface
{
Q_DECLARE_PRIVATE(QPlatformWindow)
public:
@@ -69,6 +68,8 @@ public:
QWindow *window() const;
QPlatformWindow *parent() const;
+ virtual QSurfaceFormat format() const;
+
virtual void setGeometry(const QRect &rect);
virtual QRect geometry() const;
@@ -90,8 +91,6 @@ public:
virtual void setOpacity(qreal level);
virtual void requestActivateWindow();
- virtual QPlatformGLSurface *createGLSurface() const;
-
virtual bool setKeyboardGrabEnabled(bool grab);
virtual bool setMouseGrabEnabled(bool grab);
diff --git a/src/gui/kernel/qguiglformat_qpa.cpp b/src/gui/kernel/qsurfaceformat.cpp
index 65bd6a4ac2..88601cab1f 100644
--- a/src/gui/kernel/qguiglformat_qpa.cpp
+++ b/src/gui/kernel/qsurfaceformat.cpp
@@ -39,29 +39,29 @@
**
****************************************************************************/
-#include "qguiglformat_qpa.h"
+#include "qsurfaceformat.h"
#include <QtCore/qatomic.h>
#include <QtCore/QDebug>
-class QGuiGLFormatPrivate
+class QSurfaceFormatPrivate
{
public:
- QGuiGLFormatPrivate()
+ QSurfaceFormatPrivate()
: ref(1)
- , opts(QGuiGLFormat::DoubleBuffer | QGuiGLFormat::WindowSurface)
+ , opts(QSurfaceFormat::DoubleBuffer)
, redBufferSize(-1)
, greenBufferSize(-1)
, blueBufferSize(-1)
, alphaBufferSize(-1)
, depthSize(-1)
, stencilSize(-1)
- , swapBehavior(QGuiGLFormat::DefaultSwapBehavior)
+ , swapBehavior(QSurfaceFormat::DefaultSwapBehavior)
, numSamples(-1)
{
}
- QGuiGLFormatPrivate(const QGuiGLFormatPrivate *other)
+ QSurfaceFormatPrivate(const QSurfaceFormatPrivate *other)
: ref(1),
opts(other->opts),
redBufferSize(other->redBufferSize),
@@ -76,35 +76,35 @@ public:
}
QAtomicInt ref;
- QGuiGLFormat::FormatOptions opts;
+ QSurfaceFormat::FormatOptions opts;
int redBufferSize;
int greenBufferSize;
int blueBufferSize;
int alphaBufferSize;
int depthSize;
int stencilSize;
- QGuiGLFormat::SwapBehavior swapBehavior;
+ QSurfaceFormat::SwapBehavior swapBehavior;
int numSamples;
};
-QGuiGLFormat::QGuiGLFormat()
+QSurfaceFormat::QSurfaceFormat()
{
- d = new QGuiGLFormatPrivate;
+ d = new QSurfaceFormatPrivate;
}
-QGuiGLFormat::QGuiGLFormat(QGuiGLFormat::FormatOptions options)
+QSurfaceFormat::QSurfaceFormat(QSurfaceFormat::FormatOptions options)
{
- d = new QGuiGLFormatPrivate;
+ d = new QSurfaceFormatPrivate;
d->opts = options;
}
/*!
\internal
*/
-void QGuiGLFormat::detach()
+void QSurfaceFormat::detach()
{
if (d->ref != 1) {
- QGuiGLFormatPrivate *newd = new QGuiGLFormatPrivate(d);
+ QSurfaceFormatPrivate *newd = new QSurfaceFormatPrivate(d);
if (!d->ref.deref())
delete d;
d = newd;
@@ -115,7 +115,7 @@ void QGuiGLFormat::detach()
Constructs a copy of \a other.
*/
-QGuiGLFormat::QGuiGLFormat(const QGuiGLFormat &other)
+QSurfaceFormat::QSurfaceFormat(const QSurfaceFormat &other)
{
d = other.d;
d->ref.ref();
@@ -125,7 +125,7 @@ QGuiGLFormat::QGuiGLFormat(const QGuiGLFormat &other)
Assigns \a other to this object.
*/
-QGuiGLFormat &QGuiGLFormat::operator=(const QGuiGLFormat &other)
+QSurfaceFormat &QSurfaceFormat::operator=(const QSurfaceFormat &other)
{
if (d != other.d) {
other.d->ref.ref();
@@ -137,16 +137,16 @@ QGuiGLFormat &QGuiGLFormat::operator=(const QGuiGLFormat &other)
}
/*!
- Destroys the QGuiGLFormat.
+ Destroys the QSurfaceFormat.
*/
-QGuiGLFormat::~QGuiGLFormat()
+QSurfaceFormat::~QSurfaceFormat()
{
if (!d->ref.deref())
delete d;
}
/*!
- \fn bool QGuiGLFormat::stereo() const
+ \fn bool QSurfaceFormat::stereo() const
Returns true if stereo buffering is enabled; otherwise returns
false. Stereo buffering is disabled by default.
@@ -166,12 +166,12 @@ QGuiGLFormat::~QGuiGLFormat()
\sa stereo()
*/
-void QGuiGLFormat::setStereo(bool enable)
+void QSurfaceFormat::setStereo(bool enable)
{
if (enable) {
- d->opts |= QGuiGLFormat::StereoBuffers;
+ d->opts |= QSurfaceFormat::StereoBuffers;
} else {
- d->opts &= ~QGuiGLFormat::StereoBuffers;
+ d->opts &= ~QSurfaceFormat::StereoBuffers;
}
}
@@ -182,7 +182,7 @@ void QGuiGLFormat::setStereo(bool enable)
\sa setSampleBuffers(), sampleBuffers(), setSamples()
*/
-int QGuiGLFormat::samples() const
+int QSurfaceFormat::samples() const
{
return d->numSamples;
}
@@ -194,41 +194,19 @@ int QGuiGLFormat::samples() const
\sa setSampleBuffers(), sampleBuffers(), samples()
*/
-void QGuiGLFormat::setSamples(int numSamples)
+void QSurfaceFormat::setSamples(int numSamples)
{
detach();
d->numSamples = numSamples;
}
-
-/*!
- \fn bool QGuiGLFormat::hasWindowSurface() const
-
- Returns true if the corresponding widget has an instance of QWindowSurface.
-
- Otherwise returns false.
-
- WindowSurface is enabled by default.
-
- \sa setOverlay()
-*/
-
-void QGuiGLFormat::setWindowSurface(bool enable)
-{
- if (enable) {
- d->opts |= QGuiGLFormat::WindowSurface;
- } else {
- d->opts &= ~QGuiGLFormat::WindowSurface;
- }
-}
-
/*!
Sets the format option to \a opt.
\sa testOption()
*/
-void QGuiGLFormat::setOption(QGuiGLFormat::FormatOptions opt)
+void QSurfaceFormat::setOption(QSurfaceFormat::FormatOptions opt)
{
detach();
d->opts |= opt;
@@ -240,7 +218,7 @@ void QGuiGLFormat::setOption(QGuiGLFormat::FormatOptions opt)
\sa setOption()
*/
-bool QGuiGLFormat::testOption(QGuiGLFormat::FormatOptions opt) const
+bool QSurfaceFormat::testOption(QSurfaceFormat::FormatOptions opt) const
{
return d->opts & opt;
}
@@ -250,7 +228,7 @@ bool QGuiGLFormat::testOption(QGuiGLFormat::FormatOptions opt) const
\sa depthBufferSize(), setDepth(), depth()
*/
-void QGuiGLFormat::setDepthBufferSize(int size)
+void QSurfaceFormat::setDepthBufferSize(int size)
{
detach();
d->depthSize = size;
@@ -261,22 +239,22 @@ void QGuiGLFormat::setDepthBufferSize(int size)
\sa depth(), setDepth(), setDepthBufferSize()
*/
-int QGuiGLFormat::depthBufferSize() const
+int QSurfaceFormat::depthBufferSize() const
{
return d->depthSize;
}
-void QGuiGLFormat::setSwapBehavior(SwapBehavior behavior)
+void QSurfaceFormat::setSwapBehavior(SwapBehavior behavior)
{
d->swapBehavior = behavior;
}
-QGuiGLFormat::SwapBehavior QGuiGLFormat::swapBehavior() const
+QSurfaceFormat::SwapBehavior QSurfaceFormat::swapBehavior() const
{
return d->swapBehavior;
}
-bool QGuiGLFormat::hasAlpha() const
+bool QSurfaceFormat::hasAlpha() const
{
return d->alphaBufferSize > 0;
}
@@ -286,7 +264,7 @@ bool QGuiGLFormat::hasAlpha() const
\sa stencilBufferSize(), setStencil(), stencil()
*/
-void QGuiGLFormat::setStencilBufferSize(int size)
+void QSurfaceFormat::setStencilBufferSize(int size)
{
detach();
d->stencilSize = size;
@@ -297,52 +275,52 @@ void QGuiGLFormat::setStencilBufferSize(int size)
\sa stencil(), setStencil(), setStencilBufferSize()
*/
-int QGuiGLFormat::stencilBufferSize() const
+int QSurfaceFormat::stencilBufferSize() const
{
return d->stencilSize;
}
-int QGuiGLFormat::redBufferSize() const
+int QSurfaceFormat::redBufferSize() const
{
return d->redBufferSize;
}
-int QGuiGLFormat::greenBufferSize() const
+int QSurfaceFormat::greenBufferSize() const
{
return d->greenBufferSize;
}
-int QGuiGLFormat::blueBufferSize() const
+int QSurfaceFormat::blueBufferSize() const
{
return d->blueBufferSize;
}
-int QGuiGLFormat::alphaBufferSize() const
+int QSurfaceFormat::alphaBufferSize() const
{
return d->alphaBufferSize;
}
-void QGuiGLFormat::setRedBufferSize(int size)
+void QSurfaceFormat::setRedBufferSize(int size)
{
d->redBufferSize = size;
}
-void QGuiGLFormat::setGreenBufferSize(int size)
+void QSurfaceFormat::setGreenBufferSize(int size)
{
d->greenBufferSize = size;
}
-void QGuiGLFormat::setBlueBufferSize(int size)
+void QSurfaceFormat::setBlueBufferSize(int size)
{
d->blueBufferSize = size;
}
-void QGuiGLFormat::setAlphaBufferSize(int size)
+void QSurfaceFormat::setAlphaBufferSize(int size)
{
d->alphaBufferSize = size;
}
-bool operator==(const QGuiGLFormat& a, const QGuiGLFormat& b)
+bool operator==(const QSurfaceFormat& a, const QSurfaceFormat& b)
{
return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts
&& a.d->stencilSize == b.d->stencilSize
@@ -357,23 +335,23 @@ bool operator==(const QGuiGLFormat& a, const QGuiGLFormat& b)
/*!
- Returns false if all the options of the two QGuiGLFormat objects
+ Returns false if all the options of the two QSurfaceFormat objects
\a a and \a b are equal; otherwise returns true.
- \relates QGuiGLFormat
+ \relates QSurfaceFormat
*/
-bool operator!=(const QGuiGLFormat& a, const QGuiGLFormat& b)
+bool operator!=(const QSurfaceFormat& a, const QSurfaceFormat& b)
{
return !(a == b);
}
#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug dbg, const QGuiGLFormat &f)
+QDebug operator<<(QDebug dbg, const QSurfaceFormat &f)
{
- const QGuiGLFormatPrivate * const d = f.d;
+ const QSurfaceFormatPrivate * const d = f.d;
- dbg.nospace() << "QGuiGLFormat("
+ dbg.nospace() << "QSurfaceFormat("
<< "options " << d->opts
<< ", depthBufferSize " << d->depthSize
<< ", redBufferSize " << d->redBufferSize
diff --git a/src/gui/kernel/qguiglformat_qpa.h b/src/gui/kernel/qsurfaceformat.h
index a14a8256b6..6e89aa667b 100644
--- a/src/gui/kernel/qguiglformat_qpa.h
+++ b/src/gui/kernel/qsurfaceformat.h
@@ -38,8 +38,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#ifndef QGUIGLFORMAT_QPA_H
-#define QGUIGLFORMAT_QPA_H
+#ifndef QSURFACEFORMAT_H
+#define QSURFACEFORMAT_H
#include <qglobal.h>
@@ -50,14 +50,13 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
class QGuiGLContext;
-class QGuiGLFormatPrivate;
+class QSurfaceFormatPrivate;
-class Q_GUI_EXPORT QGuiGLFormat
+class Q_GUI_EXPORT QSurfaceFormat
{
public:
enum FormatOption {
- StereoBuffers = 0x0001,
- WindowSurface = 0x0002
+ StereoBuffers = 0x0001
};
Q_DECLARE_FLAGS(FormatOptions, FormatOption)
@@ -74,11 +73,11 @@ public:
CompatibilityProfile
};
- QGuiGLFormat();
- QGuiGLFormat(FormatOptions options);
- QGuiGLFormat(const QGuiGLFormat &other);
- QGuiGLFormat &operator=(const QGuiGLFormat &other);
- ~QGuiGLFormat();
+ QSurfaceFormat();
+ QSurfaceFormat(FormatOptions options);
+ QSurfaceFormat(const QSurfaceFormat &other);
+ QSurfaceFormat &operator=(const QSurfaceFormat &other);
+ ~QSurfaceFormat();
void setDepthBufferSize(int size);
int depthBufferSize() const;
@@ -108,45 +107,38 @@ public:
bool stereo() const;
void setStereo(bool enable);
- bool windowSurface() const;
- void setWindowSurface(bool enable);
- void setOption(QGuiGLFormat::FormatOptions opt);
- bool testOption(QGuiGLFormat::FormatOptions opt) const;
+ void setOption(QSurfaceFormat::FormatOptions opt);
+ bool testOption(QSurfaceFormat::FormatOptions opt) const;
private:
- QGuiGLFormatPrivate *d;
+ QSurfaceFormatPrivate *d;
void detach();
- friend Q_GUI_EXPORT bool operator==(const QGuiGLFormat&, const QGuiGLFormat&);
- friend Q_GUI_EXPORT bool operator!=(const QGuiGLFormat&, const QGuiGLFormat&);
+ friend Q_GUI_EXPORT bool operator==(const QSurfaceFormat&, const QSurfaceFormat&);
+ friend Q_GUI_EXPORT bool operator!=(const QSurfaceFormat&, const QSurfaceFormat&);
#ifndef QT_NO_DEBUG_STREAM
- friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QGuiGLFormat &);
+ friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QSurfaceFormat &);
#endif
};
-Q_GUI_EXPORT bool operator==(const QGuiGLFormat&, const QGuiGLFormat&);
-Q_GUI_EXPORT bool operator!=(const QGuiGLFormat&, const QGuiGLFormat&);
+Q_GUI_EXPORT bool operator==(const QSurfaceFormat&, const QSurfaceFormat&);
+Q_GUI_EXPORT bool operator!=(const QSurfaceFormat&, const QSurfaceFormat&);
#ifndef QT_NO_DEBUG_STREAM
-Q_GUI_EXPORT QDebug operator<<(QDebug, const QGuiGLFormat &);
+Q_GUI_EXPORT QDebug operator<<(QDebug, const QSurfaceFormat &);
#endif
-Q_DECLARE_OPERATORS_FOR_FLAGS(QGuiGLFormat::FormatOptions)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QSurfaceFormat::FormatOptions)
-inline bool QGuiGLFormat::stereo() const
+inline bool QSurfaceFormat::stereo() const
{
- return testOption(QGuiGLFormat::StereoBuffers);
-}
-
-inline bool QGuiGLFormat::windowSurface() const
-{
- return testOption(QGuiGLFormat::WindowSurface);
+ return testOption(QSurfaceFormat::StereoBuffers);
}
QT_END_NAMESPACE
QT_END_HEADER
-#endif //QGUIGLFORMAT_QPA_H
+#endif //QSURFACEFORMAT_H
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index c29bc7002d..f56962ddb4 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -42,7 +42,7 @@
#include "qwindow.h"
#include "qplatformwindow_qpa.h"
-#include "qguiglformat_qpa.h"
+#include "qsurfaceformat.h"
#include "qplatformglcontext_qpa.h"
#include "qguiglcontext_qpa.h"
@@ -57,6 +57,7 @@ QT_BEGIN_NAMESPACE
QWindow::QWindow(QWindow *parent)
: QObject(*new QWindowPrivate(), parent)
+ , QSurface(QSurface::Window)
{
Q_D(QWindow);
d->parentWindow = parent;
@@ -178,40 +179,20 @@ void QWindow::setWindowModality(Qt::WindowModality windowModality)
d->modality = windowModality;
}
-void QWindow::setGLFormat(const QGuiGLFormat &format)
+void QWindow::setFormat(const QSurfaceFormat &format)
{
Q_D(QWindow);
d->requestedFormat = format;
}
-QGuiGLFormat QWindow::glFormat() const
+QSurfaceFormat QWindow::format() const
{
Q_D(const QWindow);
- if (d->glSurface)
- return d->glSurface->format();
+ if (d->platformWindow)
+ return d->platformWindow->format();
return d->requestedFormat;
}
-QPlatformGLSurface *QWindow::glSurface() const
-{
- Q_D(const QWindow);
- if (d->platformWindow && !d->glSurface)
- const_cast<QPlatformGLSurface *&>(d->glSurface) = d->platformWindow->createGLSurface();
- return d->glSurface;
-}
-
-void QWindow::setSurfaceType(SurfaceType type)
-{
- Q_D(QWindow);
- d->surfaceType = type;
-}
-
-QWindow::SurfaceType QWindow::surfaceType() const
-{
- Q_D(const QWindow);
- return d->surfaceType;
-}
-
void QWindow::setWindowFlags(Qt::WindowFlags flags)
{
Q_D(QWindow);
@@ -414,9 +395,7 @@ void QWindow::setWindowIcon(const QImage &icon) const
void QWindow::destroy()
{
Q_D(QWindow);
- delete d->glSurface;
delete d->platformWindow;
- d->glSurface = 0;
d->platformWindow = 0;
}
@@ -426,6 +405,11 @@ QPlatformWindow *QWindow::handle() const
return d->platformWindow;
}
+QPlatformSurface *QWindow::surfaceHandle() const
+{
+ Q_D(const QWindow);
+ return d->platformWindow;
+}
bool QWindow::setKeyboardGrabEnabled(bool grab)
{
diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h
index cfd251fff0..af882b5451 100644
--- a/src/gui/kernel/qwindow.h
+++ b/src/gui/kernel/qwindow.h
@@ -46,7 +46,7 @@
#include <QtCore/QEvent>
#include <QtCore/QMargins>
-#include <QtGui/qguiglformat_qpa.h>
+#include <QtGui/qsurfaceformat.h>
#include <QtGui/qwindowdefs.h>
QT_BEGIN_HEADER
@@ -67,11 +67,31 @@ class QMouseEvent;
class QWheelEvent;
#endif
-class QPlatformGLSurface;
+class QPlatformSurface;
class QPlatformWindow;
class QBackingStore;
-class Q_GUI_EXPORT QWindow : public QObject
+class Q_GUI_EXPORT QSurface
+{
+public:
+ enum SurfaceType {
+ Window
+ };
+
+ SurfaceType surfaceType() const { return m_type; }
+
+ virtual QSurfaceFormat format() const = 0;
+ virtual QPlatformSurface *surfaceHandle() const = 0;
+
+private:
+ QSurface(SurfaceType type) : m_type(type) {}
+
+ SurfaceType m_type;
+
+ friend class QWindow;
+};
+
+class Q_GUI_EXPORT QWindow : public QObject, public QSurface
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWindow)
@@ -79,11 +99,6 @@ class Q_GUI_EXPORT QWindow : public QObject
Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle)
public:
- enum SurfaceType {
- RasterSurface,
- OpenGLSurface
- };
-
QWindow(QWindow *parent = 0);
virtual ~QWindow();
@@ -103,13 +118,8 @@ public:
Qt::WindowModality windowModality() const;
void setWindowModality(Qt::WindowModality windowModality);
- void setGLFormat(const QGuiGLFormat &format);
- QGuiGLFormat glFormat() const;
-
- QPlatformGLSurface *glSurface() const;
-
- void setSurfaceType(SurfaceType type);
- SurfaceType surfaceType() const;
+ void setFormat(const QSurfaceFormat &format);
+ QSurfaceFormat format() const;
void setWindowFlags(Qt::WindowFlags flags);
Qt::WindowFlags windowFlags() const;
@@ -187,6 +197,8 @@ protected:
#endif
private:
+ QPlatformSurface *surfaceHandle() const;
+
Q_DISABLE_COPY(QWindow)
friend class QGuiApplication;
diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h
index 1c4c4bffad..a8b118319d 100644
--- a/src/gui/kernel/qwindow_p.h
+++ b/src/gui/kernel/qwindow_p.h
@@ -60,11 +60,9 @@ public:
QWindowPrivate()
: QObjectPrivate()
, windowFlags(Qt::Window)
- , surfaceType(QWindow::RasterSurface)
, parentWindow(0)
, platformWindow(0)
, visible(false)
- , glSurface(0)
, windowState(Qt::WindowNoState)
, maximumSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX)
, modality(Qt::NonModal)
@@ -78,14 +76,12 @@ public:
}
Qt::WindowFlags windowFlags;
- QWindow::SurfaceType surfaceType;
QWindow *parentWindow;
QPlatformWindow *platformWindow;
bool visible;
- QGuiGLFormat requestedFormat;
+ QSurfaceFormat requestedFormat;
QString windowTitle;
QRect geometry;
- QPlatformGLSurface *glSurface;
Qt::WindowState windowState;
QSize minimumSize;
diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h
index f6051fa179..c9908ad01f 100644
--- a/src/opengl/qgl.h
+++ b/src/opengl/qgl.h
@@ -48,9 +48,7 @@
#include <QtCore/qmap.h>
#include <QtCore/qscopedpointer.h>
-#ifdef Q_WS_QPA
-#include <QtGui/QGuiGLFormat>
-#endif
+#include <QtGui/QSurfaceFormat>
QT_BEGIN_HEADER
@@ -282,10 +280,8 @@ public:
static OpenGLVersionFlags openGLVersionFlags();
-#if defined(Q_WS_QPA)
- static QGLFormat fromGuiGLFormat(const QGuiGLFormat &format);
- static QGuiGLFormat toGuiGLFormat(const QGLFormat &format);
-#endif
+ static QGLFormat fromSurfaceFormat(const QSurfaceFormat &format);
+ static QSurfaceFormat toSurfaceFormat(const QGLFormat &format);
private:
QGLFormatPrivate *d;
diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp
index cb3032bd59..661f120601 100644
--- a/src/opengl/qgl_qpa.cpp
+++ b/src/opengl/qgl_qpa.cpp
@@ -47,7 +47,7 @@
#include <private/qapplication_p.h>
#include <QtGui/QPlatformGLContext>
#include <QtGui/QPlatformWindow>
-#include <QtGui/QGuiGLFormat>
+#include <QtGui/QSurfaceFormat>
#include "qgl.h"
#include "qgl_p.h"
@@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
/*!
Returns an OpenGL format for the window format specified by \a format.
*/
-QGLFormat QGLFormat::fromGuiGLFormat(const QGuiGLFormat &format)
+QGLFormat QGLFormat::fromSurfaceFormat(const QSurfaceFormat &format)
{
QGLFormat retFormat;
if (format.alphaBufferSize() >= 0)
@@ -78,7 +78,7 @@ QGLFormat QGLFormat::fromGuiGLFormat(const QGuiGLFormat &format)
retFormat.setStencil(true);
retFormat.setStencilBufferSize(format.stencilBufferSize());
}
- retFormat.setDoubleBuffer(format.swapBehavior() != QGuiGLFormat::SingleBuffer);
+ retFormat.setDoubleBuffer(format.swapBehavior() != QSurfaceFormat::SingleBuffer);
retFormat.setStereo(format.stereo());
return retFormat;
}
@@ -86,9 +86,9 @@ QGLFormat QGLFormat::fromGuiGLFormat(const QGuiGLFormat &format)
/*!
Returns a window format for the OpenGL format specified by \a format.
*/
-QGuiGLFormat QGLFormat::toGuiGLFormat(const QGLFormat &format)
+QSurfaceFormat QGLFormat::toSurfaceFormat(const QGLFormat &format)
{
- QGuiGLFormat retFormat;
+ QSurfaceFormat retFormat;
if (format.alpha())
retFormat.setAlphaBufferSize(format.alphaBufferSize() == -1 ? 1 : format.alphaBufferSize());
if (format.blueBufferSize() >= 0)
@@ -99,7 +99,7 @@ QGuiGLFormat QGLFormat::toGuiGLFormat(const QGLFormat &format)
retFormat.setRedBufferSize(format.redBufferSize());
if (format.depth())
retFormat.setDepthBufferSize(format.depthBufferSize() == -1 ? 1 : format.depthBufferSize());
- retFormat.setSwapBehavior(format.doubleBuffer() ? QGuiGLFormat::DoubleBuffer : QGuiGLFormat::DefaultSwapBehavior);
+ retFormat.setSwapBehavior(format.doubleBuffer() ? QSurfaceFormat::DoubleBuffer : QSurfaceFormat::DefaultSwapBehavior);
if (format.sampleBuffers())
retFormat.setSamples(format.samples() == -1 ? 4 : format.samples());
if (format.stencil())
@@ -138,14 +138,12 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
}else {
QWidget *widget = static_cast<QWidget *>(d->paintDevice);
QGLFormat glformat = format();
- QGuiGLFormat winFormat = QGLFormat::toGuiGLFormat(glformat);
+ QSurfaceFormat winFormat = QGLFormat::toSurfaceFormat(glformat);
if (widget->testAttribute(Qt::WA_TranslucentBackground))
winFormat.setAlphaBufferSize(qMax(winFormat.alphaBufferSize(), 8));
- winFormat.setWindowSurface(false);
if (!widget->windowHandle()->handle()) {
- widget->windowHandle()->setSurfaceType(QWindow::OpenGLSurface);
- widget->windowHandle()->setGLFormat(winFormat);
+ widget->windowHandle()->setFormat(winFormat);
widget->winId();//make window
}
@@ -153,7 +151,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
QGuiGLContext *shareGlContext = shareContext ? shareContext->d_func()->guiGlContext : 0;
d->guiGlContext = new QGuiGLContext(winFormat, shareGlContext);
- d->glFormat = QGLFormat::fromGuiGLFormat(d->guiGlContext->format());
+ d->glFormat = QGLFormat::fromSurfaceFormat(d->guiGlContext->format());
d->valid = d->guiGlContext->isValid();
if (d->valid) {
d->guiGlContext->setQGLContextHandle(this,qDeleteQGLContext);
@@ -193,7 +191,7 @@ void QGLContext::makeCurrent()
if (!widget->windowHandle())
return;
- if (d->guiGlContext->makeCurrent(widget->windowHandle()->glSurface())) {
+ if (d->guiGlContext->makeCurrent(widget->windowHandle())) {
if (!d->workaroundsCached) {
d->workaroundsCached = true;
const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
@@ -220,7 +218,7 @@ void QGLContext::swapBuffers() const
if (!widget->windowHandle())
return;
- d->guiGlContext->swapBuffers(widget->windowHandle()->glSurface());
+ d->guiGlContext->swapBuffers(widget->windowHandle());
}
void *QGLContext::getProcAddress(const QString &procName) const
@@ -297,11 +295,10 @@ QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *)
d->window = new QWindow;
d->window->setGeometry(QRect(0, 0, 3, 3));
- d->window->setSurfaceType(QWindow::OpenGLSurface);
d->window->create();
d->context = new QGuiGLContext;
- d->context->makeCurrent(d->window->glSurface());
+ d->context->makeCurrent(d->window);
}
QGLTemporaryContext::~QGLTemporaryContext()
@@ -380,7 +377,7 @@ QGLContext::QGLContext(QGuiGLContext *context)
: d_ptr(new QGLContextPrivate(this))
{
Q_D(QGLContext);
- d->init(0,QGLFormat::fromGuiGLFormat(context->format()));
+ d->init(0, QGLFormat::fromSurfaceFormat(context->format()));
d->guiGlContext = context;
d->guiGlContext->setQGLContextHandle(this,qDeleteQGLContext);
d->valid = context->isValid();
diff --git a/src/platformsupport/eglconvenience/qeglconvenience.cpp b/src/platformsupport/eglconvenience/qeglconvenience.cpp
index a9973b642a..63f564c2d5 100644
--- a/src/platformsupport/eglconvenience/qeglconvenience.cpp
+++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp
@@ -45,7 +45,7 @@
QT_BEGIN_NAMESPACE
-QVector<EGLint> q_createConfigAttributesFromFormat(const QGuiGLFormat &format)
+QVector<EGLint> q_createConfigAttributesFromFormat(const QSurfaceFormat &format)
{
int redSize = format.redBufferSize();
int greenSize = format.greenBufferSize();
@@ -70,7 +70,7 @@ QVector<EGLint> q_createConfigAttributesFromFormat(const QGuiGLFormat &format)
// "AtLeast" for EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are
// put in the list before 32-bit configs. So, to make sure 16-bit is preffered over 32-bit,
// we must set the red/green/blue sizes to zero. This has an unfortunate consequence that
- // if the application sets the red/green/blue size to 5/6/5 on the QGuiGLFormat,
+ // if the application sets the red/green/blue size to 5/6/5 on the QSurfaceFormat,
// they will probably get a 32-bit config, even when there's an RGB565 config available.
// // Now normalize the values so -1 becomes 0
@@ -197,7 +197,7 @@ bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes)
return false;
}
-EGLConfig q_configFromGLFormat(EGLDisplay display, const QGuiGLFormat &format, bool highestPixelFormat, int surfaceType)
+EGLConfig q_configFromGLFormat(EGLDisplay display, const QSurfaceFormat &format, bool highestPixelFormat, int surfaceType)
{
EGLConfig cfg = 0;
QVector<EGLint> configureAttributes = q_createConfigAttributesFromFormat(format);
@@ -259,9 +259,9 @@ EGLConfig q_configFromGLFormat(EGLDisplay display, const QGuiGLFormat &format, b
return 0;
}
-QGuiGLFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config)
+QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config)
{
- QGuiGLFormat format;
+ QSurfaceFormat format;
EGLint redSize = 0;
EGLint greenSize = 0;
EGLint blueSize = 0;
diff --git a/src/platformsupport/eglconvenience/qeglconvenience_p.h b/src/platformsupport/eglconvenience/qeglconvenience_p.h
index 302aba318f..7b5b970415 100644
--- a/src/platformsupport/eglconvenience/qeglconvenience_p.h
+++ b/src/platformsupport/eglconvenience/qeglconvenience_p.h
@@ -43,16 +43,16 @@
#define QEGLCONVENIENCE_H
-#include <QtGui/QGuiGLFormat>
+#include <QtGui/QSurfaceFormat>
#include <QtCore/QVector>
#include <EGL/egl.h>
QT_BEGIN_NAMESPACE
-QVector<EGLint> q_createConfigAttributesFromFormat(const QGuiGLFormat &format);
+QVector<EGLint> q_createConfigAttributesFromFormat(const QSurfaceFormat &format);
bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes);
-EGLConfig q_configFromGLFormat(EGLDisplay display, const QGuiGLFormat &format, bool highestPixelFormat = false, int surfaceType = EGL_WINDOW_BIT);
-QGuiGLFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config);
+EGLConfig q_configFromGLFormat(EGLDisplay display, const QSurfaceFormat &format, bool highestPixelFormat = false, int surfaceType = EGL_WINDOW_BIT);
+QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config);
bool q_hasEglExtension(EGLDisplay display,const char* extensionName);
QT_END_NAMESPACE
diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
index bb2d167c81..0e61dd3486 100644
--- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
+++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
@@ -47,13 +47,7 @@
#include <EGL/egl.h>
-QEGLSurface::QEGLSurface(EGLSurface surface, const QGuiGLFormat &format)
- : QPlatformGLSurface(format)
- , m_eglSurface(surface)
-{
-}
-
-QEGLPlatformContext::QEGLPlatformContext(const QGuiGLFormat &format, QPlatformGLContext *share, EGLDisplay display,
+QEGLPlatformContext::QEGLPlatformContext(const QSurfaceFormat &format, QPlatformGLContext *share, EGLDisplay display,
EGLint eglClientVersion, EGLenum eglApi)
: m_eglDisplay(display)
, m_eglApi(eglApi)
@@ -78,18 +72,18 @@ QEGLPlatformContext::QEGLPlatformContext(const QGuiGLFormat &format, QPlatformGL
}
}
-bool QEGLPlatformContext::makeCurrent(const QPlatformGLSurface &surface)
+bool QEGLPlatformContext::makeCurrent(QPlatformSurface *surface)
{
#ifdef QEGL_EXTRA_DEBUG
qWarning("QEglContext::makeCurrent: %p\n",this);
#endif
eglBindAPI(m_eglApi);
- EGLSurface eglSurface = static_cast<const QEGLSurface &>(surface).eglSurface();
+ EGLSurface eglSurface = eglSurfaceForPlatformSurface(surface);
bool ok = eglMakeCurrent(m_eglDisplay, eglSurface, eglSurface, m_eglContext);
if (!ok)
- qWarning("QEGLPlatformContext::makeCurrent: eglError: %d, this: %p \n", eglGetError(), this);
+ qWarning("QEGLPlatformContext::makeCurrent: eglError: %x, this: %p \n", eglGetError(), this);
#ifdef QEGL_EXTRA_DEBUG
static bool showDebug = true;
if (showDebug) {
@@ -134,13 +128,14 @@ void QEGLPlatformContext::doneCurrent()
qWarning("QEGLPlatformContext::doneCurrent(): eglError: %d, this: %p \n", eglGetError(), this);
}
-void QEGLPlatformContext::swapBuffers(const QPlatformGLSurface &surface)
+void QEGLPlatformContext::swapBuffers(QPlatformSurface *surface)
{
#ifdef QEGL_EXTRA_DEBUG
qWarning("QEglContext::swapBuffers:%p\n",this);
#endif
eglBindAPI(m_eglApi);
- bool ok = eglSwapBuffers(m_eglDisplay, static_cast<const QEGLSurface &>(surface).eglSurface());
+ EGLSurface eglSurface = eglSurfaceForPlatformSurface(surface);
+ bool ok = eglSwapBuffers(m_eglDisplay, eglSurface);
if (!ok)
qWarning("QEGLPlatformContext::swapBuffers(): eglError: %d, this: %p \n", eglGetError(), this);
}
@@ -154,7 +149,7 @@ void (*QEGLPlatformContext::getProcAddress(const QByteArray &procName)) ()
return eglGetProcAddress(procName.constData());
}
-QGuiGLFormat QEGLPlatformContext::format() const
+QSurfaceFormat QEGLPlatformContext::format() const
{
return m_format;
}
diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h
index 9877b77e4e..56a873afcb 100644
--- a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h
+++ b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h
@@ -42,42 +42,35 @@
#ifndef QEGLPLATFORMCONTEXT_H
#define QEGLPLATFORMCONTEXT_H
+#include <QtGui/QPlatformWindow>
#include <QtGui/QPlatformGLContext>
#include <EGL/egl.h>
-class QEGLSurface : public QPlatformGLSurface
-{
-public:
- QEGLSurface(EGLSurface surface, const QGuiGLFormat &format);
-
- virtual EGLSurface eglSurface() const { return m_eglSurface; }
-
-private:
- EGLSurface m_eglSurface;
-};
-
class QEGLPlatformContext : public QPlatformGLContext
{
public:
- QEGLPlatformContext(const QGuiGLFormat &format, QPlatformGLContext *share, EGLDisplay display,
+ QEGLPlatformContext(const QSurfaceFormat &format, QPlatformGLContext *share, EGLDisplay display,
EGLint eglClientVersion = 2, EGLenum eglApi = EGL_OPENGL_ES_API);
~QEGLPlatformContext();
- bool makeCurrent(const QPlatformGLSurface &surface);
+ bool makeCurrent(QPlatformSurface *surface);
void doneCurrent();
- void swapBuffers(const QPlatformGLSurface &surface);
+ void swapBuffers(QPlatformSurface *surface);
void (*getProcAddress(const QByteArray &procName)) ();
- QGuiGLFormat format() const;
+ QSurfaceFormat format() const;
EGLContext eglContext() const;
+protected:
+ virtual EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) = 0;
+
private:
EGLContext m_eglContext;
EGLDisplay m_eglDisplay;
EGLenum m_eglApi;
- QGuiGLFormat m_format;
+ QSurfaceFormat m_format;
};
#endif //QEGLPLATFORMCONTEXT_H
diff --git a/src/platformsupport/glxconvenience/qglxconvenience.cpp b/src/platformsupport/glxconvenience/qglxconvenience.cpp
index fc506df3bd..ce0c49d93f 100644
--- a/src/platformsupport/glxconvenience/qglxconvenience.cpp
+++ b/src/platformsupport/glxconvenience/qglxconvenience.cpp
@@ -70,7 +70,7 @@ enum {
#undef FontChange
#endif
-QVector<int> qglx_buildSpec(const QGuiGLFormat &format, int drawableBit)
+QVector<int> qglx_buildSpec(const QSurfaceFormat &format, int drawableBit)
{
QVector<int> spec(48);
int i = 0;
@@ -88,7 +88,7 @@ QVector<int> qglx_buildSpec(const QGuiGLFormat &format, int drawableBit)
spec[i++] = GLX_ALPHA_SIZE; spec[i++] = format.alphaBufferSize();
}
- spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.swapBehavior() != QGuiGLFormat::SingleBuffer ? True : False;
+ spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.swapBehavior() != QSurfaceFormat::SingleBuffer ? True : False;
spec[i++] = GLX_STEREO; spec[i++] = format.stereo() ? True : False;
@@ -111,11 +111,11 @@ QVector<int> qglx_buildSpec(const QGuiGLFormat &format, int drawableBit)
return spec;
}
-GLXFBConfig qglx_findConfig(Display *display, int screen , const QGuiGLFormat &format, int drawableBit)
+GLXFBConfig qglx_findConfig(Display *display, int screen , const QSurfaceFormat &format, int drawableBit)
{
bool reduced = true;
GLXFBConfig chosenConfig = 0;
- QGuiGLFormat reducedFormat = format;
+ QSurfaceFormat reducedFormat = format;
while (!chosenConfig && reduced) {
QVector<int> spec = qglx_buildSpec(reducedFormat, drawableBit);
int confcount = 0;
@@ -147,7 +147,7 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , const QGuiGLFormat &f
XFree(configs);
}
- reducedFormat = qglx_reduceGuiGLFormat(reducedFormat,&reduced);
+ reducedFormat = qglx_reduceSurfaceFormat(reducedFormat,&reduced);
}
if (!chosenConfig)
@@ -156,16 +156,16 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , const QGuiGLFormat &f
return chosenConfig;
}
-XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QGuiGLFormat &format)
+XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QSurfaceFormat &format)
{
GLXFBConfig config = qglx_findConfig(display,screen,format);
XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display,config);
return visualInfo;
}
-QGuiGLFormat qglx_guiGLFormatFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext)
+QSurfaceFormat qglx_surfaceFormatFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext)
{
- QGuiGLFormat format;
+ QSurfaceFormat format;
int redSize = 0;
int greenSize = 0;
int blueSize = 0;
@@ -203,9 +203,9 @@ QGuiGLFormat qglx_guiGLFormatFromGLXFBConfig(Display *display, GLXFBConfig confi
return format;
}
-QGuiGLFormat qglx_reduceGuiGLFormat(const QGuiGLFormat &format, bool *reduced)
+QSurfaceFormat qglx_reduceSurfaceFormat(const QSurfaceFormat &format, bool *reduced)
{
- QGuiGLFormat retFormat = format;
+ QSurfaceFormat retFormat = format;
*reduced = true;
if (retFormat.samples() > 1) {
diff --git a/src/platformsupport/glxconvenience/qglxconvenience_p.h b/src/platformsupport/glxconvenience/qglxconvenience_p.h
index 1a0510067b..4892b07729 100644
--- a/src/platformsupport/glxconvenience/qglxconvenience_p.h
+++ b/src/platformsupport/glxconvenience/qglxconvenience_p.h
@@ -42,16 +42,16 @@
#ifndef QGLXCONVENIENCE_H
#define QGLXCONVENIENCE_H
-#include <QGuiGLFormat>
+#include <QSurfaceFormat>
#include <QVector>
#include <X11/Xlib.h>
#include <GL/glx.h>
-XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QGuiGLFormat &format);
-GLXFBConfig qglx_findConfig(Display *display, int screen, const QGuiGLFormat &format, int drawableBit = GLX_WINDOW_BIT);
-QGuiGLFormat qglx_guiGLFormatFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context);
-QVector<int> qglx_buildSpec(const QGuiGLFormat &format, int drawableBit = GLX_WINDOW_BIT);
-QGuiGLFormat qglx_reduceGuiGLFormat(const QGuiGLFormat &format, bool *reduced);
+XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QSurfaceFormat &format);
+GLXFBConfig qglx_findConfig(Display *display, int screen, const QSurfaceFormat &format, int drawableBit = GLX_WINDOW_BIT);
+QSurfaceFormat qglx_surfaceFormatFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context);
+QVector<int> qglx_buildSpec(const QSurfaceFormat &format, int drawableBit = GLX_WINDOW_BIT);
+QSurfaceFormat qglx_reduceSurfaceFormat(const QSurfaceFormat &format, bool *reduced);
#endif // QGLXCONVENIENCE_H
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h
index 01d931b662..9af931bf6c 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.h
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h
@@ -10,28 +10,16 @@
QT_BEGIN_NAMESPACE
-class QCocoaGLSurface : public QPlatformGLSurface
-{
-public:
- QCocoaGLSurface(const QGuiGLFormat &format, QWindow *window)
- : QPlatformGLSurface(format)
- , window(window)
- {
- }
-
- QWindow *window;
-};
-
class QCocoaGLContext : public QPlatformGLContext
{
public:
- QCocoaGLContext(const QGuiGLFormat &format, QPlatformGLContext *share);
+ QCocoaGLContext(const QSurfaceFormat &format, QPlatformGLContext *share);
- QGuiGLFormat format() const;
+ QSurfaceFormat format() const;
- void swapBuffers(const QPlatformGLSurface &surface);
+ void swapBuffers(QPlatformSurface *surface);
- bool makeCurrent(const QPlatformGLSurface &surface);
+ bool makeCurrent(QPlatformSurface *surface);
void doneCurrent();
void (*getProcAddress(const QByteArray &procName)) ();
@@ -45,7 +33,7 @@ private:
void setActiveWindow(QWindow *window);
NSOpenGLContext *m_context;
- QGuiGLFormat m_format;
+ QSurfaceFormat m_format;
QWeakPointer<QWindow> m_currentWindow;
};
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index f9cda1bb37..ba8bd423a2 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -5,7 +5,7 @@
#import <Cocoa/Cocoa.h>
-QCocoaGLContext::QCocoaGLContext(const QGuiGLFormat &format, QPlatformGLContext *share)
+QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformGLContext *share)
: m_format(format)
{
NSOpenGLPixelFormat *pixelFormat = createNSOpenGLPixelFormat();
@@ -16,22 +16,22 @@ QCocoaGLContext::QCocoaGLContext(const QGuiGLFormat &format, QPlatformGLContext
}
// Match up with createNSOpenGLPixelFormat!
-QGuiGLFormat QCocoaGLContext::format() const
+QSurfaceFormat QCocoaGLContext::format() const
{
return m_format;
}
-void QCocoaGLContext::swapBuffers(const QPlatformGLSurface &surface)
+void QCocoaGLContext::swapBuffers(QPlatformSurface *surface)
{
- QWindow *window = static_cast<const QCocoaGLSurface &>(surface).window;
+ QWindow *window = static_cast<QCocoaWindow *>(surface)->window();
setActiveWindow(window);
[m_context flushBuffer];
}
-bool QCocoaGLContext::makeCurrent(const QPlatformGLSurface &surface)
+bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface)
{
- QWindow *window = static_cast<const QCocoaGLSurface &>(surface).window;
+ QWindow *window = static_cast<QCocoaWindow *>(surface)->window();
setActiveWindow(window);
[m_context makeCurrentContext];
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h
index 0100fee1bf..56864a4d57 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.h
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.h
@@ -78,7 +78,7 @@ public:
bool hasCapability(QPlatformIntegration::Capability cap) const;
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWindow *window) const;
- QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const;
+ QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const;
QPlatformBackingStore *createPlatformBackingStore(QWindow *widget) const;
QList<QPlatformScreen *> screens() const { return mScreens; }
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index e2a206abc2..474f3a3d5c 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -112,7 +112,7 @@ QPlatformWindow *QCocoaIntegration::createPlatformWindow(QWindow *window) const
return new QCocoaWindow(window);
}
-QPlatformGLContext *QCocoaIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const
+QPlatformGLContext *QCocoaIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const
{
return new QCocoaGLContext(glFormat, share);
}
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 82fd35ee18..9ce449a9af 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -70,8 +70,6 @@ public:
void windowDidMove();
void windowDidResize();
- QPlatformGLSurface *createGLSurface() const;
-
void setCurrentContext(QCocoaGLContext *context);
QCocoaGLContext *currentContext() const;
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 874790a128..444762b8ff 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -157,12 +157,6 @@ void QCocoaWindow::windowDidResize()
m_glContext->update();
}
-QPlatformGLSurface *QCocoaWindow::createGLSurface() const
-{
- Q_ASSERT(window()->surfaceType() == QWindow::OpenGLSurface);
- return new QCocoaGLSurface(window()->glFormat(), window());
-}
-
void QCocoaWindow::setCurrentContext(QCocoaGLContext *context)
{
m_glContext = context;
diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h
index 2960d64eea..2b4f9fe028 100644
--- a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h
+++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h
@@ -47,7 +47,7 @@ class QWaylandDisplay;
class QWindow;
class QPlatformGLContext;
-class QGuiGLFormat;
+class QSurfaceFormat;
class QWaylandGLIntegration
{
@@ -58,7 +58,7 @@ public:
virtual void initialize() = 0;
virtual QWaylandWindow *createEglWindow(QWindow *window) = 0;
- virtual QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const = 0;
+ virtual QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const = 0;
static QWaylandGLIntegration *createGLIntegration(QWaylandDisplay *waylandDisplay);
};
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp
index 7fbe5cc725..773087f513 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp
@@ -86,7 +86,7 @@ QWaylandWindow * QWaylandReadbackEglIntegration::createEglWindow(QWindow *window
return new QWaylandReadbackEglWindow(window, this);
}
-QPlatformGLContext *QWaylandReadbackEglWindow::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const
+QPlatformGLContext *QWaylandReadbackEglWindow::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const
{
return new QWaylandReadbackEglContext(glFormat, share, this);
}
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h
index 8945cdab38..d96e6cface 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h
+++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h
@@ -63,7 +63,7 @@ public:
void initialize();
QWaylandWindow *createEglWindow(QWindow *window);
- QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const;
+ QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const;
QWaylandDisplay *waylandDisplay() const;
Display *xDisplay() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp
index 0ca04187d3..dec2cdd428 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp
@@ -47,16 +47,6 @@
#include <QtGui/QGuiGLContext>
#include <QtCore/QDebug>
-QWaylandReadbackGlxSurface::QWaylandReadbackGlxSurface(QWaylandReadbackGlxWindow *window)
- : m_window(window)
-{
-}
-
-GLXPixmap QWaylandReadbackGlxSurface::glxPixmap() const
-{
- return m_window->glxPixmap();
-}
-
static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type)
{
const int width = img.width();
@@ -79,7 +69,7 @@ static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type)
}
}
-QWaylandReadbackGlxContext::QWaylandReadbackGlxContext(const QGuiGLFormat &format,
+QWaylandReadbackGlxContext::QWaylandReadbackGlxContext(const QSurfaceFormat &format,
QPlatformGLContext *share, Display *display, int screen)
: m_display(display)
{
@@ -89,17 +79,17 @@ QWaylandReadbackGlxContext::QWaylandReadbackGlxContext(const QGuiGLFormat &forma
XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display, config);
m_context = glXCreateContext(display, visualInfo, shareContext, TRUE);
- m_format = qglx_guiGLFormatFromGLXFBConfig(display, config, m_context);
+ m_format = qglx_surfaceFormatFromGLXFBConfig(display, config, m_context);
}
-QGuiGLFormat QWaylandReadbackGlxContext::format() const
+QSurfaceFormat QWaylandReadbackGlxContext::format() const
{
return m_format;
}
-bool QWaylandReadbackGlxContext::makeCurrent(const QPlatformGLSurface &surface)
+bool QWaylandReadbackGlxContext::makeCurrent(QPlatformSurface *surface)
{
- GLXPixmap glxPixmap = static_cast<const QWaylandReadbackGlxSurface &>(surface).glxPixmap();
+ GLXPixmap glxPixmap = static_cast<QWaylandReadbackGlxWindow *>(surface)->glxPixmap();
return glXMakeCurrent(m_display, glxPixmap, m_context);
}
@@ -109,16 +99,15 @@ void QWaylandReadbackGlxContext::doneCurrent()
glXMakeCurrent(m_display, 0, 0);
}
-void QWaylandReadbackGlxContext::swapBuffers(const QPlatformGLSurface &surface)
+void QWaylandReadbackGlxContext::swapBuffers(QPlatformSurface *surface)
{
// #### makeCurrent() directly on the platform context doesn't update QGuiGLContext::currentContext()
if (QGuiGLContext::currentContext()->handle() != this)
makeCurrent(surface);
- const QWaylandReadbackGlxSurface &s =
- static_cast<const QWaylandReadbackGlxSurface &>(surface);
+ QWaylandReadbackGlxWindow *w = static_cast<QWaylandReadbackGlxWindow *>(surface);
- QSize size = s.window()->geometry().size();
+ QSize size = w->geometry().size();
QImage img(size, QImage::Format_ARGB32);
const uchar *constBits = img.bits();
@@ -130,13 +119,13 @@ void QWaylandReadbackGlxContext::swapBuffers(const QPlatformGLSurface &surface)
qgl_byteSwapImage(img, GL_UNSIGNED_INT_8_8_8_8_REV);
constBits = img.bits();
- const uchar *constDstBits = s.window()->buffer();
+ const uchar *constDstBits = w->buffer();
uchar *dstBits = const_cast<uchar *>(constDstBits);
memcpy(dstBits, constBits, (img.width() * 4) * img.height());
- s.window()->damage(QRect(QPoint(), size));
+ w->damage(QRect(QPoint(), size));
- s.window()->waitForFrameSync();
+ w->waitForFrameSync();
}
void (*QWaylandReadbackGlxContext::getProcAddress(const QByteArray &procName)) ()
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h
index 3008c295d3..d3a028f51a 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h
@@ -43,7 +43,7 @@
#define QWAYLANDREADBACKGLXCONTEXT_H
#include <QPlatformGLContext>
-#include <QGuiGLFormat>
+#include <QSurfaceFormat>
#include "qwaylandreadbackglxintegration.h"
@@ -52,28 +52,16 @@
class QWaylandReadbackGlxWindow;
class QWaylandShmBuffer;
-class QWaylandReadbackGlxSurface : public QPlatformGLSurface
-{
-public:
- QWaylandReadbackGlxSurface(QWaylandReadbackGlxWindow *window);
-
- QWaylandReadbackGlxWindow *window() const { return m_window; }
- GLXPixmap glxPixmap() const;
-
-private:
- QWaylandReadbackGlxWindow *m_window;
-};
-
class QWaylandReadbackGlxContext : public QPlatformGLContext
{
public:
- QWaylandReadbackGlxContext(const QGuiGLFormat &format, QPlatformGLContext *share, Display *display, int screen);
+ QWaylandReadbackGlxContext(const QSurfaceFormat &format, QPlatformGLContext *share, Display *display, int screen);
- QGuiGLFormat format() const;
+ QSurfaceFormat format() const;
- void swapBuffers(const QPlatformGLSurface &surface);
+ void swapBuffers(QPlatformSurface *surface);
- bool makeCurrent(const QPlatformGLSurface &surface);
+ bool makeCurrent(QPlatformSurface *surface);
void doneCurrent();
void (*getProcAddress(const QByteArray &procName)) ();
@@ -82,7 +70,7 @@ private:
GLXContext m_context;
Display *m_display;
- QGuiGLFormat m_format;
+ QSurfaceFormat m_format;
};
#endif // QWAYLANDREADBACKGLXCONTEXT_H
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp
index 6fb2a178c8..22ff5dc0c6 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp
@@ -71,7 +71,7 @@ QWaylandWindow * QWaylandReadbackGlxIntegration::createEglWindow(QWindow *window
return new QWaylandReadbackGlxWindow(window,this);
}
-QPlatformGLContext *QWaylandReadbackGlxIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const
+QPlatformGLContext *QWaylandReadbackGlxIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const
{
return new QWaylandReadbackGlxContext(glFormat, share, mDisplay, mScreen);
}
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h
index 0b3d0cc2cc..05c224263b 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h
@@ -61,7 +61,7 @@ public:
void initialize();
QWaylandWindow *createEglWindow(QWindow *window);
- QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const;
+ QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const;
QWaylandDisplay *waylandDisplay() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp
index c7f00280a6..41824b0efd 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp
@@ -86,11 +86,6 @@ uchar *QWaylandReadbackGlxWindow::buffer()
return m_buffer->image()->bits();
}
-QPlatformGLSurface *QWaylandReadbackGlxWindow::createGLSurface() const
-{
- return new QWaylandReadbackGlxSurface(const_cast<QWaylandReadbackGlxWindow *>(this));
-}
-
void QWaylandReadbackGlxWindow::createSurface()
{
QSize size(geometry().size());
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h
index 4f753c660b..c92646c80d 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h
@@ -52,8 +52,6 @@ public:
QWaylandReadbackGlxWindow(QWindow *window, QWaylandReadbackGlxIntegration *glxIntegration);
WindowType windowType() const;
- QPlatformGLSurface *createGLSurface() const;
-
void setGeometry(const QRect &rect);
Pixmap glxPixmap() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp
index c43b675d44..6c1018d79a 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp
@@ -48,31 +48,25 @@
#include <QtPlatformSupport/private/qeglconvenience_p.h>
-QWaylandXCompositeEGLSurface::QWaylandXCompositeEGLSurface(QWaylandXCompositeEGLWindow *window)
- : QEGLSurface(window->eglSurface(), window->window()->glFormat())
- , m_window(window)
-{
-}
-
-EGLSurface QWaylandXCompositeEGLSurface::eglSurface() const
-{
- return m_window->eglSurface();
-}
-
-QWaylandXCompositeEGLContext::QWaylandXCompositeEGLContext(const QGuiGLFormat &format, QPlatformGLContext *share, EGLDisplay display)
+QWaylandXCompositeEGLContext::QWaylandXCompositeEGLContext(const QSurfaceFormat &format, QPlatformGLContext *share, EGLDisplay display)
: QEGLPlatformContext(format, share, display)
{
}
-void QWaylandXCompositeEGLContext::swapBuffers(const QPlatformGLSurface &surface)
+void QWaylandXCompositeEGLContext::swapBuffers(QPlatformSurface *surface)
{
QEGLPlatformContext::swapBuffers(surface);
- const QWaylandXCompositeEGLSurface &s =
- static_cast<const QWaylandXCompositeEGLSurface &>(surface);
+ QWaylandXCompositeEGLWindow *w =
+ static_cast<QWaylandXCompositeEGLWindow *>(surface);
+
+ QSize size = w->geometry().size();
- QSize size = s.window()->geometry().size();
+ w->damage(QRect(QPoint(), size));
+ w->waitForFrameSync();
+}
- s.window()->damage(QRect(QPoint(), size));
- s.window()->waitForFrameSync();
+EGLSurface QWaylandXCompositeEGLContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface)
+{
+ return static_cast<QWaylandXCompositeEGLWindow *>(surface)->eglSurface();
}
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h
index e394ea1a04..f0e96a19af 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h
@@ -50,23 +50,15 @@
class QWaylandXCompositeEGLWindow;
-class QWaylandXCompositeEGLSurface : public QEGLSurface
-{
-public:
- QWaylandXCompositeEGLSurface(QWaylandXCompositeEGLWindow *window);
-
- EGLSurface eglSurface() const;
- QWaylandXCompositeEGLWindow *window() const { return m_window; }
-private:
- QWaylandXCompositeEGLWindow *m_window;
-};
-
class QWaylandXCompositeEGLContext : public QEGLPlatformContext
{
public:
- QWaylandXCompositeEGLContext(const QGuiGLFormat &format, QPlatformGLContext *share, EGLDisplay display);
+ QWaylandXCompositeEGLContext(const QSurfaceFormat &format, QPlatformGLContext *share, EGLDisplay display);
- void swapBuffers(const QPlatformGLSurface &surface);
+ void swapBuffers(QPlatformSurface *surface);
+
+private:
+ EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface);
};
#endif // QWAYLANDXCOMPOSITEEGLCONTEXT_H
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp
index 90d5bea770..47454dccab 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp
@@ -75,7 +75,7 @@ QWaylandWindow * QWaylandXCompositeEGLIntegration::createEglWindow(QWindow *wind
return new QWaylandXCompositeEGLWindow(window,this);
}
-QPlatformGLContext *QWaylandXCompositeEGLIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const
+QPlatformGLContext *QWaylandXCompositeEGLIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const
{
return new QWaylandXCompositeEGLContext(glFormat, share, eglDisplay());
}
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h
index ac302ef89f..1f67bf28e1 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h
@@ -69,7 +69,7 @@ public:
void initialize();
QWaylandWindow *createEglWindow(QWindow *window);
- QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const;
+ QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const;
QWaylandDisplay *waylandDisplay() const;
struct wl_xcomposite *waylandXComposite() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp
index 5e1bab2044..9bf857d734 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp
@@ -57,7 +57,7 @@ QWaylandXCompositeEGLWindow::QWaylandXCompositeEGLWindow(QWindow *window, QWayla
, m_context(0)
, m_buffer(0)
, m_xWindow(0)
- , m_config(q_configFromGLFormat(glxIntegration->eglDisplay(), window->glFormat(), true))
+ , m_config(q_configFromGLFormat(glxIntegration->eglDisplay(), window->format(), true))
, m_surface(0)
, m_waitingForSync(false)
{
@@ -69,11 +69,6 @@ QWaylandWindow::WindowType QWaylandXCompositeEGLWindow::windowType() const
return QWaylandWindow::Egl;
}
-QPlatformGLSurface *QWaylandXCompositeEGLWindow::createGLSurface() const
-{
- return new QWaylandXCompositeEGLSurface(const_cast<QWaylandXCompositeEGLWindow *>(this));
-}
-
void QWaylandXCompositeEGLWindow::setGeometry(const QRect &rect)
{
QWaylandWindow::setGeometry(rect);
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h
index 16188ca3e0..535498a722 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h
@@ -54,8 +54,6 @@ public:
QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLIntegration *glxIntegration);
WindowType windowType() const;
- QPlatformGLSurface *createGLSurface() const;
-
void setGeometry(const QRect &rect);
EGLSurface eglSurface() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp
index 54d63a2bec..20fb0396f8 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp
@@ -47,17 +47,7 @@
#include <QRegion>
-QWaylandXCompositeGLXSurface::QWaylandXCompositeGLXSurface(QWaylandXCompositeGLXWindow *window)
- : m_window(window)
-{
-}
-
-Window QWaylandXCompositeGLXSurface::xWindow() const
-{
- return m_window->xWindow();
-}
-
-QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(const QGuiGLFormat &format, QPlatformGLContext *share, Display *display, int screen)
+QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(const QSurfaceFormat &format, QPlatformGLContext *share, Display *display, int screen)
: m_display(display)
{
qDebug("creating XComposite-GLX context");
@@ -65,12 +55,12 @@ QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(const QGuiGLFormat &f
GLXFBConfig config = qglx_findConfig(display, screen, format);
XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display, config);
m_context = glXCreateContext(display, visualInfo, shareContext, true);
- m_format = qglx_guiGLFormatFromGLXFBConfig(display, config, m_context);
+ m_format = qglx_surfaceFormatFromGLXFBConfig(display, config, m_context);
}
-bool QWaylandXCompositeGLXContext::makeCurrent(const QPlatformGLSurface &surface)
+bool QWaylandXCompositeGLXContext::makeCurrent(QPlatformSurface *surface)
{
- Window xWindow = static_cast<const QWaylandXCompositeGLXSurface &>(surface).xWindow();
+ Window xWindow = static_cast<QWaylandXCompositeGLXWindow *>(surface)->xWindow();
return glXMakeCurrent(m_display, xWindow, m_context);
}
@@ -80,17 +70,16 @@ void QWaylandXCompositeGLXContext::doneCurrent()
glXMakeCurrent(m_display, 0, 0);
}
-void QWaylandXCompositeGLXContext::swapBuffers(const QPlatformGLSurface &surface)
+void QWaylandXCompositeGLXContext::swapBuffers(QPlatformSurface *surface)
{
- const QWaylandXCompositeGLXSurface &s =
- static_cast<const QWaylandXCompositeGLXSurface &>(surface);
+ QWaylandXCompositeGLXWindow *w = static_cast<QWaylandXCompositeGLXWindow *>(surface);
- QSize size = s.window()->geometry().size();
+ QSize size = w->geometry().size();
- glXSwapBuffers(m_display, s.xWindow());
+ glXSwapBuffers(m_display, w->xWindow());
- s.window()->damage(QRect(QPoint(), size));
- s.window()->waitForFrameSync();
+ w->damage(QRect(QPoint(), size));
+ w->waitForFrameSync();
}
void (*QWaylandXCompositeGLXContext::getProcAddress(const QByteArray &procName)) ()
@@ -98,7 +87,7 @@ void (*QWaylandXCompositeGLXContext::getProcAddress(const QByteArray &procName))
return glXGetProcAddress(reinterpret_cast<const GLubyte *>(procName.constData()));
}
-QGuiGLFormat QWaylandXCompositeGLXContext::format() const
+QSurfaceFormat QWaylandXCompositeGLXContext::format() const
{
return m_format;
}
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h
index 39fe03032f..cabdbe1a82 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h
@@ -50,29 +50,16 @@
class QWaylandXCompositeGLXWindow;
class QWaylandShmBuffer;
-class QWaylandXCompositeGLXSurface : public QPlatformGLSurface
-{
-public:
- QWaylandXCompositeGLXSurface(QWaylandXCompositeGLXWindow *window);
-
- QWaylandXCompositeGLXWindow *window() const { return m_window; }
- Window xWindow() const;
-
-private:
- QWaylandXCompositeGLXWindow *m_window;
-};
-
-
class QWaylandXCompositeGLXContext : public QPlatformGLContext
{
public:
- QWaylandXCompositeGLXContext(const QGuiGLFormat &format, QPlatformGLContext *share, Display *display, int screen);
+ QWaylandXCompositeGLXContext(const QSurfaceFormat &format, QPlatformGLContext *share, Display *display, int screen);
- QGuiGLFormat format() const;
+ QSurfaceFormat format() const;
- void swapBuffers(const QPlatformGLSurface &surface);
+ void swapBuffers(QPlatformSurface *surface);
- bool makeCurrent(const QPlatformGLSurface &surface);
+ bool makeCurrent(QPlatformSurface *surface);
void doneCurrent();
void (*getProcAddress(const QByteArray &procName)) ();
@@ -81,7 +68,7 @@ private:
GLXContext m_context;
Display *m_display;
- QGuiGLFormat m_format;
+ QSurfaceFormat m_format;
};
#endif // QWAYLANDXCOMPOSITEGLXCONTEXT_H
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp
index 426c78e5e8..8c27fa1cd8 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp
@@ -78,7 +78,7 @@ QWaylandWindow * QWaylandXCompositeGLXIntegration::createEglWindow(QWindow *wind
return new QWaylandXCompositeGLXWindow(window, this);
}
-QPlatformGLContext *QWaylandXCompositeGLXIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const
+QPlatformGLContext *QWaylandXCompositeGLXIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const
{
return new QWaylandXCompositeGLXContext(glFormat, share, mDisplay, mScreen);
}
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h
index c347b110c6..5a779bf58a 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h
@@ -64,7 +64,7 @@ public:
void initialize();
QWaylandWindow *createEglWindow(QWindow *window);
- QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const;
+ QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const;
QWaylandDisplay *waylandDisplay() const;
struct wl_xcomposite *waylandXComposite() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp
index 797803f4cd..abaf3b16a9 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp
@@ -54,7 +54,7 @@ QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWindow *window, QWayla
: QWaylandWindow(window)
, m_glxIntegration(glxIntegration)
, m_xWindow(0)
- , m_config(qglx_findConfig(glxIntegration->xDisplay(), glxIntegration->screen(), window->glFormat()))
+ , m_config(qglx_findConfig(glxIntegration->xDisplay(), glxIntegration->screen(), window->format()))
, m_buffer(0)
, m_waitingForSync(false)
{
@@ -66,11 +66,6 @@ QWaylandWindow::WindowType QWaylandXCompositeGLXWindow::windowType() const
return QWaylandWindow::Egl;
}
-QPlatformGLSurface *QWaylandXCompositeGLXWindow::createGLSurface() const
-{
- return new QWaylandXCompositeGLXSurface(const_cast<QWaylandXCompositeGLXWindow *>(this));
-}
-
void QWaylandXCompositeGLXWindow::setGeometry(const QRect &rect)
{
QWaylandWindow::setGeometry(rect);
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h
index 7a19c7175a..acf6c8e63e 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h
@@ -56,8 +56,6 @@ public:
QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration);
WindowType windowType() const;
- QPlatformGLSurface *createGLSurface() const;
-
void setGeometry(const QRect &rect);
Window xWindow() const;
diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp
index 9cd79e2978..dc59d37f40 100644
--- a/src/plugins/platforms/wayland/qwaylandintegration.cpp
+++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp
@@ -51,7 +51,7 @@
#include <QtGui/QWindowSystemInterface>
#include <QtGui/QPlatformCursor>
-#include <QtGui/QGuiGLFormat>
+#include <QtGui/QSurfaceFormat>
#include <QtGui/private/qpixmap_raster_p.h>
@@ -100,18 +100,19 @@ QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type)
QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) const
{
#ifdef QT_WAYLAND_GL_SUPPORT
- if (window->surfaceType() == QWindow::OpenGLSurface)
- return mDisplay->eglIntegration()->createEglWindow(window);
-#endif
-
+ return mDisplay->eglIntegration()->createEglWindow(window);
+#else
return new QWaylandShmWindow(window);
+#endif
}
-QPlatformGLContext *QWaylandIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const
+QPlatformGLContext *QWaylandIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const
{
#ifdef QT_WAYLAND_GL_SUPPORT
return mDisplay->eglIntegration()->createPlatformGLContext(glFormat, share);
#else
+ Q_UNUSED(glFormat);
+ Q_UNUSED(share);
return 0;
#endif
}
diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h
index 1e22191ff7..adb8b81ca6 100644
--- a/src/plugins/platforms/wayland/qwaylandintegration.h
+++ b/src/plugins/platforms/wayland/qwaylandintegration.h
@@ -57,7 +57,7 @@ public:
bool hasCapability(QPlatformIntegration::Capability cap) const;
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWindow *window) const;
- QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const;
+ QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const;
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
QList<QPlatformScreen *> screens() const;
diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp
index bd1e61fa4c..ba5e46cab1 100644
--- a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp
+++ b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp
@@ -63,9 +63,3 @@ QWaylandWindow::WindowType QWaylandShmWindow::windowType() const
return QWaylandWindow::Shm;
}
-QPlatformGLSurface * QWaylandShmWindow::glSurface() const
-{
- qWarning("Raster window does not have a GL drawable");
- return 0;
-}
-
diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.h b/src/plugins/platforms/wayland/qwaylandshmwindow.h
index db26c5c928..69d4228daa 100644
--- a/src/plugins/platforms/wayland/qwaylandshmwindow.h
+++ b/src/plugins/platforms/wayland/qwaylandshmwindow.h
@@ -52,7 +52,7 @@ public:
~QWaylandShmWindow();
WindowType windowType() const;
- QPlatformGLSurface *glSurface() const;
+ QSurfaceFormat format() const { return window()->format(); }
};
#endif // QWAYLANDSHMWINDOW_H
diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp
index a47de88141..38f760ede9 100644
--- a/src/plugins/platforms/xcb/qglxintegration.cpp
+++ b/src/plugins/platforms/xcb/qglxintegration.cpp
@@ -59,13 +59,7 @@
#include <dlfcn.h>
#endif
-QGLXSurface::QGLXSurface(GLXDrawable drawable, const QGuiGLFormat &format)
- : QPlatformGLSurface(format)
- , glxDrawable(drawable)
-{
-}
-
-QGLXContext::QGLXContext(QXcbScreen *screen, const QGuiGLFormat &format, QPlatformGLContext *share)
+QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlatformGLContext *share)
: QPlatformGLContext()
, m_screen(screen)
, m_context(0)
@@ -77,7 +71,7 @@ QGLXContext::QGLXContext(QXcbScreen *screen, const QGuiGLFormat &format, QPlatfo
GLXFBConfig config = qglx_findConfig(DISPLAY_FROM_XCB(screen),screen->screenNumber(),format);
m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, shareGlxContext, TRUE);
- m_format = qglx_guiGLFormatFromGLXFBConfig(DISPLAY_FROM_XCB(screen), config, m_context);
+ m_format = qglx_surfaceFormatFromGLXFBConfig(DISPLAY_FROM_XCB(screen), config, m_context);
Q_XCB_NOOP(m_screen->connection());
}
@@ -88,13 +82,15 @@ QGLXContext::~QGLXContext()
Q_XCB_NOOP(m_screen->connection());
}
-bool QGLXContext::makeCurrent(const QPlatformGLSurface &surface)
+bool QGLXContext::makeCurrent(QPlatformSurface *surface)
{
+ Q_ASSERT(surface);
+
Q_XCB_NOOP(m_screen->connection());
- GLXDrawable glxSurface = static_cast<const QGLXSurface &>(surface).glxDrawable;
+ GLXDrawable glxDrawable = static_cast<QXcbWindow *>(surface)->xcb_window();
- bool result = glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), glxSurface, m_context);
+ bool result = glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), glxDrawable, m_context);
Q_XCB_NOOP(m_screen->connection());
return result;
@@ -105,10 +101,10 @@ void QGLXContext::doneCurrent()
glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), 0, 0);
}
-void QGLXContext::swapBuffers(const QPlatformGLSurface &drawable)
+void QGLXContext::swapBuffers(QPlatformSurface *surface)
{
Q_XCB_NOOP(m_screen->connection());
- GLXDrawable glxDrawable = static_cast<const QGLXSurface &>(drawable).glxDrawable;
+ GLXDrawable glxDrawable = static_cast<QXcbWindow *>(surface)->xcb_window();
glXSwapBuffers(DISPLAY_FROM_XCB(m_screen), glxDrawable);
Q_XCB_NOOP(m_screen->connection());
}
@@ -147,7 +143,7 @@ void (*QGLXContext::getProcAddress(const QByteArray &procName)) ()
return (void (*)())glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName.constData()));
}
-QGuiGLFormat QGLXContext::format() const
+QSurfaceFormat QGLXContext::format() const
{
return m_format;
}
diff --git a/src/plugins/platforms/xcb/qglxintegration.h b/src/plugins/platforms/xcb/qglxintegration.h
index ae95e23b81..b431a45741 100644
--- a/src/plugins/platforms/xcb/qglxintegration.h
+++ b/src/plugins/platforms/xcb/qglxintegration.h
@@ -43,40 +43,34 @@
#define QGLXINTEGRATION_H
#include "qxcbwindow.h"
+#include "qxcbscreen.h"
#include <QtGui/QPlatformGLContext>
-#include <QtGui/QGuiGLFormat>
+#include <QtGui/QSurfaceFormat>
#include <QtCore/QMutex>
#include <GL/glx.h>
-class QGLXSurface : public QPlatformGLSurface
-{
-public:
- QGLXSurface(GLXDrawable drawable, const QGuiGLFormat &format);
- GLXDrawable glxDrawable;
-};
-
class QGLXContext : public QPlatformGLContext
{
public:
- QGLXContext(QXcbScreen *xd, const QGuiGLFormat &format, QPlatformGLContext *share);
+ QGLXContext(QXcbScreen *xd, const QSurfaceFormat &format, QPlatformGLContext *share);
~QGLXContext();
- bool makeCurrent(const QPlatformGLSurface &surface);
+ bool makeCurrent(QPlatformSurface *surface);
void doneCurrent();
- void swapBuffers(const QPlatformGLSurface &surface);
+ void swapBuffers(QPlatformSurface *surface);
void (*getProcAddress(const QByteArray &procName)) ();
- QGuiGLFormat format() const;
+ QSurfaceFormat format() const;
GLXContext glxContext() const { return m_context; }
private:
QXcbScreen *m_screen;
GLXContext m_context;
- QGuiGLFormat m_format;
+ QSurfaceFormat m_format;
};
#endif
diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
index 24ec65fb47..3def577462 100644
--- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
@@ -260,7 +260,7 @@ void QXcbBackingStore::resize(const QSize &size, const QRegion &)
QXcbWindow* win = static_cast<QXcbWindow *>(window()->handle());
delete m_image;
- m_image = new QXcbShmImage(screen, size, win->depth(), win->format());
+ m_image = new QXcbShmImage(screen, size, win->depth(), win->imageFormat());
Q_XCB_NOOP(connection());
m_syncingResize = true;
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index d6460339a2..ac8a900d66 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -39,6 +39,9 @@
**
****************************************************************************/
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtCore/QDebug>
+
#include "qxcbconnection.h"
#include "qxcbkeyboard.h"
#include "qxcbscreen.h"
@@ -49,11 +52,8 @@
#include <QtAlgorithms>
#include <QSocketNotifier>
-#include <QtGui/private/qguiapplication_p.h>
#include <QAbstractEventDispatcher>
-#include <QtCore/QDebug>
-
#include <stdio.h>
#include <errno.h>
#include <xcb/xfixes.h>
@@ -108,7 +108,7 @@ QXcbConnection::QXcbConnection(const char *displayName)
m_has_egl = eglInitialize(eglDisplay,&major,&minor);
#endif //XCB_USE_EGL
#else
- m_connection = xcb_connect(m_displayName.constData(), &primaryScreen);
+ m_connection = xcb_connect(m_displayName.constData(), &m_primaryScreen);
#endif //XCB_USE_XLIB
xcb_prefetch_extension_data (m_connection, &xcb_xfixes_id);
diff --git a/src/plugins/platforms/xcb/qxcbeglsurface.h b/src/plugins/platforms/xcb/qxcbeglsurface.h
new file mode 100644
index 0000000000..a1e6c148a2
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbeglsurface.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** 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 plugins 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 QXCBEGLSURFACE_H
+#define QXCBEGLSURFACE_H
+
+#include <EGL/egl.h>
+
+class QXcbEGLSurface
+{
+public:
+ QXcbEGLSurface(EGLDisplay display, EGLSurface surface)
+ : m_display(display)
+ , m_surface(surface)
+ {
+ }
+
+ ~QXcbEGLSurface()
+ {
+ eglDestroySurface(m_display, m_surface);
+ }
+
+ EGLSurface surface() const { return m_surface; }
+
+private:
+ EGLDisplay m_display;
+ EGLSurface m_surface;
+};
+
+#endif
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index 72d0036a3c..d5f7c70ad2 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.cpp
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -66,6 +66,7 @@
#if defined(XCB_USE_GLX)
#include "qglxintegration.h"
#elif defined(XCB_USE_EGL)
+#include "qxcbeglsurface.h"
#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
#endif
@@ -103,12 +104,28 @@ QPlatformWindow *QXcbIntegration::createPlatformWindow(QWindow *window) const
return new QXcbWindow(window);
}
-QPlatformGLContext *QXcbIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const
+#if defined(XCB_USE_EGL)
+class QEGLXcbPlatformContext : public QEGLPlatformContext
+{
+public:
+ QEGLXcbPlatformContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share, EGLDisplay display)
+ : QEGLPlatformContext(glFormat, share, display)
+ {
+ }
+
+ EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface)
+ {
+ return static_cast<QXcbWindow *>(surface)->eglSurface()->surface();
+ }
+};
+#endif
+
+QPlatformGLContext *QXcbIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const
{
#if defined(XCB_USE_GLX)
return new QGLXContext(static_cast<QXcbScreen *>(m_screens.at(0)), glFormat, share);
#elif defined(XCB_USE_EGL)
- return new QEGLPlatformContext(glFormat, share, m_connection->egl_display());
+ return new QEGLXcbPlatformContext(glFormat, share, m_connection->egl_display());
#elif defined(XCB_USE_DRI2)
return new QDri2Context(glFormat, share);
#endif
diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h
index 5837be1148..a839b78caa 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.h
+++ b/src/plugins/platforms/xcb/qxcbintegration.h
@@ -58,7 +58,7 @@ public:
bool hasCapability(Capability cap) const;
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWindow *window) const;
- QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const;
+ QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const;
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
QList<QPlatformScreen *> screens() const;
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 547a93be0b..f63cbe25e6 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -71,7 +71,7 @@
#include "qglxintegration.h"
#include <QtPlatformSupport/private/qglxconvenience_p.h>
#elif defined(XCB_USE_EGL)
-#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
+#include "qxcbeglsurface.h"
#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QtPlatformSupport/private/qxlibeglintegration_p.h>
#endif
@@ -98,6 +98,9 @@ QXcbWindow::QXcbWindow(QWindow *window)
, m_syncCounter(0)
, m_mapped(false)
, m_netWmUserTimeWindow(XCB_NONE)
+#if defined(XCB_USE_EGL)
+ , m_eglSurface(0)
+#endif
{
m_screen = static_cast<QXcbScreen *>(QGuiApplicationPrivate::platformIntegration()->screens().at(0));
@@ -120,7 +123,7 @@ void QXcbWindow::create()
if (type == Qt::Desktop) {
m_window = m_screen->root();
m_depth = m_screen->screen()->root_depth;
- m_format = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
+ m_imageFormat = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
connection()->addWindow(m_window, this);
return;
}
@@ -155,17 +158,18 @@ void QXcbWindow::create()
if (parent())
xcb_parent_id = static_cast<QXcbWindow *>(parent())->xcb_window();
+ m_requestedFormat = window()->format();
+
#if defined(XCB_USE_GLX) || defined(XCB_USE_EGL)
- if ((window()->surfaceType() == QWindow::OpenGLSurface
- && QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
- || window()->glFormat().hasAlpha())
+ if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)
+ || window()->format().hasAlpha())
{
#if defined(XCB_USE_GLX)
- XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), window()->glFormat());
+ XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), window()->format());
#elif defined(XCB_USE_EGL)
EGLDisplay eglDisplay = connection()->egl_display();
- EGLConfig eglConfig = q_configFromGLFormat(eglDisplay, window()->glFormat(), true);
+ EGLConfig eglConfig = q_configFromGLFormat(eglDisplay, window()->format(), true);
VisualID id = QXlibEglIntegration::getCompatibleVisualId(DISPLAY_FROM_XCB(this), eglDisplay, eglConfig);
XVisualInfo visualInfoTemplate;
@@ -178,7 +182,7 @@ void QXcbWindow::create()
#endif //XCB_USE_GLX
if (visualInfo) {
m_depth = visualInfo->depth;
- m_format = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
+ m_imageFormat = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(this), xcb_parent_id, visualInfo->visual, AllocNone);
XSetWindowAttributes a;
@@ -196,7 +200,7 @@ void QXcbWindow::create()
{
m_window = xcb_generate_id(xcb_connection());
m_depth = m_screen->screen()->root_depth;
- m_format = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
+ m_imageFormat = (m_depth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
Q_XCB_CALL(xcb_create_window(xcb_connection(),
XCB_COPY_FROM_PARENT, // depth -- same as root
@@ -291,6 +295,11 @@ void QXcbWindow::destroy()
Q_XCB_CALL(xcb_destroy_window(xcb_connection(), m_window));
}
m_mapped = false;
+
+#if defined(XCB_USE_EGL)
+ delete m_eglSurface;
+ m_eglSurface = 0;
+#endif
}
void QXcbWindow::setGeometry(const QRect &rect)
@@ -1028,28 +1037,26 @@ void QXcbWindow::requestActivateWindow()
connection()->sync();
}
-QPlatformGLSurface *QXcbWindow::createGLSurface() const
+QSurfaceFormat QXcbWindow::format() const
{
- if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) {
- qWarning() << "QXcb::createGLSurface() called without OpenGL support";
- return 0;
- }
-
- QGuiGLFormat format = window()->glFormat();
+ // ### return actual format
+ return m_requestedFormat;
+}
-#if defined(XCB_USE_GLX)
- return new QGLXSurface(m_window, format);
-#elif defined(XCB_USE_EGL)
- EGLDisplay display = connection()->egl_display();
- EGLConfig config = q_configFromGLFormat(display, format, true);
+#if defined(XCB_USE_EGL)
+QXcbEGLSurface *QXcbWindow::eglSurface() const
+{
+ if (!m_eglSurface) {
+ EGLDisplay display = connection()->egl_display();
+ EGLConfig config = q_configFromGLFormat(display, window()->format(), true);
+ EGLSurface surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType)m_window, 0);
- EGLSurface eglSurface = eglCreateWindowSurface(display, config, (EGLNativeWindowType)m_window, 0);
+ m_eglSurface = new QXcbEGLSurface(display, surface);
+ }
- return new QEGLSurface(eglSurface, window()->glFormat());
-#else
- return 0;
-#endif
+ return m_eglSurface;
}
+#endif
void QXcbWindow::handleExposeEvent(const xcb_expose_event_t *event)
{
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
index 501e9a33c4..89be3b78b2 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -43,7 +43,7 @@
#define QXCBWINDOW_H
#include <QtGui/QPlatformWindow>
-#include <QtGui/QGuiGLFormat>
+#include <QtGui/QSurfaceFormat>
#include <QtGui/QImage>
#include <xcb/xcb.h>
@@ -52,6 +52,7 @@
#include "qxcbobject.h"
class QXcbScreen;
+class QXcbEGLSurface;
class QXcbWindow : public QXcbObject, public QPlatformWindow
{
@@ -74,8 +75,6 @@ public:
void lower();
void propagateSizeHints();
- QPlatformGLSurface *createGLSurface() const;
-
void requestActivateWindow();
bool setKeyboardGrabEnabled(bool grab);
@@ -83,9 +82,11 @@ public:
void setCursor(xcb_cursor_t cursor);
+ QSurfaceFormat format() const;
+
xcb_window_t xcb_window() const { return m_window; }
uint depth() const { return m_depth; }
- QImage::Format format() const { return m_format; }
+ QImage::Format imageFormat() const { return m_imageFormat; }
void handleExposeEvent(const xcb_expose_event_t *event);
void handleClientMessageEvent(const xcb_client_message_event_t *event);
@@ -107,6 +108,10 @@ public:
void updateNetWmUserTime(xcb_timestamp_t timestamp);
void netWmUserTime() const;
+#if defined(XCB_USE_EGL)
+ QXcbEGLSurface *eglSurface() const;
+#endif
+
private:
void changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0);
QVector<xcb_atom_t> getNetWmState();
@@ -119,7 +124,6 @@ private:
void updateMotifWmHintsBeforeMap();
void updateNetWmStateBeforeMap();
-
void create();
void destroy();
@@ -131,7 +135,7 @@ private:
xcb_window_t m_window;
uint m_depth;
- QImage::Format m_format;
+ QImage::Format m_imageFormat;
xcb_sync_int64_t m_syncValue;
xcb_sync_counter_t m_syncCounter;
@@ -142,8 +146,14 @@ private:
bool m_mapped;
xcb_window_t m_netWmUserTimeWindow;
+ QSurfaceFormat m_requestedFormat;
+
mutable bool m_dirtyFrameMargins;
mutable QMargins m_frameMargins;
+
+#if defined(XCB_USE_EGL)
+ mutable QXcbEGLSurface *m_eglSurface;
+#endif
};
#endif
diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro
index 8cf7ec4aff..33a7494133 100644
--- a/src/plugins/platforms/xcb/xcb.pro
+++ b/src/plugins/platforms/xcb/xcb.pro
@@ -67,6 +67,7 @@ contains(QT_CONFIG, opengl) {
contains(QT_CONFIG, opengles2) {
DEFINES += XCB_USE_EGL
LIBS += -lEGL
+ HEADERS += qxcbeglsurface.h
} else {
DEFINES += XCB_USE_GLX
HEADERS += qglxintegration.h
diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp
index 9aa7e5afb6..5051b38185 100644
--- a/src/widgets/kernel/qwidget_qpa.cpp
+++ b/src/widgets/kernel/qwidget_qpa.cpp
@@ -48,7 +48,7 @@
#include "private/qapplication_p.h"
#include "QtWidgets/qdesktopwidget.h"
#include "QtGui/qplatformwindow_qpa.h"
-#include "QtGui/qguiglformat_qpa.h"
+#include "QtGui/qsurfaceformat.h"
#include "QtGui/qplatformglcontext_qpa.h"
#include "QtGui/private/qwindow_p.h"
@@ -106,9 +106,9 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
win->setGeometry(q->geometry());
if (q->testAttribute(Qt::WA_TranslucentBackground)) {
- QGuiGLFormat format;
+ QSurfaceFormat format;
format.setAlphaBufferSize(8);
- win->setGLFormat(format);
+ win->setFormat(format);
}
if (QWidget *nativeParent = q->nativeParentWidget()) {