Make glx wayland backends working.
This commit is contained in:
parent
34d19a5571
commit
c84346ddff
@ -34,9 +34,8 @@ HelloWindow::HelloWindow(Renderer *renderer)
|
|||||||
create();
|
create();
|
||||||
|
|
||||||
QTimer *timer = new QTimer(this);
|
QTimer *timer = new QTimer(this);
|
||||||
timer->start(10);
|
|
||||||
|
|
||||||
connect(timer, SIGNAL(timeout()), this, SLOT(render()));
|
connect(timer, SIGNAL(timeout()), this, SLOT(render()));
|
||||||
|
timer->start(10);
|
||||||
|
|
||||||
updateColor();
|
updateColor();
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,7 @@ void QWindow::create()
|
|||||||
d->platformWindow->setWindowTitle(d->windowTitle);
|
d->platformWindow->setWindowTitle(d->windowTitle);
|
||||||
if (d->windowState != Qt::WindowNoState)
|
if (d->windowState != Qt::WindowNoState)
|
||||||
d->windowState = d->platformWindow->setWindowState(d->windowState);
|
d->windowState = d->platformWindow->setWindowState(d->windowState);
|
||||||
|
d->platformWindow->setGeometry(geometry());
|
||||||
|
|
||||||
QObjectList childObjects = children();
|
QObjectList childObjects = children();
|
||||||
for (int i = 0; i < childObjects.size(); i ++) {
|
for (int i = 0; i < childObjects.size(); i ++) {
|
||||||
|
@ -3,12 +3,10 @@ contains(QT_CONFIG, opengl) {
|
|||||||
QT += opengl
|
QT += opengl
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/qwaylandglintegration.h \
|
$$PWD/qwaylandglintegration.h
|
||||||
$$PWD/qwaylandglwindowsurface.h
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/qwaylandglintegration.cpp \
|
$$PWD/qwaylandglintegration.cpp
|
||||||
$$PWD/qwaylandglwindowsurface.cpp
|
|
||||||
|
|
||||||
QT_WAYLAND_GL_CONFIG = $$(QT_WAYLAND_GL_CONFIG)
|
QT_WAYLAND_GL_CONFIG = $$(QT_WAYLAND_GL_CONFIG)
|
||||||
contains(QT_CONFIG, opengles2) {
|
contains(QT_CONFIG, opengles2) {
|
||||||
|
@ -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 ®ion, 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
|
|
@ -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 ®ion, const QPoint &offset);
|
|
||||||
|
|
||||||
void resize(const QSize &size);
|
|
||||||
|
|
||||||
QGuiGLContext *context() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QWaylandDisplay *mDisplay;
|
|
||||||
QGLFramebufferObject *mPaintDevice;
|
|
||||||
QGuiGLContext *mContext;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // QWAYLANDDRMSURFACE_H
|
|
@ -113,7 +113,7 @@ void QWaylandReadbackGlxContext::swapBuffers(const QPlatformGLSurface &surface)
|
|||||||
{
|
{
|
||||||
// #### makeCurrent() directly on the platform context doesn't update QGuiGLContext::currentContext()
|
// #### makeCurrent() directly on the platform context doesn't update QGuiGLContext::currentContext()
|
||||||
if (QGuiGLContext::currentContext()->handle() != this)
|
if (QGuiGLContext::currentContext()->handle() != this)
|
||||||
makeCurrent(surface, surface);
|
makeCurrent(surface);
|
||||||
|
|
||||||
const QWaylandReadbackGlxSurface &s =
|
const QWaylandReadbackGlxSurface &s =
|
||||||
static_cast<const QWaylandReadbackGlxSurface &>(surface);
|
static_cast<const QWaylandReadbackGlxSurface &>(surface);
|
||||||
@ -135,6 +135,7 @@ void QWaylandReadbackGlxContext::swapBuffers(const QPlatformGLSurface &surface)
|
|||||||
memcpy(dstBits, constBits, (img.width() * 4) * img.height());
|
memcpy(dstBits, constBits, (img.width() * 4) * img.height());
|
||||||
|
|
||||||
s.window()->damage(QRect(QPoint(), size));
|
s.window()->damage(QRect(QPoint(), size));
|
||||||
|
|
||||||
s.window()->waitForFrameSync();
|
s.window()->waitForFrameSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
#include "qwaylandreadbackglxintegration.h"
|
#include "qwaylandreadbackglxintegration.h"
|
||||||
|
|
||||||
#include "qglxconvenience.h"
|
#include <QtPlatformSupport/private/qglxconvenience_p.h>
|
||||||
|
|
||||||
class QWaylandReadbackGlxWindow;
|
class QWaylandReadbackGlxWindow;
|
||||||
class QWaylandShmBuffer;
|
class QWaylandShmBuffer;
|
||||||
|
@ -86,6 +86,11 @@ uchar *QWaylandReadbackGlxWindow::buffer()
|
|||||||
return m_buffer->image()->bits();
|
return m_buffer->image()->bits();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPlatformGLSurface *QWaylandReadbackGlxWindow::createGLSurface() const
|
||||||
|
{
|
||||||
|
return new QWaylandReadbackGlxSurface(const_cast<QWaylandReadbackGlxWindow *>(this));
|
||||||
|
}
|
||||||
|
|
||||||
void QWaylandReadbackGlxWindow::createSurface()
|
void QWaylandReadbackGlxWindow::createSurface()
|
||||||
{
|
{
|
||||||
QSize size(geometry().size());
|
QSize size(geometry().size());
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
load(qpa/glx/convenience)
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/qwaylandreadbackglxintegration.h \
|
$$PWD/qwaylandreadbackglxintegration.h \
|
||||||
$$PWD/qwaylandreadbackglxwindow.h \
|
$$PWD/qwaylandreadbackglxwindow.h \
|
||||||
|
@ -60,8 +60,8 @@ Window QWaylandXCompositeGLXSurface::xWindow() const
|
|||||||
QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(const QGuiGLFormat &format, QPlatformGLContext *share, Display *display, int screen)
|
QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(const QGuiGLFormat &format, QPlatformGLContext *share, Display *display, int screen)
|
||||||
: m_display(display)
|
: m_display(display)
|
||||||
{
|
{
|
||||||
|
qDebug("creating XComposite-GLX context");
|
||||||
GLXContext shareContext = share ? static_cast<QWaylandXCompositeGLXContext *>(share)->m_context : 0;
|
GLXContext shareContext = share ? static_cast<QWaylandXCompositeGLXContext *>(share)->m_context : 0;
|
||||||
|
|
||||||
GLXFBConfig config = qglx_findConfig(display, screen, format);
|
GLXFBConfig config = qglx_findConfig(display, screen, format);
|
||||||
XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display, config);
|
XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display, config);
|
||||||
m_context = glXCreateContext(display, visualInfo, shareContext, true);
|
m_context = glXCreateContext(display, visualInfo, shareContext, true);
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
#include <QtGui/QPlatformGLContext>
|
#include <QtGui/QPlatformGLContext>
|
||||||
|
|
||||||
#include "qwaylandxcompositeglxintegration.h"
|
#include "qwaylandxcompositeglxintegration.h"
|
||||||
#include "qglxconvenience.h"
|
#include <QtPlatformSupport/private/qglxconvenience_p.h>
|
||||||
|
|
||||||
class QWaylandXCompositeGLXWindow;
|
class QWaylandXCompositeGLXWindow;
|
||||||
class QWaylandShmBuffer;
|
class QWaylandShmBuffer;
|
||||||
|
@ -52,12 +52,15 @@ QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDispl
|
|||||||
return new QWaylandXCompositeGLXIntegration(waylandDisplay);
|
return new QWaylandXCompositeGLXIntegration(waylandDisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWaylandXCompositeGLXIntegration::QWaylandXCompositeGLXIntegration(QWaylandDisplay * waylandDispaly)
|
QWaylandXCompositeGLXIntegration::QWaylandXCompositeGLXIntegration(QWaylandDisplay *waylandDisplay)
|
||||||
: QWaylandGLIntegration()
|
: mWaylandDisplay(waylandDisplay)
|
||||||
, mWaylandDisplay(waylandDispaly)
|
, mWaylandComposite(0)
|
||||||
|
, mDisplay(0)
|
||||||
|
, mScreen(0)
|
||||||
|
, mRootWindow(0)
|
||||||
{
|
{
|
||||||
qDebug() << "Using XComposite-GLX";
|
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);
|
this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +115,7 @@ void QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal(wl_display *display
|
|||||||
{
|
{
|
||||||
Q_UNUSED(version);
|
Q_UNUSED(version);
|
||||||
if (strcmp(interface, "wl_xcomposite") == 0) {
|
if (strcmp(interface, "wl_xcomposite") == 0) {
|
||||||
|
qDebug("XComposite-GLX: got wl_xcomposite global");
|
||||||
QWaylandXCompositeGLXIntegration *integration = static_cast<QWaylandXCompositeGLXIntegration *>(data);
|
QWaylandXCompositeGLXIntegration *integration = static_cast<QWaylandXCompositeGLXIntegration *>(data);
|
||||||
integration->mWaylandComposite = wl_xcomposite_create(display,id,1);
|
integration->mWaylandComposite = wl_xcomposite_create(display,id,1);
|
||||||
wl_xcomposite_add_listener(integration->mWaylandComposite,&xcomposite_listener,integration);
|
wl_xcomposite_add_listener(integration->mWaylandComposite,&xcomposite_listener,integration);
|
||||||
@ -124,6 +128,8 @@ void QWaylandXCompositeGLXIntegration::rootInformation(void *data, wl_xcomposite
|
|||||||
Q_UNUSED(xcomposite);
|
Q_UNUSED(xcomposite);
|
||||||
QWaylandXCompositeGLXIntegration *integration = static_cast<QWaylandXCompositeGLXIntegration *>(data);
|
QWaylandXCompositeGLXIntegration *integration = static_cast<QWaylandXCompositeGLXIntegration *>(data);
|
||||||
|
|
||||||
|
qDebug("XComposite-GLX: xcomposite listener callback");
|
||||||
|
|
||||||
integration->mDisplay = XOpenDisplay(display_name);
|
integration->mDisplay = XOpenDisplay(display_name);
|
||||||
integration->mRootWindow = (Window) root_window;
|
integration->mRootWindow = (Window) root_window;
|
||||||
integration->mScreen = XDefaultScreen(integration->mDisplay);
|
integration->mScreen = XDefaultScreen(integration->mDisplay);
|
||||||
|
@ -112,6 +112,11 @@ void QWaylandXCompositeGLXWindow::createSurface()
|
|||||||
size = QSize(1,1);
|
size = QSize(1,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!m_glxIntegration->xDisplay()) {
|
||||||
|
qWarning("XCompositeGLXWindow: X display still null?!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
XVisualInfo *visualInfo = glXGetVisualFromFBConfig(m_glxIntegration->xDisplay(), m_config);
|
XVisualInfo *visualInfo = glXGetVisualFromFBConfig(m_glxIntegration->xDisplay(), m_config);
|
||||||
Colormap cmap = XCreateColormap(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(),
|
Colormap cmap = XCreateColormap(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(),
|
||||||
visualInfo->visual, AllocNone);
|
visualInfo->visual, AllocNone);
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
include (../xcomposite_share/xcomposite_share.pri)
|
include (../xcomposite_share/xcomposite_share.pri)
|
||||||
load(qpa/glx/convenience)
|
|
||||||
|
|
||||||
LIBS += -lXcomposite
|
LIBS += -lXcomposite
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
@ -54,8 +54,7 @@ public:
|
|||||||
QStringList QWaylandIntegrationPlugin::keys() const
|
QStringList QWaylandIntegrationPlugin::keys() const
|
||||||
{
|
{
|
||||||
QStringList list;
|
QStringList list;
|
||||||
list << "Wayland";
|
list << "wayland";
|
||||||
list << "WaylandGL";
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,9 +62,7 @@ QPlatformIntegration *QWaylandIntegrationPlugin::create(const QString& system, c
|
|||||||
{
|
{
|
||||||
Q_UNUSED(paramList);
|
Q_UNUSED(paramList);
|
||||||
if (system.toLower() == "wayland")
|
if (system.toLower() == "wayland")
|
||||||
return new QWaylandIntegration;
|
return new QWaylandIntegration();
|
||||||
if (system.toLower() == "waylandgl")
|
|
||||||
return new QWaylandIntegration(true);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -47,9 +47,7 @@
|
|||||||
#include "qwaylandinputdevice.h"
|
#include "qwaylandinputdevice.h"
|
||||||
#include "qwaylandclipboard.h"
|
#include "qwaylandclipboard.h"
|
||||||
|
|
||||||
#ifdef QT_WAYLAND_GL_SUPPORT
|
|
||||||
#include "gl_integration/qwaylandglintegration.h"
|
#include "gl_integration/qwaylandglintegration.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
|
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
|
||||||
#include "windowmanager_integration/qwaylandwindowmanagerintegration.h"
|
#include "windowmanager_integration/qwaylandwindowmanagerintegration.h"
|
||||||
@ -93,12 +91,10 @@ struct wl_visual *QWaylandDisplay::argbPremultipliedVisual()
|
|||||||
return premultiplied_argb_visual;
|
return premultiplied_argb_visual;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef QT_WAYLAND_GL_SUPPORT
|
|
||||||
QWaylandGLIntegration * QWaylandDisplay::eglIntegration()
|
QWaylandGLIntegration * QWaylandDisplay::eglIntegration()
|
||||||
{
|
{
|
||||||
return mEglIntegration;
|
return mEglIntegration;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
|
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
|
||||||
QWaylandWindowManagerIntegration *QWaylandDisplay::windowManagerIntegration()
|
QWaylandWindowManagerIntegration *QWaylandDisplay::windowManagerIntegration()
|
||||||
@ -136,9 +132,7 @@ QWaylandDisplay::QWaylandDisplay(void)
|
|||||||
|
|
||||||
wl_display_add_global_listener(mDisplay, QWaylandDisplay::displayHandleGlobal, this);
|
wl_display_add_global_listener(mDisplay, QWaylandDisplay::displayHandleGlobal, this);
|
||||||
|
|
||||||
#ifdef QT_WAYLAND_GL_SUPPORT
|
|
||||||
mEglIntegration = QWaylandGLIntegration::createGLIntegration(this);
|
mEglIntegration = QWaylandGLIntegration::createGLIntegration(this);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
|
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
|
||||||
mWindowManagerIntegration = QWaylandWindowManagerIntegration::createIntegration(this);
|
mWindowManagerIntegration = QWaylandWindowManagerIntegration::createIntegration(this);
|
||||||
@ -148,9 +142,7 @@ QWaylandDisplay::QWaylandDisplay(void)
|
|||||||
|
|
||||||
qRegisterMetaType<uint32_t>("uint32_t");
|
qRegisterMetaType<uint32_t>("uint32_t");
|
||||||
|
|
||||||
#ifdef QT_WAYLAND_GL_SUPPORT
|
|
||||||
mEglIntegration->initialize();
|
mEglIntegration->initialize();
|
||||||
#endif
|
|
||||||
|
|
||||||
connect(QAbstractEventDispatcher::instance(), SIGNAL(aboutToBlock()), this, SLOT(flushRequests()));
|
connect(QAbstractEventDispatcher::instance(), SIGNAL(aboutToBlock()), this, SLOT(flushRequests()));
|
||||||
|
|
||||||
@ -165,9 +157,7 @@ QWaylandDisplay::QWaylandDisplay(void)
|
|||||||
QWaylandDisplay::~QWaylandDisplay(void)
|
QWaylandDisplay::~QWaylandDisplay(void)
|
||||||
{
|
{
|
||||||
close(mFd);
|
close(mFd);
|
||||||
#ifdef QT_WAYLAND_GL_SUPPORT
|
|
||||||
delete mEglIntegration;
|
delete mEglIntegration;
|
||||||
#endif
|
|
||||||
wl_display_destroy(mDisplay);
|
wl_display_destroy(mDisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,6 +280,8 @@ void QWaylandDisplay::displayHandleGlobal(uint32_t id,
|
|||||||
mInputDevices.append(inputDevice);
|
mInputDevices.append(inputDevice);
|
||||||
} else if (interface == "wl_selection_offer") {
|
} else if (interface == "wl_selection_offer") {
|
||||||
QPlatformIntegration *plat = QGuiApplicationPrivate::platformIntegration();
|
QPlatformIntegration *plat = QGuiApplicationPrivate::platformIntegration();
|
||||||
|
if (!plat)
|
||||||
|
return;
|
||||||
QWaylandClipboard *clipboard = static_cast<QWaylandClipboard *>(plat->clipboard());
|
QWaylandClipboard *clipboard = static_cast<QWaylandClipboard *>(plat->clipboard());
|
||||||
clipboard->createSelectionOffer(id);
|
clipboard->createSelectionOffer(id);
|
||||||
}
|
}
|
||||||
|
@ -73,9 +73,7 @@ public:
|
|||||||
struct wl_visual *argbVisual();
|
struct wl_visual *argbVisual();
|
||||||
struct wl_visual *argbPremultipliedVisual();
|
struct wl_visual *argbPremultipliedVisual();
|
||||||
|
|
||||||
#ifdef QT_WAYLAND_GL_SUPPORT
|
|
||||||
QWaylandGLIntegration *eglIntegration();
|
QWaylandGLIntegration *eglIntegration();
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
|
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
|
||||||
QWaylandWindowManagerIntegration *windowManagerIntegration();
|
QWaylandWindowManagerIntegration *windowManagerIntegration();
|
||||||
@ -133,9 +131,8 @@ private:
|
|||||||
static void handleVisual(void *data,
|
static void handleVisual(void *data,
|
||||||
struct wl_compositor *compositor,
|
struct wl_compositor *compositor,
|
||||||
uint32_t id, uint32_t token);
|
uint32_t id, uint32_t token);
|
||||||
#ifdef QT_WAYLAND_GL_SUPPORT
|
|
||||||
QWaylandGLIntegration *mEglIntegration;
|
QWaylandGLIntegration *mEglIntegration;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
|
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
|
||||||
QWaylandWindowManagerIntegration *mWindowManagerIntegration;
|
QWaylandWindowManagerIntegration *mWindowManagerIntegration;
|
||||||
|
@ -54,16 +54,12 @@
|
|||||||
#include <QtGui/QGuiGLFormat>
|
#include <QtGui/QGuiGLFormat>
|
||||||
|
|
||||||
#include <QtGui/private/qpixmap_raster_p.h>
|
#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
|
|
||||||
|
|
||||||
QWaylandIntegration::QWaylandIntegration(bool useOpenGL)
|
#include "gl_integration/qwaylandglintegration.h"
|
||||||
|
|
||||||
|
QWaylandIntegration::QWaylandIntegration()
|
||||||
: mFontDb(new QGenericUnixFontDatabase())
|
: mFontDb(new QGenericUnixFontDatabase())
|
||||||
, mDisplay(new QWaylandDisplay())
|
, mDisplay(new QWaylandDisplay())
|
||||||
, mUseOpenGL(useOpenGL)
|
|
||||||
, mNativeInterface(new QWaylandNativeInterface)
|
, mNativeInterface(new QWaylandNativeInterface)
|
||||||
, mClipboard(0)
|
, mClipboard(0)
|
||||||
{
|
{
|
||||||
@ -84,46 +80,32 @@ bool QWaylandIntegration::hasCapability(QPlatformIntegration::Capability cap) co
|
|||||||
{
|
{
|
||||||
switch (cap) {
|
switch (cap) {
|
||||||
case ThreadedPixmaps: return true;
|
case ThreadedPixmaps: return true;
|
||||||
case OpenGL: return hasOpenGL();
|
case OpenGL: return true;
|
||||||
default: return QPlatformIntegration::hasCapability(cap);
|
default: return QPlatformIntegration::hasCapability(cap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type) const
|
QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type) const
|
||||||
{
|
{
|
||||||
#ifdef QT_WAYLAND_GL_SUPPORT
|
|
||||||
if (mUseOpenGL)
|
|
||||||
return new QGLPixmapData(type);
|
|
||||||
#endif
|
|
||||||
return new QRasterPixmapData(type);
|
return new QRasterPixmapData(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) const
|
QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) const
|
||||||
{
|
{
|
||||||
#ifdef QT_WAYLAND_GL_SUPPORT
|
if (window->surfaceType() == QWindow::OpenGLSurface)
|
||||||
bool useOpenGL = mUseOpenGL || window->surfaceType() == QWindow::OpenGLSurface;
|
|
||||||
if (useOpenGL)
|
|
||||||
return mDisplay->eglIntegration()->createEglWindow(window);
|
return mDisplay->eglIntegration()->createEglWindow(window);
|
||||||
#endif
|
|
||||||
return new QWaylandShmWindow(window);
|
return new QWaylandShmWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPlatformGLContext *QWaylandIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const
|
QPlatformGLContext *QWaylandIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const
|
||||||
{
|
{
|
||||||
#ifdef QT_WAYLAND_GL_SUPPORT
|
|
||||||
return mDisplay->eglIntegration()->createPlatformGLContext(glFormat, share);
|
return mDisplay->eglIntegration()->createPlatformGLContext(glFormat, share);
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWindowSurface *QWaylandIntegration::createWindowSurface(QWindow *window, WId winId) const
|
QWindowSurface *QWaylandIntegration::createWindowSurface(QWindow *window, WId winId) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(winId);
|
Q_UNUSED(winId);
|
||||||
#ifdef QT_WAYLAND_GL_SUPPORT
|
|
||||||
bool useOpenGL = mUseOpenGL || window->surfaceType() == QWindow::OpenGLSurface;
|
|
||||||
if (useOpenGL)
|
|
||||||
return new QWaylandGLWindowSurface(window);
|
|
||||||
#endif
|
|
||||||
return new QWaylandShmWindowSurface(window);
|
return new QWaylandShmWindowSurface(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,15 +114,6 @@ QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const
|
|||||||
return mFontDb;
|
return mFontDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QWaylandIntegration::hasOpenGL() const
|
|
||||||
{
|
|
||||||
#ifdef QT_WAYLAND_GL_SUPPORT
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
QPlatformClipboard *QWaylandIntegration::clipboard() const
|
QPlatformClipboard *QWaylandIntegration::clipboard() const
|
||||||
{
|
{
|
||||||
if (!mClipboard)
|
if (!mClipboard)
|
||||||
|
@ -52,7 +52,7 @@ class QWaylandDisplay;
|
|||||||
class QWaylandIntegration : public QPlatformIntegration
|
class QWaylandIntegration : public QPlatformIntegration
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QWaylandIntegration(bool useOpenGL = false);
|
QWaylandIntegration();
|
||||||
|
|
||||||
bool hasCapability(QPlatformIntegration::Capability cap) const;
|
bool hasCapability(QPlatformIntegration::Capability cap) const;
|
||||||
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
|
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
|
||||||
@ -69,11 +69,8 @@ public:
|
|||||||
QPlatformClipboard *clipboard() const;
|
QPlatformClipboard *clipboard() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool hasOpenGL() const;
|
|
||||||
|
|
||||||
QPlatformFontDatabase *mFontDb;
|
QPlatformFontDatabase *mFontDb;
|
||||||
QWaylandDisplay *mDisplay;
|
QWaylandDisplay *mDisplay;
|
||||||
bool mUseOpenGL;
|
|
||||||
QPlatformNativeInterface *mNativeInterface;
|
QPlatformNativeInterface *mNativeInterface;
|
||||||
mutable QPlatformClipboard *mClipboard;
|
mutable QPlatformClipboard *mClipboard;
|
||||||
};
|
};
|
||||||
|
@ -116,8 +116,8 @@ void QWaylandWindow::configure(uint32_t time, uint32_t edges,
|
|||||||
{
|
{
|
||||||
Q_UNUSED(time);
|
Q_UNUSED(time);
|
||||||
Q_UNUSED(edges);
|
Q_UNUSED(edges);
|
||||||
QRect geometry = QRect(x, y, width, height);
|
|
||||||
|
|
||||||
|
QRect geometry = QRect(x, y, width, height);
|
||||||
setGeometry(geometry);
|
setGeometry(geometry);
|
||||||
|
|
||||||
QWindowSystemInterface::handleGeometryChange(window(), geometry);
|
QWindowSystemInterface::handleGeometryChange(window(), geometry);
|
||||||
|
@ -40,3 +40,5 @@ QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_WAYLAND
|
|||||||
target.path += $$[QT_INSTALL_PLUGINS]/platforms
|
target.path += $$[QT_INSTALL_PLUGINS]/platforms
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
|
|
||||||
|
include ($$PWD/gl_integration/gl_integration.pri)
|
||||||
|
include ($$PWD/windowmanager_integration/windowmanager_integration.pri)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user