summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wayland/gl_integration
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>2011-06-16 12:56:00 +0200
committerLaszlo Agocs <laszlo.p.agocs@nokia.com>2011-06-20 10:30:30 +0200
commitc84346ddff128daf6900860229aa99e4dc6763b2 (patch)
tree80055e58c282aa8b6a514ec967d21f46201aa024 /src/plugins/platforms/wayland/gl_integration
parent34d19a5571a422c53a7736d9c7a075da85aaa9c3 (diff)
Make glx wayland backends working.
Diffstat (limited to 'src/plugins/platforms/wayland/gl_integration')
-rw-r--r--src/plugins/platforms/wayland/gl_integration/gl_integration.pri6
-rw-r--r--src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp192
-rw-r--r--src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h72
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp3
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp5
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri1
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp14
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp5
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri1
12 files changed, 27 insertions, 278 deletions
diff --git a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri
index d9b5fa9bff..6652ff5fbb 100644
--- a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri
+++ b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri
@@ -3,12 +3,10 @@ contains(QT_CONFIG, opengl) {
QT += opengl
HEADERS += \
- $$PWD/qwaylandglintegration.h \
- $$PWD/qwaylandglwindowsurface.h
+ $$PWD/qwaylandglintegration.h
SOURCES += \
- $$PWD/qwaylandglintegration.cpp \
- $$PWD/qwaylandglwindowsurface.cpp
+ $$PWD/qwaylandglintegration.cpp
QT_WAYLAND_GL_CONFIG = $$(QT_WAYLAND_GL_CONFIG)
contains(QT_CONFIG, opengles2) {
diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp
deleted file mode 100644
index 1d6e79e94c..0000000000
--- a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp
+++ /dev/null
@@ -1,192 +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 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$
-**
-****************************************************************************/
-
-#include "qwaylandglwindowsurface.h"
-
-#include "qwaylanddisplay.h"
-#include "qwaylandwindow.h"
-#include "qwaylandscreen.h"
-
-#include <QtOpenGL/QGLFramebufferObject>
-#include <QtOpenGL/QGLContext>
-#include <QPlatformGLContext>
-
-#include <QtOpenGL/private/qglengineshadermanager_p.h>
-
-QT_BEGIN_NAMESPACE
-
-static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize, const QRectF &br)
-{
-#if !defined(QT_OPENGL_ES_2)
- QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
-#endif
- const GLenum target = GL_TEXTURE_2D;
- QRectF src = br.isEmpty()
- ? QRectF(QPointF(), texSize)
- : QRectF(QPointF(br.x(), texSize.height() - br.bottom()), br.size());
-
- if (target == GL_TEXTURE_2D) {
- qreal width = texSize.width();
- qreal height = texSize.height();
-
- src.setLeft(src.left() / width);
- src.setRight(src.right() / width);
- src.setTop(src.top() / height);
- src.setBottom(src.bottom() / height);
- }
-
- const GLfloat tx1 = src.left();
- const GLfloat tx2 = src.right();
- const GLfloat ty1 = src.top();
- const GLfloat ty2 = src.bottom();
-
- GLfloat texCoordArray[4*2] = {
- tx1, ty2, tx2, ty2, tx2, ty1, tx1, ty1
- };
-
- GLfloat vertexArray[4*2];
- vertexArray[0] = rect.left(); vertexArray[1] = rect.top();
- vertexArray[2] = rect.right(); vertexArray[3] = rect.top();
- vertexArray[4] = rect.right(); vertexArray[5] = rect.bottom();
- vertexArray[6] = rect.left(); vertexArray[7] = rect.bottom();
-
- glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexArray);
- glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, texCoordArray);
-
- glBindTexture(target, tex_id);
-
- glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR);
- glEnableVertexAttribArray(QT_TEXTURE_COORDS_ATTR);
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR);
- glDisableVertexAttribArray(QT_TEXTURE_COORDS_ATTR);
-
- glBindTexture(target, 0);
-}
-
-static void blitTexture(QGLContext *ctx, GLuint texture, const QSize &viewport, const QSize &texSize, const QRect &targetRect, const QRect &sourceRect)
-{
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_SCISSOR_TEST);
- glDisable(GL_BLEND);
- glViewport(0, 0, viewport.width(), viewport.height());
-
- QGLShaderProgram *blitProgram =
- QGLEngineSharedShaders::shadersForContext(ctx)->blitProgram();
- blitProgram->bind();
- blitProgram->setUniformValue("imageTexture", 0 /*QT_IMAGE_TEXTURE_UNIT*/);
-
- // The shader manager's blit program does not multiply the
- // vertices by the pmv matrix, so we need to do the effect
- // of the orthographic projection here ourselves.
- QRectF r;
- qreal w = viewport.width();
- qreal h = viewport.height();
- r.setLeft((targetRect.left() / w) * 2.0f - 1.0f);
- if (targetRect.right() == (viewport.width() - 1))
- r.setRight(1.0f);
- else
- r.setRight((targetRect.right() / w) * 2.0f - 1.0f);
- r.setBottom((targetRect.top() / h) * 2.0f - 1.0f);
- if (targetRect.bottom() == (viewport.height() - 1))
- r.setTop(1.0f);
- else
- r.setTop((targetRect.bottom() / w) * 2.0f - 1.0f);
-
- drawTexture(r, texture, texSize, sourceRect);
-}
-
-QWaylandGLWindowSurface::QWaylandGLWindowSurface(QWindow *window)
- : QWindowSurface(window)
- , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display())
- , mPaintDevice(0)
- , mContext(0)
-{
-}
-
-QWaylandGLWindowSurface::~QWaylandGLWindowSurface()
-{
- delete mPaintDevice;
- delete mContext;
-}
-
-QPaintDevice *QWaylandGLWindowSurface::paintDevice()
-{
- return mPaintDevice;
-}
-
-QGuiGLContext *QWaylandGLWindowSurface::context() const
-{
- if (!mContext)
- const_cast<QGuiGLContext *&>(mContext) = new QGuiGLContext(window()->glFormat());
- return mContext;
-}
-
-void QWaylandGLWindowSurface::beginPaint(const QRegion &)
-{
- context()->makeCurrent(window()->glSurface());
- glClearColor(0, 0, 0, 0);
- glClear(GL_COLOR_BUFFER_BIT);
-}
-
-void QWaylandGLWindowSurface::flush(QWindow *, const QRegion &region, const QPoint &offset)
-{
- Q_UNUSED(offset);
- Q_UNUSED(region);
-
- if (mPaintDevice->isBound())
- mPaintDevice->release();
-
- QRect rect(0,0,size().width(),size().height());
- QGLContext *ctx = QGLContext::fromGuiGLContext(context());
- blitTexture(ctx,mPaintDevice->texture(),size(),mPaintDevice->size(),rect,rect);
- context()->swapBuffers(window()->glSurface());
-}
-
-void QWaylandGLWindowSurface::resize(const QSize &size)
-{
- QWindowSurface::resize(size);
- context()->makeCurrent(window()->glSurface());
- delete mPaintDevice;
- mPaintDevice = new QGLFramebufferObject(size);
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h
deleted file mode 100644
index 3703869a60..0000000000
--- a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h
+++ /dev/null
@@ -1,72 +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 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 QWAYLANDDRMSURFACE_H
-#define QWAYLANDDRMSURFACE_H
-
-#include "qwaylanddisplay.h"
-
-#include <QtGui/private/qwindowsurface_p.h>
-
-class QGLFramebufferObject;
-
-class QWaylandGLWindowSurface : public QWindowSurface
-{
-public:
- QWaylandGLWindowSurface(QWindow *window);
- ~QWaylandGLWindowSurface();
-
- void beginPaint(const QRegion &);
-
- QPaintDevice *paintDevice();
- void flush(QWindow *window, const QRegion &region, const QPoint &offset);
-
- void resize(const QSize &size);
-
- QGuiGLContext *context() const;
-
-private:
- QWaylandDisplay *mDisplay;
- QGLFramebufferObject *mPaintDevice;
- QGuiGLContext *mContext;
-};
-
-#endif // QWAYLANDDRMSURFACE_H
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 54b7d322f8..61fd26fe3a 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp
@@ -113,7 +113,7 @@ void QWaylandReadbackGlxContext::swapBuffers(const QPlatformGLSurface &surface)
{
// #### makeCurrent() directly on the platform context doesn't update QGuiGLContext::currentContext()
if (QGuiGLContext::currentContext()->handle() != this)
- makeCurrent(surface, surface);
+ makeCurrent(surface);
const QWaylandReadbackGlxSurface &s =
static_cast<const QWaylandReadbackGlxSurface &>(surface);
@@ -135,6 +135,7 @@ void QWaylandReadbackGlxContext::swapBuffers(const QPlatformGLSurface &surface)
memcpy(dstBits, constBits, (img.width() * 4) * img.height());
s.window()->damage(QRect(QPoint(), size));
+
s.window()->waitForFrameSync();
}
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 27a7287b07..3008c295d3 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h
@@ -47,7 +47,7 @@
#include "qwaylandreadbackglxintegration.h"
-#include "qglxconvenience.h"
+#include <QtPlatformSupport/private/qglxconvenience_p.h>
class QWaylandReadbackGlxWindow;
class QWaylandShmBuffer;
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 f878bef0c4..5565e78ef4 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp
@@ -86,6 +86,11 @@ 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/readback_glx.pri b/src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri
index dc84d1c9e9..746d594fa2 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri
@@ -1,4 +1,3 @@
-load(qpa/glx/convenience)
HEADERS += \
$$PWD/qwaylandreadbackglxintegration.h \
$$PWD/qwaylandreadbackglxwindow.h \
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 5d4cf7a567..54d63a2bec 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp
@@ -60,8 +60,8 @@ Window QWaylandXCompositeGLXSurface::xWindow() const
QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(const QGuiGLFormat &format, QPlatformGLContext *share, Display *display, int screen)
: m_display(display)
{
+ qDebug("creating XComposite-GLX context");
GLXContext shareContext = share ? static_cast<QWaylandXCompositeGLXContext *>(share)->m_context : 0;
-
GLXFBConfig config = qglx_findConfig(display, screen, format);
XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display, config);
m_context = glXCreateContext(display, visualInfo, shareContext, true);
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 e0de801a5e..39fe03032f 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h
@@ -45,7 +45,7 @@
#include <QtGui/QPlatformGLContext>
#include "qwaylandxcompositeglxintegration.h"
-#include "qglxconvenience.h"
+#include <QtPlatformSupport/private/qglxconvenience_p.h>
class QWaylandXCompositeGLXWindow;
class QWaylandShmBuffer;
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 a80a595768..426c78e5e8 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp
@@ -52,12 +52,15 @@ QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDispl
return new QWaylandXCompositeGLXIntegration(waylandDisplay);
}
-QWaylandXCompositeGLXIntegration::QWaylandXCompositeGLXIntegration(QWaylandDisplay * waylandDispaly)
- : QWaylandGLIntegration()
- , mWaylandDisplay(waylandDispaly)
+QWaylandXCompositeGLXIntegration::QWaylandXCompositeGLXIntegration(QWaylandDisplay *waylandDisplay)
+ : mWaylandDisplay(waylandDisplay)
+ , mWaylandComposite(0)
+ , mDisplay(0)
+ , mScreen(0)
+ , mRootWindow(0)
{
qDebug() << "Using XComposite-GLX";
- wl_display_add_global_listener(waylandDispaly->wl_display(), QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal,
+ wl_display_add_global_listener(waylandDisplay->wl_display(), QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal,
this);
}
@@ -112,6 +115,7 @@ void QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal(wl_display *display
{
Q_UNUSED(version);
if (strcmp(interface, "wl_xcomposite") == 0) {
+ qDebug("XComposite-GLX: got wl_xcomposite global");
QWaylandXCompositeGLXIntegration *integration = static_cast<QWaylandXCompositeGLXIntegration *>(data);
integration->mWaylandComposite = wl_xcomposite_create(display,id,1);
wl_xcomposite_add_listener(integration->mWaylandComposite,&xcomposite_listener,integration);
@@ -124,6 +128,8 @@ void QWaylandXCompositeGLXIntegration::rootInformation(void *data, wl_xcomposite
Q_UNUSED(xcomposite);
QWaylandXCompositeGLXIntegration *integration = static_cast<QWaylandXCompositeGLXIntegration *>(data);
+ qDebug("XComposite-GLX: xcomposite listener callback");
+
integration->mDisplay = XOpenDisplay(display_name);
integration->mRootWindow = (Window) root_window;
integration->mScreen = XDefaultScreen(integration->mDisplay);
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 41a14e3f66..797803f4cd 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp
@@ -112,6 +112,11 @@ void QWaylandXCompositeGLXWindow::createSurface()
size = QSize(1,1);
}
+ if (!m_glxIntegration->xDisplay()) {
+ qWarning("XCompositeGLXWindow: X display still null?!");
+ return;
+ }
+
XVisualInfo *visualInfo = glXGetVisualFromFBConfig(m_glxIntegration->xDisplay(), m_config);
Colormap cmap = XCreateColormap(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(),
visualInfo->visual, AllocNone);
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri
index 9aae32c41b..bbd6c12e42 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri
@@ -1,5 +1,4 @@
include (../xcomposite_share/xcomposite_share.pri)
-load(qpa/glx/convenience)
LIBS += -lXcomposite
SOURCES += \