create();
QTimer *timer = new QTimer(this);
- timer->start(10);
-
connect(timer, SIGNAL(timeout()), this, SLOT(render()));
+ timer->start(10);
updateColor();
}
d->platformWindow->setWindowTitle(d->windowTitle);
if (d->windowState != Qt::WindowNoState)
d->windowState = d->platformWindow->setWindowState(d->windowState);
+ d->platformWindow->setGeometry(geometry());
QObjectList childObjects = children();
for (int i = 0; i < childObjects.size(); i ++) {
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) {
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#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
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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
{
// #### 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);
memcpy(dstBits, constBits, (img.width() * 4) * img.height());
s.window()->damage(QRect(QPoint(), size));
+
s.window()->waitForFrameSync();
}
#include "qwaylandreadbackglxintegration.h"
-#include "qglxconvenience.h"
+#include <QtPlatformSupport/private/qglxconvenience_p.h>
class QWaylandReadbackGlxWindow;
class QWaylandShmBuffer;
return m_buffer->image()->bits();
}
+QPlatformGLSurface *QWaylandReadbackGlxWindow::createGLSurface() const
+{
+ return new QWaylandReadbackGlxSurface(const_cast<QWaylandReadbackGlxWindow *>(this));
+}
+
void QWaylandReadbackGlxWindow::createSurface()
{
QSize size(geometry().size());
-load(qpa/glx/convenience)
HEADERS += \
$$PWD/qwaylandreadbackglxintegration.h \
$$PWD/qwaylandreadbackglxwindow.h \
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);
#include <QtGui/QPlatformGLContext>
#include "qwaylandxcompositeglxintegration.h"
-#include "qglxconvenience.h"
+#include <QtPlatformSupport/private/qglxconvenience_p.h>
class QWaylandXCompositeGLXWindow;
class QWaylandShmBuffer;
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);
}
{
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);
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);
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);
include (../xcomposite_share/xcomposite_share.pri)
-load(qpa/glx/convenience)
LIBS += -lXcomposite
SOURCES += \
QStringList QWaylandIntegrationPlugin::keys() const
{
QStringList list;
- list << "Wayland";
- list << "WaylandGL";
+ list << "wayland";
return list;
}
{
Q_UNUSED(paramList);
if (system.toLower() == "wayland")
- return new QWaylandIntegration;
- if (system.toLower() == "waylandgl")
- return new QWaylandIntegration(true);
+ return new QWaylandIntegration();
return 0;
}
#include "qwaylandinputdevice.h"
#include "qwaylandclipboard.h"
-#ifdef QT_WAYLAND_GL_SUPPORT
#include "gl_integration/qwaylandglintegration.h"
-#endif
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
#include "windowmanager_integration/qwaylandwindowmanagerintegration.h"
return premultiplied_argb_visual;
}
-#ifdef QT_WAYLAND_GL_SUPPORT
QWaylandGLIntegration * QWaylandDisplay::eglIntegration()
{
return mEglIntegration;
}
-#endif
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
QWaylandWindowManagerIntegration *QWaylandDisplay::windowManagerIntegration()
wl_display_add_global_listener(mDisplay, QWaylandDisplay::displayHandleGlobal, this);
-#ifdef QT_WAYLAND_GL_SUPPORT
mEglIntegration = QWaylandGLIntegration::createGLIntegration(this);
-#endif
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
mWindowManagerIntegration = QWaylandWindowManagerIntegration::createIntegration(this);
qRegisterMetaType<uint32_t>("uint32_t");
-#ifdef QT_WAYLAND_GL_SUPPORT
mEglIntegration->initialize();
-#endif
connect(QAbstractEventDispatcher::instance(), SIGNAL(aboutToBlock()), this, SLOT(flushRequests()));
QWaylandDisplay::~QWaylandDisplay(void)
{
close(mFd);
-#ifdef QT_WAYLAND_GL_SUPPORT
delete mEglIntegration;
-#endif
wl_display_destroy(mDisplay);
}
mInputDevices.append(inputDevice);
} else if (interface == "wl_selection_offer") {
QPlatformIntegration *plat = QGuiApplicationPrivate::platformIntegration();
+ if (!plat)
+ return;
QWaylandClipboard *clipboard = static_cast<QWaylandClipboard *>(plat->clipboard());
clipboard->createSelectionOffer(id);
}
struct wl_visual *argbVisual();
struct wl_visual *argbPremultipliedVisual();
-#ifdef QT_WAYLAND_GL_SUPPORT
QWaylandGLIntegration *eglIntegration();
-#endif
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
QWaylandWindowManagerIntegration *windowManagerIntegration();
static void handleVisual(void *data,
struct wl_compositor *compositor,
uint32_t id, uint32_t token);
-#ifdef QT_WAYLAND_GL_SUPPORT
+
QWaylandGLIntegration *mEglIntegration;
-#endif
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
QWaylandWindowManagerIntegration *mWindowManagerIntegration;
#include <QtGui/QGuiGLFormat>
#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)
+QWaylandIntegration::QWaylandIntegration()
: mFontDb(new QGenericUnixFontDatabase())
, mDisplay(new QWaylandDisplay())
- , mUseOpenGL(useOpenGL)
, mNativeInterface(new QWaylandNativeInterface)
, mClipboard(0)
{
{
switch (cap) {
case ThreadedPixmaps: return true;
- case OpenGL: return hasOpenGL();
+ case OpenGL: return true;
default: return QPlatformIntegration::hasCapability(cap);
}
}
QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type) const
{
-#ifdef QT_WAYLAND_GL_SUPPORT
- if (mUseOpenGL)
- return new QGLPixmapData(type);
-#endif
return new QRasterPixmapData(type);
}
QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) const
{
-#ifdef QT_WAYLAND_GL_SUPPORT
- bool useOpenGL = mUseOpenGL || window->surfaceType() == QWindow::OpenGLSurface;
- if (useOpenGL)
+ if (window->surfaceType() == QWindow::OpenGLSurface)
return mDisplay->eglIntegration()->createEglWindow(window);
-#endif
+
return new QWaylandShmWindow(window);
}
QPlatformGLContext *QWaylandIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const
{
-#ifdef QT_WAYLAND_GL_SUPPORT
return mDisplay->eglIntegration()->createPlatformGLContext(glFormat, share);
-#endif
- return 0;
}
QWindowSurface *QWaylandIntegration::createWindowSurface(QWindow *window, WId winId) const
{
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 mFontDb;
}
-bool QWaylandIntegration::hasOpenGL() const
-{
-#ifdef QT_WAYLAND_GL_SUPPORT
- return true;
-#else
- return false;
-#endif
-}
-
QPlatformClipboard *QWaylandIntegration::clipboard() const
{
if (!mClipboard)
class QWaylandIntegration : public QPlatformIntegration
{
public:
- QWaylandIntegration(bool useOpenGL = false);
+ QWaylandIntegration();
bool hasCapability(QPlatformIntegration::Capability cap) const;
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformClipboard *clipboard() const;
private:
- bool hasOpenGL() const;
-
QPlatformFontDatabase *mFontDb;
QWaylandDisplay *mDisplay;
- bool mUseOpenGL;
QPlatformNativeInterface *mNativeInterface;
mutable QPlatformClipboard *mClipboard;
};
{
Q_UNUSED(time);
Q_UNUSED(edges);
- QRect geometry = QRect(x, y, width, height);
+ QRect geometry = QRect(x, y, width, height);
setGeometry(geometry);
QWindowSystemInterface::handleGeometryChange(window(), geometry);
target.path += $$[QT_INSTALL_PLUGINS]/platforms
INSTALLS += target
+include ($$PWD/gl_integration/gl_integration.pri)
+include ($$PWD/windowmanager_integration/windowmanager_integration.pri)