diff options
Diffstat (limited to 'src/plugins/platforms/wayland/gl_integration/readback_glx')
7 files changed, 0 insertions, 591 deletions
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp deleted file mode 100644 index 850e7bb0ac..0000000000 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp +++ /dev/null @@ -1,134 +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 "qwaylandreadbackglxcontext.h" - -#include "qwaylandshmbackingstore.h" -#include "qwaylandreadbackglxwindow.h" - -#include <QtGui/QOpenGLContext> -#include <QtCore/QDebug> - -static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type) -{ - const int width = img.width(); - const int height = img.height(); - - if (pixel_type == GL_UNSIGNED_INT_8_8_8_8_REV - || (pixel_type == GL_UNSIGNED_BYTE && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) - { - for (int i = 0; i < height; ++i) { - uint *p = (uint *) img.scanLine(i); - for (int x = 0; x < width; ++x) - p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00); - } - } else { - for (int i = 0; i < height; ++i) { - uint *p = (uint *) img.scanLine(i); - for (int x = 0; x < width; ++x) - p[x] = (p[x] << 8) | ((p[x] >> 24) & 0xff); - } - } -} - -QWaylandReadbackGlxContext::QWaylandReadbackGlxContext(const QSurfaceFormat &format, - QPlatformOpenGLContext *share, Display *display, int screen) - : m_display(display) -{ - GLXFBConfig config = qglx_findConfig(display, screen, format, GLX_PIXMAP_BIT); - - GLXContext shareContext = share ? static_cast<QWaylandReadbackGlxContext *>(share)->m_context : 0; - - XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display, config); - m_context = glXCreateContext(display, visualInfo, shareContext, TRUE); - m_format = qglx_surfaceFormatFromGLXFBConfig(display, config, m_context); -} - -QSurfaceFormat QWaylandReadbackGlxContext::format() const -{ - return m_format; -} - -bool QWaylandReadbackGlxContext::makeCurrent(QPlatformSurface *surface) -{ - GLXPixmap glxPixmap = static_cast<QWaylandReadbackGlxWindow *>(surface)->glxPixmap(); - - return glXMakeCurrent(m_display, glxPixmap, m_context); -} - -void QWaylandReadbackGlxContext::doneCurrent() -{ - glXMakeCurrent(m_display, 0, 0); -} - -void QWaylandReadbackGlxContext::swapBuffers(QPlatformSurface *surface) -{ - // #### makeCurrent() directly on the platform context doesn't update QOpenGLContext::currentContext() - if (QOpenGLContext::currentContext()->handle() != this) - makeCurrent(surface); - - QWaylandReadbackGlxWindow *w = static_cast<QWaylandReadbackGlxWindow *>(surface); - - QSize size = w->geometry().size(); - - QImage img(size, QImage::Format_ARGB32); - const uchar *constBits = img.bits(); - void *pixels = const_cast<uchar *>(constBits); - - glReadPixels(0, 0, size.width(), size.height(), GL_RGBA,GL_UNSIGNED_BYTE, pixels); - - img = img.mirrored(); - qgl_byteSwapImage(img, GL_UNSIGNED_INT_8_8_8_8_REV); - constBits = img.bits(); - - const uchar *constDstBits = w->buffer(); - uchar *dstBits = const_cast<uchar *>(constDstBits); - memcpy(dstBits, constBits, (img.width() * 4) * img.height()); - - w->damage(QRect(QPoint(), size)); - - w->waitForFrameSync(); -} - -void (*QWaylandReadbackGlxContext::getProcAddress(const QByteArray &procName)) () -{ - return glXGetProcAddress(reinterpret_cast<const GLubyte *>(procName.constData())); -} diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h deleted file mode 100644 index 7b5eeece93..0000000000 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h +++ /dev/null @@ -1,76 +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 QWAYLANDREADBACKGLXCONTEXT_H -#define QWAYLANDREADBACKGLXCONTEXT_H - -#include <QPlatformOpenGLContext> -#include <QSurfaceFormat> - -#include "qwaylandreadbackglxintegration.h" - -#include <QtPlatformSupport/private/qglxconvenience_p.h> - -class QWaylandReadbackGlxWindow; -class QWaylandShmBuffer; - -class QWaylandReadbackGlxContext : public QPlatformOpenGLContext -{ -public: - QWaylandReadbackGlxContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, Display *display, int screen); - - QSurfaceFormat format() const; - - void swapBuffers(QPlatformSurface *surface); - - bool makeCurrent(QPlatformSurface *surface); - void doneCurrent(); - - void (*getProcAddress(const QByteArray &procName)) (); - -private: - GLXContext m_context; - - Display *m_display; - QSurfaceFormat m_format; -}; - -#endif // QWAYLANDREADBACKGLXCONTEXT_H diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp deleted file mode 100644 index 752bb06a43..0000000000 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp +++ /dev/null @@ -1,102 +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 "qwaylandreadbackglxintegration.h" - -#include "qwaylandreadbackglxwindow.h" - -#include <QtCore/QDebug> - -QWaylandReadbackGlxIntegration::QWaylandReadbackGlxIntegration(QWaylandDisplay * waylandDispaly) - : QWaylandGLIntegration() - , mWaylandDisplay(waylandDispaly) -{ - qDebug() << "Using Readback-GLX"; - char *display_name = getenv("DISPLAY"); - mDisplay = XOpenDisplay(display_name); - mScreen = XDefaultScreen(mDisplay); - mRootWindow = XDefaultRootWindow(mDisplay); - XSync(mDisplay, False); -} - -QWaylandReadbackGlxIntegration::~QWaylandReadbackGlxIntegration() -{ - XCloseDisplay(mDisplay); -} - -void QWaylandReadbackGlxIntegration::initialize() -{ -} - -QWaylandWindow * QWaylandReadbackGlxIntegration::createEglWindow(QWindow *window) -{ - return new QWaylandReadbackGlxWindow(window,this); -} - -QPlatformOpenGLContext *QWaylandReadbackGlxIntegration::createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const -{ - return new QWaylandReadbackGlxContext(glFormat, share, mDisplay, mScreen); -} - -QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) -{ - return new QWaylandReadbackGlxIntegration(waylandDisplay); -} - -Display * QWaylandReadbackGlxIntegration::xDisplay() const -{ - return mDisplay; -} - -int QWaylandReadbackGlxIntegration::screen() const -{ - return mScreen; -} - -Window QWaylandReadbackGlxIntegration::rootWindow() const -{ - return mRootWindow; -} - -QWaylandDisplay * QWaylandReadbackGlxIntegration::waylandDisplay() const -{ - return mWaylandDisplay; -} diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h deleted file mode 100644 index ee50d74ebd..0000000000 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h +++ /dev/null @@ -1,81 +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 QWAYLANDREADBACKGLXINTEGRATION_H -#define QWAYLANDREADBACKGLXINTEGRATION_H - -#include "gl_integration/qwaylandglintegration.h" - -#include <QtCore/QTextStream> -#include <QtCore/QDataStream> -#include <QtCore/QMetaType> -#include <QtCore/QVariant> -#include <QtGui/QWindow> - -#include <X11/Xlib.h> - -class QWaylandReadbackGlxIntegration : public QWaylandGLIntegration -{ -public: - QWaylandReadbackGlxIntegration(QWaylandDisplay * waylandDispaly); - ~QWaylandReadbackGlxIntegration(); - - void initialize(); - - QWaylandWindow *createEglWindow(QWindow *window); - QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const; - - QWaylandDisplay *waylandDisplay() const; - - Display *xDisplay() const; - int screen() const; - Window rootWindow() const; - -private: - QWaylandDisplay *mWaylandDisplay; - - Display *mDisplay; - int mScreen; - Window mRootWindow; - -}; - -#endif // QWAYLANDREADBACKGLXINTEGRATION_H diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp deleted file mode 100644 index 35c3ca3154..0000000000 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp +++ /dev/null @@ -1,114 +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 <QtDebug> - -#include "qwaylandreadbackglxwindow.h" -#include "qwaylandshmbackingstore.h" - -QWaylandReadbackGlxWindow::QWaylandReadbackGlxWindow(QWindow *window, QWaylandReadbackGlxIntegration *glxIntegration) - : QWaylandShmWindow(window) - , m_glxIntegration(glxIntegration) - , m_buffer(0) - , m_pixmap(0) - , m_config(0) - , m_glxPixmap(0) - , m_window(window) -{ -} - -QWaylandWindow::WindowType QWaylandReadbackGlxWindow::windowType() const -{ - //yeah. this type needs a new name - return QWaylandWindow::Egl; -} - -void QWaylandReadbackGlxWindow::setGeometry(const QRect &rect) -{ - QWaylandShmWindow::setGeometry(rect); - - if (m_pixmap) { - delete mBuffer; - //XFreePixmap deletes the glxPixmap as well - XFreePixmap(m_glxIntegration->xDisplay(), m_pixmap); - m_pixmap = 0; - } -} - -GLXPixmap QWaylandReadbackGlxWindow::glxPixmap() const -{ - if (!m_pixmap) - const_cast<QWaylandReadbackGlxWindow *>(this)->createSurface(); - - return m_glxPixmap; -} - -uchar *QWaylandReadbackGlxWindow::buffer() -{ - return m_buffer->image()->bits(); -} - -void QWaylandReadbackGlxWindow::createSurface() -{ - QSize size(geometry().size()); - if (size.isEmpty()) { - //QGLWidget wants a context for a window without geometry - size = QSize(1,1); - } - - waitForFrameSync(); - - m_buffer = new QWaylandShmBuffer(m_glxIntegration->waylandDisplay(), size, QImage::Format_ARGB32); - attach(m_buffer); - - int depth = XDefaultDepth(m_glxIntegration->xDisplay(), m_glxIntegration->screen()); - m_pixmap = XCreatePixmap(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(), size.width(), size.height(), depth); - XSync(m_glxIntegration->xDisplay(), False); - - if (!m_config) - m_config = qglx_findConfig(m_glxIntegration->xDisplay(), m_glxIntegration->screen(), m_window->format()); - - m_glxPixmap = glXCreatePixmap(m_glxIntegration->xDisplay(), m_config, m_pixmap,0); - - if (!m_glxPixmap) - qDebug() << "Could not make glx surface out of pixmap :("; -} - diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h deleted file mode 100644 index c92646c80d..0000000000 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h +++ /dev/null @@ -1,73 +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 QWAYLANDREADBACKGLXWINDOW_H -#define QWAYLANDREADBACKGLXWINDOW_H - -#include "qwaylandshmwindow.h" -#include "qwaylandreadbackglxintegration.h" -#include "qwaylandreadbackglxcontext.h" - -class QWaylandReadbackGlxWindow : public QWaylandShmWindow -{ -public: - QWaylandReadbackGlxWindow(QWindow *window, QWaylandReadbackGlxIntegration *glxIntegration); - WindowType windowType() const; - - void setGeometry(const QRect &rect); - - Pixmap glxPixmap() const; - - uchar *buffer(); - -private: - void createSurface(); - - QWaylandReadbackGlxIntegration *m_glxIntegration; - QWaylandShmBuffer *m_buffer; - - Pixmap m_pixmap; - GLXFBConfig m_config; - GLXPixmap m_glxPixmap; - QWindow *m_window; -}; - -#endif // QWAYLANDREADBACKGLXWINDOW_H 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 deleted file mode 100644 index 746d594fa2..0000000000 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri +++ /dev/null @@ -1,11 +0,0 @@ -HEADERS += \ - $$PWD/qwaylandreadbackglxintegration.h \ - $$PWD/qwaylandreadbackglxwindow.h \ - $$PWD/qwaylandreadbackglxcontext.h - -SOURCES += \ - $$PWD/qwaylandreadbackglxintegration.cpp \ - $$PWD/qwaylandreadbackglxwindow.cpp \ - $$PWD/qwaylandreadbackglxcontext.cpp - -LIBS += -lX11 |