diff options
Diffstat (limited to 'src/plugins/platforms')
41 files changed, 244 insertions, 258 deletions
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 |