summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/platforms/eglconvenience/qeglconvenience.h4
-rw-r--r--src/plugins/platforms/wayland/gl_integration/gl_integration.pri13
-rw-r--r--src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.cpp11
-rw-r--r--src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h20
-rw-r--r--src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp (renamed from src/plugins/platforms/wayland/qwaylanddrmsurface.cpp)16
-rw-r--r--src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h (renamed from src/plugins/platforms/wayland/qwaylanddrmsurface.h)7
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglinclude.h16
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp48
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h32
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp (renamed from src/plugins/platforms/wayland/qwaylandeglwindow.cpp)13
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h (renamed from src/plugins/platforms/wayland/qwaylandeglwindow.h)3
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp (renamed from src/plugins/platforms/wayland/qwaylandglcontext.cpp)32
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h (renamed from src/plugins/platforms/wayland/qwaylandglcontext.h)12
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri12
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.cpp30
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.h17
-rw-r--r--src/plugins/platforms/wayland/qwaylandinclude.h63
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration.cpp14
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow.h1
-rw-r--r--src/plugins/platforms/wayland/wayland.pro18
20 files changed, 224 insertions, 158 deletions
diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.h b/src/plugins/platforms/eglconvenience/qeglconvenience.h
index 8668095..fab1cb0 100644
--- a/src/plugins/platforms/eglconvenience/qeglconvenience.h
+++ b/src/plugins/platforms/eglconvenience/qeglconvenience.h
@@ -46,11 +46,7 @@
#include <QtGui/QPlatformWindowFormat>
#include <QtCore/QVector>
-#ifdef Q_PLATFORM_WAYLAND
-#include "qwaylandinclude.h"
-#else
#include <EGL/egl.h>
-#endif
QT_BEGIN_NAMESPACE
QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format);
diff --git a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri
new file mode 100644
index 0000000..8a792a5
--- /dev/null
+++ b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri
@@ -0,0 +1,13 @@
+HEADERS += \
+ $$PWD/qwaylandglintegration.h \
+ $$PWD/qwaylandglwindowsurface.h
+
+SOURCES += \
+ $$PWD/qwaylandglintegration.cpp \
+ $$PWD/qwaylandglwindowsurface.cpp
+
+wayland_egl {
+ include ($$PWD/wayland_egl/wayland_egl.pri)
+}
+
+
diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.cpp
new file mode 100644
index 0000000..9a0a824
--- /dev/null
+++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.cpp
@@ -0,0 +1,11 @@
+#include "qwaylandglintegration.h"
+
+QWaylandGLIntegration::QWaylandGLIntegration()
+{
+
+}
+
+QWaylandGLIntegration::~QWaylandGLIntegration()
+{
+
+}
diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h
new file mode 100644
index 0000000..a1f6b2c
--- /dev/null
+++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h
@@ -0,0 +1,20 @@
+#ifndef QWAYLANDGLINTEGRATION_H
+#define QWAYLANDGLINTEGRATION_H
+
+class QWaylandWindow;
+class QWidget;
+
+class QWaylandGLIntegration
+{
+public:
+ QWaylandGLIntegration();
+ virtual ~QWaylandGLIntegration();
+
+ virtual void initialize() = 0;
+
+ virtual QWaylandWindow *createEglWindow(QWidget *widget) = 0;
+
+ static QWaylandGLIntegration *createEglIntegration(struct wl_display *waylandDisplay);
+};
+
+#endif // QWAYLANDGLINTEGRATION_H
diff --git a/src/plugins/platforms/wayland/qwaylanddrmsurface.cpp b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp
index a8bc352..ca9fb97 100644
--- a/src/plugins/platforms/wayland/qwaylanddrmsurface.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include "qwaylanddrmsurface.h"
+#include "qwaylandglwindowsurface.h"
#include "qwaylanddisplay.h"
#include "qwaylandwindow.h"
@@ -52,8 +52,6 @@
QT_BEGIN_NAMESPACE
-
-
static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize, const QRectF &br)
{
const GLenum target = GL_TEXTURE_2D;
@@ -132,7 +130,7 @@ static void blitTexture(QGLContext *ctx, GLuint texture, const QSize &viewport,
drawTexture(r, texture, texSize, sourceRect);
}
-QWaylandDrmWindowSurface::QWaylandDrmWindowSurface(QWidget *window)
+QWaylandGLWindowSurface::QWaylandGLWindowSurface(QWidget *window)
: QWindowSurface(window)
, mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display())
, mPaintDevice(0)
@@ -140,24 +138,24 @@ QWaylandDrmWindowSurface::QWaylandDrmWindowSurface(QWidget *window)
}
-QWaylandDrmWindowSurface::~QWaylandDrmWindowSurface()
+QWaylandGLWindowSurface::~QWaylandGLWindowSurface()
{
delete mPaintDevice;
}
-QPaintDevice *QWaylandDrmWindowSurface::paintDevice()
+QPaintDevice *QWaylandGLWindowSurface::paintDevice()
{
return mPaintDevice;
}
-void QWaylandDrmWindowSurface::beginPaint(const QRegion &)
+void QWaylandGLWindowSurface::beginPaint(const QRegion &)
{
window()->platformWindow()->glContext()->makeCurrent();
glClearColor(0,0,0,0xff);
glClear(GL_COLOR_BUFFER_BIT);
}
-void QWaylandDrmWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+void QWaylandGLWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
{
Q_UNUSED(offset);
Q_UNUSED(region);
@@ -172,7 +170,7 @@ void QWaylandDrmWindowSurface::flush(QWidget *widget, const QRegion &region, con
ww->glContext()->swapBuffers();
}
-void QWaylandDrmWindowSurface::resize(const QSize &size)
+void QWaylandGLWindowSurface::resize(const QSize &size)
{
QWindowSurface::resize(size);
window()->platformWindow()->glContext()->makeCurrent();
diff --git a/src/plugins/platforms/wayland/qwaylanddrmsurface.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h
index 78418ee..faff872 100644
--- a/src/plugins/platforms/wayland/qwaylanddrmsurface.h
+++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h
@@ -48,11 +48,11 @@
class QGLFramebufferObject;
-class QWaylandDrmWindowSurface : public QWindowSurface
+class QWaylandGLWindowSurface : public QWindowSurface
{
public:
- QWaylandDrmWindowSurface(QWidget *window);
- ~QWaylandDrmWindowSurface();
+ QWaylandGLWindowSurface(QWidget *window);
+ ~QWaylandGLWindowSurface();
void beginPaint(const QRegion &);
@@ -62,7 +62,6 @@ public:
void resize(const QSize &size);
private:
-
QWaylandDisplay *mDisplay;
QGLFramebufferObject *mPaintDevice;
};
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglinclude.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglinclude.h
new file mode 100644
index 0000000..778c3db
--- /dev/null
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglinclude.h
@@ -0,0 +1,16 @@
+#ifndef QWAYLANDEGLINCLUDE_H
+#define QWAYLANDEGLINCLUDE_H
+
+#include <wayland-client.h>
+
+#include <wayland-egl.h>
+
+#define GL_GLEXT_PROTOTYPES
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
+#define EGL_EGLEXT_PROTOTYPES
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
+#endif // QWAYLANDEGLINCLUDE_H
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp
new file mode 100644
index 0000000..eb46bc7
--- /dev/null
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp
@@ -0,0 +1,48 @@
+#include "qwaylandeglintegration.h"
+
+#include "qwaylandeglwindow.h"
+
+QWaylandEglIntegration::QWaylandEglIntegration(struct wl_display *waylandDisplay)
+ : mWaylandDisplay(waylandDisplay)
+ , mNativeEglDisplay(wl_egl_display_create(mWaylandDisplay))
+{
+}
+
+QWaylandEglIntegration::~QWaylandEglIntegration()
+{
+ eglTerminate(mEglDisplay);
+}
+
+void QWaylandEglIntegration::initialize()
+{
+ EGLint major,minor;
+ mEglDisplay = eglGetDisplay((EGLNativeDisplayType)mNativeEglDisplay);
+ if (mEglDisplay == NULL) {
+ qWarning("EGL not available");
+ } else {
+ if (!eglInitialize(mEglDisplay, &major, &minor)) {
+ qWarning("failed to initialize EGL display");
+ return;
+ }
+ }
+}
+
+QWaylandWindow *QWaylandEglIntegration::createEglWindow(QWidget *window)
+{
+ return new QWaylandEglWindow(window);
+}
+
+EGLDisplay QWaylandEglIntegration::eglDisplay() const
+{
+ return mEglDisplay;
+}
+
+wl_egl_display * QWaylandEglIntegration::nativeDisplay() const
+{
+ return mNativeEglDisplay;
+}
+
+QWaylandGLIntegration *QWaylandGLIntegration::createEglIntegration(wl_display *waylandDisplay)
+{
+ return new QWaylandEglIntegration(waylandDisplay);
+}
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h
new file mode 100644
index 0000000..8b166ce
--- /dev/null
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h
@@ -0,0 +1,32 @@
+#ifndef QWAYLANDEGLINTEGRATION_H
+#define QWAYLANDEGLINTEGRATION_H
+
+#include "gl_integration/qwaylandglintegration.h"
+
+#include "qwaylandeglinclude.h"
+
+class QWaylandWindow;
+class QWidget;
+
+class QWaylandEglIntegration : public QWaylandGLIntegration
+{
+public:
+ QWaylandEglIntegration(struct wl_display *waylandDisplay);
+ ~QWaylandEglIntegration();
+
+ void initialize();
+
+ QWaylandWindow *createEglWindow(QWidget *window);
+
+ EGLDisplay eglDisplay() const;
+ struct wl_egl_display *nativeDisplay() const;
+private:
+ struct wl_display *mWaylandDisplay;
+
+ EGLDisplay mEglDisplay;
+ struct wl_egl_display *mNativeEglDisplay;
+
+
+};
+
+#endif // QWAYLANDEGLINTEGRATION_H
diff --git a/src/plugins/platforms/wayland/qwaylandeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp
index ed54bb9..a9aa46f 100644
--- a/src/plugins/platforms/wayland/qwaylandeglwindow.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp
@@ -43,21 +43,20 @@
#include "qwaylandscreen.h"
#include "qwaylandglcontext.h"
-#include "qwaylandinclude.h"
QWaylandEglWindow::QWaylandEglWindow(QWidget *window)
: QWaylandWindow(window)
, mGLContext(0)
, mWaylandEglWindow(0)
{
+ mEglIntegration = static_cast<QWaylandEglIntegration *>(mDisplay->eglIntegration());
//super creates a new surface
newSurfaceCreated();
}
QWaylandEglWindow::~QWaylandEglWindow()
{
- if (mGLContext)
- delete mGLContext;
+ delete mGLContext;
}
QWaylandWindow::WindowType QWaylandEglWindow::windowType() const
@@ -84,10 +83,10 @@ QPlatformGLContext * QWaylandEglWindow::glContext() const
{
if (!mGLContext) {
QWaylandEglWindow *that = const_cast<QWaylandEglWindow *>(this);
- that->mGLContext = new QWaylandGLContext(that->mDisplay,widget()->platformWindowFormat());
+ that->mGLContext = new QWaylandGLContext(mEglIntegration->eglDisplay(),widget()->platformWindowFormat());
EGLNativeWindowType window(reinterpret_cast<EGLNativeWindowType>(mWaylandEglWindow));
- EGLSurface surface = eglCreateWindowSurface(mDisplay->eglDisplay(),mGLContext->eglConfig(),window,NULL);
+ EGLSurface surface = eglCreateWindowSurface(mEglIntegration->eglDisplay(),mGLContext->eglConfig(),window,NULL);
that->mGLContext->setEglSurface(surface);
}
@@ -104,10 +103,10 @@ void QWaylandEglWindow::newSurfaceCreated()
if (!size.isValid())
size = QSize(0,0);
- mWaylandEglWindow = wl_egl_window_create(mDisplay->nativeDisplay(),mSurface,size.width(),size.height(),visual);
+ mWaylandEglWindow = wl_egl_window_create(mEglIntegration->nativeDisplay(),mSurface,size.width(),size.height(),visual);
if (mGLContext) {
EGLNativeWindowType window(reinterpret_cast<EGLNativeWindowType>(mWaylandEglWindow));
- EGLSurface surface = eglCreateWindowSurface(mDisplay->eglDisplay(),mGLContext->eglConfig(),window,NULL);
+ EGLSurface surface = eglCreateWindowSurface(mEglIntegration->eglDisplay(),mGLContext->eglConfig(),window,NULL);
mGLContext->setEglSurface(surface);
}
}
diff --git a/src/plugins/platforms/wayland/qwaylandeglwindow.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h
index 4b3bb5b..ef1e02a 100644
--- a/src/plugins/platforms/wayland/qwaylandeglwindow.h
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h
@@ -43,6 +43,8 @@
#define QWAYLANDEGLWINDOW_H
#include "qwaylandwindow.h"
+#include "qwaylandeglinclude.h"
+#include "qwaylandeglintegration.h"
class QWaylandGLContext;
@@ -58,6 +60,7 @@ public:
protected:
void newSurfaceCreated();
private:
+ QWaylandEglIntegration *mEglIntegration;
QWaylandGLContext *mGLContext;
struct wl_egl_window *mWaylandEglWindow;
EGLConfig mConfig;
diff --git a/src/plugins/platforms/wayland/qwaylandglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp
index 3720567..4444229 100644
--- a/src/plugins/platforms/wayland/qwaylandglcontext.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp
@@ -43,27 +43,27 @@
#include "qwaylanddisplay.h"
#include "qwaylandwindow.h"
-#include "qwaylanddrmsurface.h"
-#include "../eglconvenience/qeglconvenience.h"
+#include "../../../eglconvenience/qeglconvenience.h"
#include <QtGui/QPlatformGLContext>
#include <QtGui/QPlatformWindowFormat>
+#include <QtCore/QMutex>
Q_GLOBAL_STATIC(QMutex,qt_defaultSharedContextMutex)
-QWaylandGLContext::QWaylandGLContext(QWaylandDisplay *wd, const QPlatformWindowFormat &format)
+QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindowFormat &format)
: QPlatformGLContext()
- , mDisplay(wd)
+ , mEglDisplay(eglDisplay)
, mSurface(EGL_NO_SURFACE)
- , mConfig(q_configFromQPlatformWindowFormat(mDisplay->eglDisplay(),format,true))
- , mFormat(qt_qPlatformWindowFormatFromConfig(mDisplay->eglDisplay(),mConfig))
+ , mConfig(q_configFromQPlatformWindowFormat(mEglDisplay,format,true))
+ , mFormat(qt_qPlatformWindowFormatFromConfig(mEglDisplay,mConfig))
{
QPlatformGLContext *sharePlatformContext = 0;
if (format.useDefaultSharedContext()) {
if (!QPlatformGLContext::defaultSharedContext()) {
if (qt_defaultSharedContextMutex()->tryLock()){
- createDefaultSharedContex(wd);
+ createDefaultSharedContex(eglDisplay);
qt_defaultSharedContextMutex()->unlock();
} else {
qt_defaultSharedContextMutex()->lock(); //wait to the the shared context is created
@@ -86,13 +86,13 @@ QWaylandGLContext::QWaylandGLContext(QWaylandDisplay *wd, const QPlatformWindowF
eglContextAttrs.append(2);
eglContextAttrs.append(EGL_NONE);
- mContext = eglCreateContext(mDisplay->eglDisplay(), mConfig,
+ mContext = eglCreateContext(mEglDisplay, mConfig,
shareEGLContext, eglContextAttrs.constData());
}
QWaylandGLContext::QWaylandGLContext()
: QPlatformGLContext()
- , mDisplay(0)
+ , mEglDisplay(0)
, mContext(EGL_NO_CONTEXT)
, mSurface(EGL_NO_SURFACE)
, mConfig(0)
@@ -100,7 +100,7 @@ QWaylandGLContext::QWaylandGLContext()
QWaylandGLContext::~QWaylandGLContext()
{
- eglDestroyContext(mDisplay->eglDisplay(),mContext);
+ eglDestroyContext(mEglDisplay,mContext);
}
void QWaylandGLContext::makeCurrent()
@@ -109,18 +109,18 @@ void QWaylandGLContext::makeCurrent()
if (mSurface == EGL_NO_SURFACE) {
qWarning("makeCurrent with EGL_NO_SURFACE");
}
- eglMakeCurrent(mDisplay->eglDisplay(), mSurface, mSurface, mContext);
+ eglMakeCurrent(mEglDisplay, mSurface, mSurface, mContext);
}
void QWaylandGLContext::doneCurrent()
{
QPlatformGLContext::doneCurrent();
- eglMakeCurrent(mDisplay->eglDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
}
void QWaylandGLContext::swapBuffers()
{
- eglSwapBuffers(mDisplay->eglDisplay(),mSurface);
+ eglSwapBuffers(mEglDisplay,mSurface);
}
void *QWaylandGLContext::getProcAddress(const QString &string)
@@ -128,7 +128,7 @@ void *QWaylandGLContext::getProcAddress(const QString &string)
return (void *) eglGetProcAddress(string.toLatin1().data());
}
-void QWaylandGLContext::createDefaultSharedContex(QWaylandDisplay *display)
+void QWaylandGLContext::createDefaultSharedContex(EGLDisplay display)
{
QVector<EGLint> eglContextAttrs;
eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
@@ -136,8 +136,8 @@ void QWaylandGLContext::createDefaultSharedContex(QWaylandDisplay *display)
eglContextAttrs.append(EGL_NONE);
QWaylandGLContext *defaultSharedContext = new QWaylandGLContext;
- defaultSharedContext->mDisplay = display;
- defaultSharedContext->mContext = eglCreateContext(mDisplay->eglDisplay(),mConfig,
+ defaultSharedContext->mEglDisplay = display;
+ defaultSharedContext->mContext = eglCreateContext(mEglDisplay,mConfig,
EGL_NO_CONTEXT, eglContextAttrs.constData());
QPlatformGLContext::setDefaultSharedContext(defaultSharedContext);
}
diff --git a/src/plugins/platforms/wayland/qwaylandglcontext.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h
index dd319fd..d530b1c 100644
--- a/src/plugins/platforms/wayland/qwaylandglcontext.h
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h
@@ -46,14 +46,14 @@
#include <QtGui/QPlatformGLContext>
-class QWaylandWindow;
-class QWaylandDrmWindowSurface;
+#include "qwaylandeglinclude.h"
-#include "qwaylandinclude.h"
+class QWaylandWindow;
+class QWaylandGLWindowSurface;
class QWaylandGLContext : public QPlatformGLContext {
public:
- QWaylandGLContext(QWaylandDisplay *wd, const QPlatformWindowFormat &format);
+ QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindowFormat &format);
~QWaylandGLContext();
void makeCurrent();
void doneCurrent();
@@ -65,14 +65,14 @@ public:
void setEglSurface(EGLSurface surface);
EGLConfig eglConfig() const;
private:
- QWaylandDisplay *mDisplay;
+ EGLDisplay mEglDisplay;
EGLContext mContext;
EGLSurface mSurface;
EGLConfig mConfig;
QPlatformWindowFormat mFormat;
- void createDefaultSharedContex(QWaylandDisplay *display);
+ void createDefaultSharedContex(EGLDisplay eglDisplay);
QWaylandGLContext();
};
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri b/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri
new file mode 100644
index 0000000..bc97864
--- /dev/null
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri
@@ -0,0 +1,12 @@
+LIBS += -lwayland-egl -lEGL
+INCLUDEPATH += $$PWD
+SOURCES += $$PWD/qwaylandeglintegration.cpp \
+ $$PWD/qwaylandglcontext.cpp \
+ $$PWD/qwaylandeglwindow.cpp \
+ $$PWD/../../../eglconvenience/qeglconvenience.cpp
+
+HEADERS += $$PWD/qwaylandeglintegration.h \
+ $$PWD/qwaylandglcontext.h \
+ $$PWD/qwaylandeglwindow.h \
+ $$PWD/../../../eglconvenience/qeglconvenience.h \
+ gl_integration/wayland_egl/qwaylandeglinclude.h
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp
index 27f4334..eebc9de 100644
--- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp
+++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp
@@ -46,6 +46,10 @@
#include "qwaylandcursor.h"
#include "qwaylandinputdevice.h"
+#ifdef QT_WAYLAND_GL_SUPPORT
+#include "gl_integration/qwaylandglintegration.h"
+#endif
+
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
@@ -78,9 +82,9 @@ struct wl_visual *QWaylandDisplay::argbPremultipliedVisual()
return wl_display_get_premultiplied_argb_visual(mDisplay);
}
-struct wl_egl_display *QWaylandDisplay::nativeDisplay()
+QWaylandGLIntegration * QWaylandDisplay::eglIntegration()
{
- return mNativeEglDisplay;
+ return mEglIntegration;
}
void QWaylandDisplay::shellHandleConfigure(void *data, struct wl_shell *shell,
@@ -176,9 +180,6 @@ void QWaylandDisplay::flushRequests(void)
QWaylandDisplay::QWaylandDisplay(void)
: mWriteNotifier(0)
{
-#ifdef QT_WAYLAND_GL_SUPPORT
- EGLint major, minor;
-#endif
mDisplay = wl_display_connect(NULL);
if (mDisplay == NULL) {
fprintf(stderr, "failed to create display: %m\n");
@@ -189,25 +190,13 @@ QWaylandDisplay::QWaylandDisplay(void)
QWaylandDisplay::displayHandleGlobal, this);
#ifdef QT_WAYLAND_GL_SUPPORT
- mNativeEglDisplay = wl_egl_display_create(mDisplay);
-#else
- mNativeEglDisplay = 0;
+ mEglIntegration = QWaylandGLIntegration::createEglIntegration(mDisplay);
#endif
readEvents();
#ifdef QT_WAYLAND_GL_SUPPORT
- mEglDisplay = eglGetDisplay((EGLNativeDisplayType)mNativeEglDisplay);
- if (mEglDisplay == NULL) {
- qWarning("EGL not available");
- } else {
- if (!eglInitialize(mEglDisplay, &major, &minor)) {
- qWarning("failed to initialize EGL display");
- return;
- }
- }
-#else
- mEglDisplay = 0;
+ mEglIntegration->initialize();
#endif
int fd = wl_display_get_fd(mDisplay, sourceUpdate, this);
@@ -225,7 +214,7 @@ QWaylandDisplay::~QWaylandDisplay(void)
{
close(mFd);
#ifdef QT_WAYLAND_GL_SUPPORT
- eglTerminate(mEglDisplay);
+ delete mEglIntegration;
#endif
wl_display_destroy(mDisplay);
}
@@ -245,3 +234,4 @@ void QWaylandDisplay::frameCallback(wl_display_frame_func_t func, void *data)
{
wl_display_frame_callback(mDisplay, func, data);
}
+
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h
index d994ffe..535dcd6 100644
--- a/src/plugins/platforms/wayland/qwaylanddisplay.h
+++ b/src/plugins/platforms/wayland/qwaylanddisplay.h
@@ -44,18 +44,15 @@
#include <QtCore/QObject>
#include <QtCore/QRect>
-#include <QtCore/QDataStream>
-#include <QtCore/QTextStream>
-#include <QtCore/QMetaType>
-#include <QtGui>
-#include "qwaylandinclude.h"
+#include <wayland-client.h>
class QWaylandInputDevice;
class QSocketNotifier;
class QWaylandBuffer;
class QPlatformScreen;
class QWaylandScreen;
+class QWaylandGLIntegration;
class QWaylandDisplay : public QObject {
Q_OBJECT
@@ -73,9 +70,10 @@ public:
struct wl_visual *rgbVisual();
struct wl_visual *argbVisual();
struct wl_visual *argbPremultipliedVisual();
- struct wl_egl_display *nativeDisplay();
- EGLDisplay eglDisplay() { return mEglDisplay; }
+#ifdef QT_WAYLAND_GL_SUPPORT
+ QWaylandGLIntegration *eglIntegration();
+#endif
void setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y);
void syncCallback(wl_display_sync_func_t func, void *data);
@@ -98,8 +96,9 @@ private:
QList<QWaylandInputDevice *> mInputDevices;
QSocketNotifier *mReadNotifier;
QSocketNotifier *mWriteNotifier;
- EGLDisplay mEglDisplay;
- struct wl_egl_display *mNativeEglDisplay;
+#ifdef QT_WAYLAND_GL_SUPPORT
+ QWaylandGLIntegration *mEglIntegration;
+#endif
static void displayHandleGlobal(struct wl_display *display,
uint32_t id,
diff --git a/src/plugins/platforms/wayland/qwaylandinclude.h b/src/plugins/platforms/wayland/qwaylandinclude.h
deleted file mode 100644
index 0135251..0000000
--- a/src/plugins/platforms/wayland/qwaylandinclude.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** 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 config.tests of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWAYLANDINCLUDE_H
-#define QWAYLANDINCLUDE_H
-
-#include <wayland-client.h>
-
-#ifdef QT_WAYLAND_GL_SUPPORT
-#include <wayland-egl.h>
-
-#define GL_GLEXT_PROTOTYPES
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
-#define EGL_EGLEXT_PROTOTYPES
- #include <EGL/egl.h>
- #include <EGL/eglext.h>
-
-#else
-typedef void* EGLDisplay;
-typedef void* EGLConfig;
-#endif
-
-#endif // QWAYLANDINCLUDE_H
diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp
index 267a037..be78b82 100644
--- a/src/plugins/platforms/wayland/qwaylandintegration.cpp
+++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp
@@ -43,9 +43,7 @@
#include "qwaylanddisplay.h"
#include "qwaylandshmsurface.h"
-#include "qwaylanddrmsurface.h"
#include "qwaylandshmwindow.h"
-#include "qwaylandeglwindow.h"
#include "qgenericunixfontdatabase.h"
@@ -55,6 +53,8 @@
#include <QtGui/private/qpixmap_raster_p.h>
#ifdef QT_WAYLAND_GL_SUPPORT
+#include "gl_integration/qwaylandglintegration.h"
+#include "gl_integration/qwaylandglwindowsurface.h"
#include <QtOpenGL/private/qpixmapdata_gl_p.h>
#endif
@@ -91,10 +91,11 @@ QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type)
QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWidget *widget, WId winId) const
{
Q_UNUSED(winId);
+#ifdef QT_WAYLAND_GL_SUPPORT
bool useOpenGL = mUseOpenGL || (widget->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL);
if (useOpenGL)
- return new QWaylandEglWindow(widget);
-
+ return mDisplay->eglIntegration()->createEglWindow(widget);
+#endif
return new QWaylandShmWindow(widget);
}
@@ -102,10 +103,11 @@ QWindowSurface *QWaylandIntegration::createWindowSurface(QWidget *widget, WId wi
{
Q_UNUSED(winId);
Q_UNUSED(winId);
+#ifdef QT_WAYLAND_GL_SUPPORT
bool useOpenGL = mUseOpenGL || (widget->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL);
if (useOpenGL)
- return new QWaylandDrmWindowSurface(widget);
-
+ return new QWaylandGLWindowSurface(widget);
+#endif
return new QWaylandShmWindowSurface(widget);
}
diff --git a/src/plugins/platforms/wayland/qwaylandwindow.h b/src/plugins/platforms/wayland/qwaylandwindow.h
index 3b51ee7..afc214e 100644
--- a/src/plugins/platforms/wayland/qwaylandwindow.h
+++ b/src/plugins/platforms/wayland/qwaylandwindow.h
@@ -44,7 +44,6 @@
#include <QtGui/QPlatformWindow>
-#include <stdint.h>
#include "qwaylanddisplay.h"
class QWaylandDisplay;
diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro
index f78e4b3..b44857b 100644
--- a/src/plugins/platforms/wayland/wayland.pro
+++ b/src/plugins/platforms/wayland/wayland.pro
@@ -22,29 +22,21 @@ HEADERS = qwaylandintegration.h \
qwaylandwindow.h \
qwaylandscreen.h \
qwaylandshmsurface.h \
- qwaylanddrmsurface.h \
qwaylandbuffer.h \
- qwaylandinclude.h \
- qwaylandeglwindow.h \
qwaylandshmwindow.h
INCLUDEPATH += $$QMAKE_INCDIR_WAYLAND
LIBS += $$QMAKE_LIBS_WAYLAND
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_WAYLAND
+INCLUDEPATH += $$PWD
+
contains(QT_CONFIG, opengles2) {
+ DEFINES += QT_WAYLAND_GL_SUPPORT
QT += opengl
- LIBS += -lwayland-egl -lEGL
-
- SOURCES += qwaylanddrmsurface.cpp \
- qwaylandglcontext.cpp \
- ../eglconvenience/qeglconvenience.cpp \
- qwaylandeglwindow.cpp
- HEADERS += qwaylandglcontext.h \
- ../eglconvenience/qeglconvenience.h \
-
- DEFINES += QT_WAYLAND_GL_SUPPORT
+ CONFIG += wayland_egl
+ include ($$PWD/gl_integration/gl_integration.pri)
}
include (../fontdatabases/genericunix/genericunix.pri)