m_context = new QGuiGLContext(m_format);
}
-QGuiGLFormat Renderer::format() const
+QSurfaceFormat Renderer::format() const
{
return m_format;
}
: m_colorIndex(0)
, m_renderer(renderer)
{
- setSurfaceType(OpenGLSurface);
setWindowTitle(QLatin1String("Hello Window"));
- setGLFormat(renderer->format());
+ setFormat(renderer->format());
setGeometry(QRect(10, 10, 640, 480));
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();
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();
int colorUniform;
bool m_initialized;
- QGuiGLFormat m_format;
+ QSurfaceFormat m_format;
QGuiGLContext *m_context;
};
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 \
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
/*!
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);
/*!
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)
return true;
}
- if (d->platformGLContext->makeCurrent(*surface)) {
+ if (!surface->surfaceHandle())
+ return false;
+
+ if (d->platformGLContext->makeCurrent(surface->surfaceHandle())) {
QGuiGLContextPrivate::setCurrentContext(this);
return true;
}
QGuiGLContextPrivate::setCurrentContext(0);
}
-void QGuiGLContext::swapBuffers(QPlatformGLSurface *surface)
+void QGuiGLContext::swapBuffers(QSurface *surface)
{
Q_D(QGuiGLContext);
if (!d->platformGLContext)
return;
}
- d->platformGLContext->swapBuffers(*surface);
+ d->platformGLContext->swapBuffers(surface->surfaceHandle());
}
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();
}
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;
**
****************************************************************************/
-#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
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
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;
QT_END_HEADER
-#endif // QPLATFORM_GL_CONTEXT_H
+#endif // QPLATFORMGLCONTEXT_H
*/
-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;
#include <QtGui/qwindowdefs.h>
#include <QtGui/private/qpixmapdata_p.h>
#include <QtGui/qplatformscreen_qpa.h>
+#include <QtGui/qsurfaceformat.h>
QT_BEGIN_HEADER
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;
*/
QPlatformWindow::QPlatformWindow(QWindow *window)
- : d_ptr(new QPlatformWindowPrivate)
+ : QPlatformSurface(QSurface::Window)
+ , d_ptr(new QPlatformWindowPrivate)
{
Q_D(QPlatformWindow);
d->window = window;
}
/*!
+ 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
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);
#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
class QPlatformWindowPrivate;
class QWindow;
-class QPlatformGLSurface;
-class Q_GUI_EXPORT QPlatformWindow
+class Q_GUI_EXPORT QPlatformWindow : public QPlatformSurface
{
Q_DECLARE_PRIVATE(QPlatformWindow)
public:
QWindow *window() const;
QPlatformWindow *parent() const;
+ virtual QSurfaceFormat format() const;
+
virtual void setGeometry(const QRect &rect);
virtual QRect geometry() const;
virtual void setOpacity(qreal level);
virtual void requestActivateWindow();
- virtual QPlatformGLSurface *createGLSurface() const;
-
virtual bool setKeyboardGrabEnabled(bool grab);
virtual bool setMouseGrabEnabled(bool grab);
**
****************************************************************************/
-#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),
}
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;
Constructs a copy of \a other.
*/
-QGuiGLFormat::QGuiGLFormat(const QGuiGLFormat &other)
+QSurfaceFormat::QSurfaceFormat(const QSurfaceFormat &other)
{
d = other.d;
d->ref.ref();
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();
}
/*!
- 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.
\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;
}
}
\sa setSampleBuffers(), sampleBuffers(), setSamples()
*/
-int QGuiGLFormat::samples() const
+int QSurfaceFormat::samples() const
{
return d->numSamples;
}
\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;
\sa setOption()
*/
-bool QGuiGLFormat::testOption(QGuiGLFormat::FormatOptions opt) const
+bool QSurfaceFormat::testOption(QSurfaceFormat::FormatOptions opt) const
{
return d->opts & opt;
}
\sa depthBufferSize(), setDepth(), depth()
*/
-void QGuiGLFormat::setDepthBufferSize(int size)
+void QSurfaceFormat::setDepthBufferSize(int size)
{
detach();
d->depthSize = 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;
}
\sa stencilBufferSize(), setStencil(), stencil()
*/
-void QGuiGLFormat::setStencilBufferSize(int size)
+void QSurfaceFormat::setStencilBufferSize(int size)
{
detach();
d->stencilSize = 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
/*!
- 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
** $QT_END_LICENSE$
**
****************************************************************************/
-#ifndef QGUIGLFORMAT_QPA_H
-#define QGUIGLFORMAT_QPA_H
+#ifndef QSURFACEFORMAT_H
+#define QSURFACEFORMAT_H
#include <qglobal.h>
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)
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;
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
#include "qwindow.h"
#include "qplatformwindow_qpa.h"
-#include "qguiglformat_qpa.h"
+#include "qsurfaceformat.h"
#include "qplatformglcontext_qpa.h"
#include "qguiglcontext_qpa.h"
QWindow::QWindow(QWindow *parent)
: QObject(*new QWindowPrivate(), parent)
+ , QSurface(QSurface::Window)
{
Q_D(QWindow);
d->parentWindow = parent;
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);
void QWindow::destroy()
{
Q_D(QWindow);
- delete d->glSurface;
delete d->platformWindow;
- d->glSurface = 0;
d->platformWindow = 0;
}
return d->platformWindow;
}
+QPlatformSurface *QWindow::surfaceHandle() const
+{
+ Q_D(const QWindow);
+ return d->platformWindow;
+}
bool QWindow::setKeyboardGrabEnabled(bool grab)
{
#include <QtCore/QEvent>
#include <QtCore/QMargins>
-#include <QtGui/qguiglformat_qpa.h>
+#include <QtGui/qsurfaceformat.h>
#include <QtGui/qwindowdefs.h>
QT_BEGIN_HEADER
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)
Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle)
public:
- enum SurfaceType {
- RasterSurface,
- OpenGLSurface
- };
-
QWindow(QWindow *parent = 0);
virtual ~QWindow();
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;
#endif
private:
+ QPlatformSurface *surfaceHandle() const;
+
Q_DISABLE_COPY(QWindow)
friend class QGuiApplication;
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)
}
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;
#include <QtCore/qmap.h>
#include <QtCore/qscopedpointer.h>
-#ifdef Q_WS_QPA
-#include <QtGui/QGuiGLFormat>
-#endif
+#include <QtGui/QSurfaceFormat>
QT_BEGIN_HEADER
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;
#include <private/qapplication_p.h>
#include <QtGui/QPlatformGLContext>
#include <QtGui/QPlatformWindow>
-#include <QtGui/QGuiGLFormat>
+#include <QtGui/QSurfaceFormat>
#include "qgl.h"
#include "qgl_p.h"
/*!
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)
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;
}
/*!
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)
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())
}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
}
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);
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));
if (!widget->windowHandle())
return;
- d->guiGlContext->swapBuffers(widget->windowHandle()->glSurface());
+ d->guiGlContext->swapBuffers(widget->windowHandle());
}
void *QGLContext::getProcAddress(const QString &procName) const
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()
: 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();
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();
// "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
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);
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;
#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
#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)
}
}
-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) {
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);
}
return eglGetProcAddress(procName.constData());
}
-QGuiGLFormat QEGLPlatformContext::format() const
+QSurfaceFormat QEGLPlatformContext::format() const
{
return m_format;
}
#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
#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;
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;
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;
XFree(configs);
}
- reducedFormat = qglx_reduceGuiGLFormat(reducedFormat,&reduced);
+ reducedFormat = qglx_reduceSurfaceFormat(reducedFormat,&reduced);
}
if (!chosenConfig)
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;
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) {
#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
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)) ();
void setActiveWindow(QWindow *window);
NSOpenGLContext *m_context;
- QGuiGLFormat m_format;
+ QSurfaceFormat m_format;
QWeakPointer<QWindow> m_currentWindow;
};
#import <Cocoa/Cocoa.h>
-QCocoaGLContext::QCocoaGLContext(const QGuiGLFormat &format, QPlatformGLContext *share)
+QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformGLContext *share)
: m_format(format)
{
NSOpenGLPixelFormat *pixelFormat = createNSOpenGLPixelFormat();
}
// 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];
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; }
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);
}
void windowDidMove();
void windowDidResize();
- QPlatformGLSurface *createGLSurface() const;
-
void setCurrentContext(QCocoaGLContext *context);
QCocoaGLContext *currentContext() const;
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;
class QWindow;
class QPlatformGLContext;
-class QGuiGLFormat;
+class QSurfaceFormat;
class QWaylandGLIntegration
{
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);
};
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);
}
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;
#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();
}
}
-QWaylandReadbackGlxContext::QWaylandReadbackGlxContext(const QGuiGLFormat &format,
+QWaylandReadbackGlxContext::QWaylandReadbackGlxContext(const QSurfaceFormat &format,
QPlatformGLContext *share, Display *display, int screen)
: m_display(display)
{
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);
}
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();
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)) ()
#define QWAYLANDREADBACKGLXCONTEXT_H
#include <QPlatformGLContext>
-#include <QGuiGLFormat>
+#include <QSurfaceFormat>
#include "qwaylandreadbackglxintegration.h"
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)) ();
GLXContext m_context;
Display *m_display;
- QGuiGLFormat m_format;
+ QSurfaceFormat m_format;
};
#endif // QWAYLANDREADBACKGLXCONTEXT_H
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);
}
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;
return m_buffer->image()->bits();
}
-QPlatformGLSurface *QWaylandReadbackGlxWindow::createGLSurface() const
-{
- return new QWaylandReadbackGlxSurface(const_cast<QWaylandReadbackGlxWindow *>(this));
-}
-
void QWaylandReadbackGlxWindow::createSurface()
{
QSize size(geometry().size());
QWaylandReadbackGlxWindow(QWindow *window, QWaylandReadbackGlxIntegration *glxIntegration);
WindowType windowType() const;
- QPlatformGLSurface *createGLSurface() const;
-
void setGeometry(const QRect &rect);
Pixmap glxPixmap() const;
#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();
}
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
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());
}
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;
, 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)
{
return QWaylandWindow::Egl;
}
-QPlatformGLSurface *QWaylandXCompositeEGLWindow::createGLSurface() const
-{
- return new QWaylandXCompositeEGLSurface(const_cast<QWaylandXCompositeEGLWindow *>(this));
-}
-
void QWaylandXCompositeEGLWindow::setGeometry(const QRect &rect)
{
QWaylandWindow::setGeometry(rect);
QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLIntegration *glxIntegration);
WindowType windowType() const;
- QPlatformGLSurface *createGLSurface() const;
-
void setGeometry(const QRect &rect);
EGLSurface eglSurface() const;
#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");
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);
}
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)) ()
return glXGetProcAddress(reinterpret_cast<const GLubyte *>(procName.constData()));
}
-QGuiGLFormat QWaylandXCompositeGLXContext::format() const
+QSurfaceFormat QWaylandXCompositeGLXContext::format() const
{
return m_format;
}
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)) ();
GLXContext m_context;
Display *m_display;
- QGuiGLFormat m_format;
+ QSurfaceFormat m_format;
};
#endif // QWAYLANDXCOMPOSITEGLXCONTEXT_H
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);
}
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;
: 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)
{
return QWaylandWindow::Egl;
}
-QPlatformGLSurface *QWaylandXCompositeGLXWindow::createGLSurface() const
-{
- return new QWaylandXCompositeGLXSurface(const_cast<QWaylandXCompositeGLXWindow *>(this));
-}
-
void QWaylandXCompositeGLXWindow::setGeometry(const QRect &rect)
{
QWaylandWindow::setGeometry(rect);
QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration);
WindowType windowType() const;
- QPlatformGLSurface *createGLSurface() const;
-
void setGeometry(const QRect &rect);
Window xWindow() const;
#include <QtGui/QWindowSystemInterface>
#include <QtGui/QPlatformCursor>
-#include <QtGui/QGuiGLFormat>
+#include <QtGui/QSurfaceFormat>
#include <QtGui/private/qpixmap_raster_p.h>
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
}
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;
return QWaylandWindow::Shm;
}
-QPlatformGLSurface * QWaylandShmWindow::glSurface() const
-{
- qWarning("Raster window does not have a GL drawable");
- return 0;
-}
-
~QWaylandShmWindow();
WindowType windowType() const;
- QPlatformGLSurface *glSurface() const;
+ QSurfaceFormat format() const { return window()->format(); }
};
#endif // QWAYLANDSHMWINDOW_H
#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)
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());
}
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;
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());
}
return (void (*)())glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName.constData()));
}
-QGuiGLFormat QGLXContext::format() const
+QSurfaceFormat QGLXContext::format() const
{
return m_format;
}
#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
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;
**
****************************************************************************/
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtCore/QDebug>
+
#include "qxcbconnection.h"
#include "qxcbkeyboard.h"
#include "qxcbscreen.h"
#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>
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);
--- /dev/null
+/****************************************************************************
+**
+** 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
#if defined(XCB_USE_GLX)
#include "qglxintegration.h"
#elif defined(XCB_USE_EGL)
+#include "qxcbeglsurface.h"
#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
#endif
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
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;
#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
, 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));
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;
}
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;
#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;
{
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
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)
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)
{
#define QXCBWINDOW_H
#include <QtGui/QPlatformWindow>
-#include <QtGui/QGuiGLFormat>
+#include <QtGui/QSurfaceFormat>
#include <QtGui/QImage>
#include <xcb/xcb.h>
#include "qxcbobject.h"
class QXcbScreen;
+class QXcbEGLSurface;
class QXcbWindow : public QXcbObject, public QPlatformWindow
{
void lower();
void propagateSizeHints();
- QPlatformGLSurface *createGLSurface() const;
-
void requestActivateWindow();
bool setKeyboardGrabEnabled(bool grab);
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);
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();
void updateMotifWmHintsBeforeMap();
void updateNetWmStateBeforeMap();
-
void create();
void destroy();
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;
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
contains(QT_CONFIG, opengles2) {
DEFINES += XCB_USE_EGL
LIBS += -lEGL
+ HEADERS += qxcbeglsurface.h
} else {
DEFINES += XCB_USE_GLX
HEADERS += qglxintegration.h
#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"
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()) {