From 83791e4c0104d8b87ad2f198f9c07407c45603e3 Mon Sep 17 00:00:00 2001 From: Jorgen Lind Date: Wed, 20 Nov 2013 16:19:46 +0100 Subject: Move to new hardware structure for the platform plugins Change-Id: I0d383e4cdd59c4e4eae5506c814f0c80ecbf58ae Reviewed-by: Andy Nichols --- .../client/brcm-egl/brcm-egl.pri | 13 + .../client/brcm-egl/qwaylandbrcmeglintegration.cpp | 132 ++++++++++ .../client/brcm-egl/qwaylandbrcmeglintegration.h | 94 +++++++ .../client/brcm-egl/qwaylandbrcmeglwindow.cpp | 291 +++++++++++++++++++++ .../client/brcm-egl/qwaylandbrcmeglwindow.h | 103 ++++++++ .../client/brcm-egl/qwaylandbrcmglcontext.cpp | 105 ++++++++ .../client/brcm-egl/qwaylandbrcmglcontext.h | 83 ++++++ 7 files changed, 821 insertions(+) create mode 100644 src/hardwareintegration/client/brcm-egl/brcm-egl.pri create mode 100644 src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp create mode 100644 src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h create mode 100644 src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.cpp create mode 100644 src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.h create mode 100644 src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.cpp create mode 100644 src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.h (limited to 'src/hardwareintegration/client/brcm-egl') diff --git a/src/hardwareintegration/client/brcm-egl/brcm-egl.pri b/src/hardwareintegration/client/brcm-egl/brcm-egl.pri new file mode 100644 index 000000000..542c1c717 --- /dev/null +++ b/src/hardwareintegration/client/brcm-egl/brcm-egl.pri @@ -0,0 +1,13 @@ +INCLUDEPATH += $$PWD +LIBS += -lEGL + +SOURCES += $$PWD/qwaylandbrcmeglintegration.cpp \ + $$PWD/qwaylandbrcmglcontext.cpp \ + $$PWD/qwaylandbrcmeglwindow.cpp + +HEADERS += $$PWD/qwaylandbrcmeglintegration.h \ + $$PWD/qwaylandbrcmglcontext.h \ + $$PWD/qwaylandbrcmeglwindow.h + +CONFIG += wayland-scanner +WAYLANDCLIENTSOURCES += ../../../extensions/brcm.xml diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp new file mode 100644 index 000000000..f82ad6f97 --- /dev/null +++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandbrcmeglintegration.h" + +#include "qwaylandglintegration.h" + +#include "qwaylandbrcmeglwindow.h" +#include "qwaylandbrcmglcontext.h" + +#include + +#include "wayland-brcm-client-protocol.h" + +QT_BEGIN_NAMESPACE + +QWaylandBrcmEglIntegration::QWaylandBrcmEglIntegration(QWaylandDisplay *waylandDisplay) + : m_waylandDisplay(waylandDisplay->wl_display()) +{ + qDebug() << "Using Brcm-EGL"; + waylandDisplay->addRegistryListener(wlDisplayHandleGlobal, this); +} + +void QWaylandBrcmEglIntegration::wlDisplayHandleGlobal(void *data, struct wl_registry *registry, uint32_t id, const QString &interface, uint32_t version) +{ + Q_UNUSED(version); + if (interface == "qt_brcm") { + QWaylandBrcmEglIntegration *integration = static_cast(data); + integration->m_waylandBrcm = static_cast(wl_registry_bind(registry, id, &qt_brcm_interface, 1)); + } +} + +qt_brcm *QWaylandBrcmEglIntegration::waylandBrcm() const +{ + return m_waylandBrcm; +} + +QWaylandBrcmEglIntegration::~QWaylandBrcmEglIntegration() +{ + eglTerminate(m_eglDisplay); +} + +void QWaylandBrcmEglIntegration::initialize() +{ + EGLint major,minor; + m_eglDisplay = eglGetDisplay((EGLNativeDisplayType)EGL_DEFAULT_DISPLAY); + if (m_eglDisplay == NULL) { + qWarning("EGL not available"); + } else { + if (!eglInitialize(m_eglDisplay, &major, &minor)) { + qWarning("failed to initialize EGL display"); + return; + } + + eglFlushBRCM = (PFNEGLFLUSHBRCMPROC)eglGetProcAddress("eglFlushBRCM"); + if (!eglFlushBRCM) { + qWarning("failed to resolve eglFlushBRCM, performance will suffer"); + } + + eglCreateGlobalImageBRCM = ::eglCreateGlobalImageBRCM; + if (!eglCreateGlobalImageBRCM) { + qWarning("failed to resolve eglCreateGlobalImageBRCM"); + return; + } + + eglDestroyGlobalImageBRCM = ::eglDestroyGlobalImageBRCM; + if (!eglDestroyGlobalImageBRCM) { + qWarning("failed to resolve eglDestroyGlobalImageBRCM"); + return; + } + } +} + +QWaylandWindow *QWaylandBrcmEglIntegration::createEglWindow(QWindow *window) +{ + return new QWaylandBrcmEglWindow(window); +} + +QPlatformOpenGLContext *QWaylandBrcmEglIntegration::createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const +{ + return new QWaylandBrcmGLContext(m_eglDisplay, glFormat, share); +} + +EGLDisplay QWaylandBrcmEglIntegration::eglDisplay() const +{ + return m_eglDisplay; +} + +QWaylandGLIntegration *QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) +{ + return new QWaylandBrcmEglIntegration(waylandDisplay); +} + +QT_END_NAMESPACE diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h new file mode 100644 index 000000000..f1100d8de --- /dev/null +++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDBRCMEGLINTEGRATION_H +#define QWAYLANDBRCMEGLINTEGRATION_H + +#include "qwaylandglintegration.h" + +#include +#include + +#define EGL_EGLEXT_PROTOTYPES +#include + +#include + +QT_BEGIN_NAMESPACE + +class QWaylandWindow; +class QWindow; + +struct qt_brcm; + +class QWaylandBrcmEglIntegration : public QWaylandGLIntegration +{ +public: + QWaylandBrcmEglIntegration(QWaylandDisplay *waylandDisplay); + ~QWaylandBrcmEglIntegration(); + + void initialize(); + + bool supportsThreadedOpenGL() const { return true; } + + QWaylandWindow *createEglWindow(QWindow *window); + QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const; + + EGLDisplay eglDisplay() const; + + struct qt_brcm *waylandBrcm() const; + + PFNEGLFLUSHBRCMPROC eglFlushBRCM; + PFNEGLCREATEGLOBALIMAGEBRCMPROC eglCreateGlobalImageBRCM; + PFNEGLDESTROYGLOBALIMAGEBRCMPROC eglDestroyGlobalImageBRCM; + +private: + static void wlDisplayHandleGlobal(void *data, struct wl_registry *registry, uint32_t id, const QString &interface, uint32_t version); + + struct wl_display *m_waylandDisplay; + struct qt_brcm *m_waylandBrcm; + + EGLDisplay m_eglDisplay; +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDBRCMEGLINTEGRATION_H diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.cpp b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.cpp new file mode 100644 index 000000000..c7073e149 --- /dev/null +++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.cpp @@ -0,0 +1,291 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandbrcmeglwindow.h" + +#include "qwaylandbuffer.h" +#include "qwaylandscreen.h" +#include "qwaylandbrcmglcontext.h" + +#include + +#include +#include + +#define EGL_EGLEXT_PROTOTYPES +#include + +#include "wayland-brcm-client-protocol.h" +#include "wayland-client.h" + +QT_BEGIN_NAMESPACE + +class QWaylandBrcmBuffer : public QWaylandBuffer +{ +public: + QWaylandBrcmBuffer(QWaylandDisplay *display, + struct qt_brcm *brcm, + const QSize &size, + EGLint *data, + int count, + struct wl_event_queue *eventQueue) + : m_size(size) + , m_released(true) + , m_display(display) + , m_eventQueue(eventQueue) + { + wl_array_init(&m_array); + m_data = static_cast(wl_array_add(&m_array, count * sizeof(EGLint))); + + for (int i = 0; i < count; ++i) + m_data[i] = data[i]; + + mBuffer = qt_brcm_create_buffer(brcm, size.width(), size.height(), &m_array); + wl_proxy_set_queue(reinterpret_cast(mBuffer), m_eventQueue); + + static const struct wl_buffer_listener buffer_listener = { + QWaylandBrcmBuffer::buffer_release + }; + + wl_buffer_add_listener(mBuffer, &buffer_listener, this); + } + + ~QWaylandBrcmBuffer() + { + wl_array_release(&m_array); + } + + QSize size() const { return m_size; } + + void bind() + { + m_released = false; + } + + void waitForRelease() + { + if (m_released) + return; + while (!m_released) { + wl_display_dispatch_queue(m_display->wl_display(), m_eventQueue); + } + } + + static void buffer_release(void *data, wl_buffer *buffer) + { + Q_UNUSED(buffer); + static_cast(data)->m_released = true; + } + +private: + + QSize m_size; + bool m_released; + wl_array m_array; + EGLint *m_data; + QWaylandDisplay *m_display; + struct wl_event_queue *m_eventQueue; +}; + +QWaylandBrcmEglWindow::QWaylandBrcmEglWindow(QWindow *window) + : QWaylandWindow(window) + , m_eglIntegration(static_cast(mDisplay->eglIntegration())) + , m_eglConfig(0) + , m_format(window->format()) + , m_current(0) + , m_count(0) + , m_eventQueue(wl_display_create_queue(mDisplay->wl_display())) +{ +} + +QWaylandBrcmEglWindow::~QWaylandBrcmEglWindow() +{ + destroyEglSurfaces(); +} + +QWaylandWindow::WindowType QWaylandBrcmEglWindow::windowType() const +{ + return QWaylandWindow::Egl; +} + +void QWaylandBrcmEglWindow::setGeometry(const QRect &rect) +{ + destroyEglSurfaces(); + QWaylandWindow::setGeometry(rect); +} + +QSurfaceFormat QWaylandBrcmEglWindow::format() const +{ + return m_format; +} + +void QWaylandBrcmEglWindow::destroyEglSurfaces() +{ + for (int i = 0; i < m_count; ++i) { + if (m_eglSurfaces[i]) { + eglDestroySurface(m_eglIntegration->eglDisplay(), m_eglSurfaces[i]); + m_eglSurfaces[i] = 0; + // the server does this + //m_eglIntegration->eglDestroyGlobalImageBRCM(&m_globalImages[5*i]); + delete m_buffers[i]; + } + } + + m_count = 0; + m_current = 0; +} + +QSurfaceFormat brcmFixFormat(const QSurfaceFormat &f) +{ + QSurfaceFormat format = f; + format.setRedBufferSize(8); + format.setGreenBufferSize(8); + format.setBlueBufferSize(8); + format.setAlphaBufferSize(8); + return format; +} + +void QWaylandBrcmEglWindow::createEglSurfaces() +{ + QSize size(geometry().size()); + + m_count = window()->format().swapBehavior() == QSurfaceFormat::TripleBuffer ? 3 : 2; + + m_eglConfig = q_configFromGLFormat(m_eglIntegration->eglDisplay(), brcmFixFormat(window()->format()), true, EGL_PIXMAP_BIT); + + m_format = q_glFormatFromConfig(m_eglIntegration->eglDisplay(), m_eglConfig); + + EGLint pixel_format = EGL_PIXEL_FORMAT_ARGB_8888_BRCM; + + EGLint rt; + eglGetConfigAttrib(m_eglIntegration->eglDisplay(), m_eglConfig, EGL_RENDERABLE_TYPE, &rt); + + if (rt & EGL_OPENGL_ES_BIT) { + pixel_format |= EGL_PIXEL_FORMAT_RENDER_GLES_BRCM; + pixel_format |= EGL_PIXEL_FORMAT_GLES_TEXTURE_BRCM; + } + + if (rt & EGL_OPENGL_ES2_BIT) { + pixel_format |= EGL_PIXEL_FORMAT_RENDER_GLES2_BRCM; + pixel_format |= EGL_PIXEL_FORMAT_GLES2_TEXTURE_BRCM; + } + + if (rt & EGL_OPENVG_BIT) { + pixel_format |= EGL_PIXEL_FORMAT_RENDER_VG_BRCM; + pixel_format |= EGL_PIXEL_FORMAT_VG_IMAGE_BRCM; + } + + if (rt & EGL_OPENGL_BIT) { + pixel_format |= EGL_PIXEL_FORMAT_RENDER_GL_BRCM; + } + + memset(m_globalImages, 0, 5 * m_count * sizeof(EGLint)); + for (int i = 0; i < m_count; ++i) { + m_eglIntegration->eglCreateGlobalImageBRCM(size.width(), size.height(), pixel_format, + 0, size.width() * 4, &m_globalImages[5*i]); + + m_globalImages[5*i+2] = size.width(); + m_globalImages[5*i+3] = size.height(); + m_globalImages[5*i+4] = pixel_format; + + EGLint attrs[] = { + EGL_VG_COLORSPACE, EGL_VG_COLORSPACE_sRGB, + EGL_VG_ALPHA_FORMAT, pixel_format & EGL_PIXEL_FORMAT_ARGB_8888_PRE_BRCM ? EGL_VG_ALPHA_FORMAT_PRE : EGL_VG_ALPHA_FORMAT_NONPRE, + EGL_NONE + }; + + m_eglSurfaces[i] = eglCreatePixmapSurface(m_eglIntegration->eglDisplay(), m_eglConfig, (EGLNativePixmapType)&m_globalImages[5*i], attrs); + if (m_eglSurfaces[i] == EGL_NO_SURFACE) + qFatal("eglCreatePixmapSurface failed: %x, global image id: %d %d\n", eglGetError(), m_globalImages[5*i], m_globalImages[5*i+1]); + m_buffers[i] = new QWaylandBrcmBuffer(mDisplay, m_eglIntegration->waylandBrcm(), size, &m_globalImages[5*i], 5, m_eventQueue); + } +} + +void QWaylandBrcmEglWindow::swapBuffers() +{ + if (m_eglIntegration->eglFlushBRCM) { + m_eglIntegration->eglFlushBRCM(); + } else { + glFlush(); + glFinish(); + } + + m_buffers[m_current]->bind(); + + m_mutex.lock(); + m_pending << m_buffers[m_current]; + m_mutex.unlock(); + + // can't use a direct call since swapBuffers might be called from a separate thread + QMetaObject::invokeMethod(this, "flushBuffers"); + + m_current = (m_current + 1) % m_count; + + m_buffers[m_current]->waitForRelease(); +} + +void QWaylandBrcmEglWindow::flushBuffers() +{ + if (m_pending.isEmpty()) + return; + + QSize size = geometry().size(); + + m_mutex.lock(); + while (!m_pending.isEmpty()) { + QWaylandBrcmBuffer *buffer = m_pending.takeFirst(); + attach(buffer, 0, 0); + damage(QRect(QPoint(), size)); + commit(); + } + m_mutex.unlock(); + + mDisplay->flushRequests(); +} + +bool QWaylandBrcmEglWindow::makeCurrent(EGLContext context) +{ + if (!m_count) + const_cast(this)->createEglSurfaces(); + return eglMakeCurrent(m_eglIntegration->eglDisplay(), m_eglSurfaces[m_current], m_eglSurfaces[m_current], context); +} + +QT_END_NAMESPACE diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.h b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.h new file mode 100644 index 000000000..5a3fa0461 --- /dev/null +++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDBRCMEGLWINDOW_H +#define QWAYLANDBRCMEGLWINDOW_H + +#include "qwaylandwindow.h" +#include "qwaylandbrcmeglintegration.h" + +#include + +#include + +QT_BEGIN_NAMESPACE + +class QWaylandGLContext; +class QWaylandBrcmBuffer; + +class QWaylandBrcmEglWindow : public QWaylandWindow +{ + Q_OBJECT +public: + QWaylandBrcmEglWindow(QWindow *window); + ~QWaylandBrcmEglWindow(); + WindowType windowType() const; + void setGeometry(const QRect &rect); + + QSurfaceFormat format() const; + + bool makeCurrent(EGLContext context); + void swapBuffers(); + +private slots: + void flushBuffers(); + +private: + void createEglSurfaces(); + void destroyEglSurfaces(); + + QWaylandBrcmEglIntegration *m_eglIntegration; + struct wl_egl_window *m_waylandEglWindow; + + const QWaylandWindow *m_parentWindow; + + EGLConfig m_eglConfig; + + EGLint m_globalImages[3*5]; + EGLSurface m_eglSurfaces[3]; + + QWaylandBrcmBuffer *m_buffers[3]; + QSurfaceFormat m_format; + + struct wl_event_queue *m_eventQueue; + + int m_current; + int m_count; + + QList m_pending; + + QMutex m_mutex; +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDBRCMEGLWINDOW_H diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.cpp b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.cpp new file mode 100644 index 000000000..dfb86e54c --- /dev/null +++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.cpp @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandbrcmglcontext.h" + +#include "qwaylanddisplay.h" +#include "qwaylandwindow.h" +#include "qwaylandbrcmeglwindow.h" + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +extern QSurfaceFormat brcmFixFormat(const QSurfaceFormat &format); + +QWaylandBrcmGLContext::QWaylandBrcmGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformOpenGLContext *share) + : QPlatformOpenGLContext() + , m_eglDisplay(eglDisplay) + , m_config(q_configFromGLFormat(m_eglDisplay, brcmFixFormat(format), true)) + , m_format(q_glFormatFromConfig(m_eglDisplay, m_config)) +{ + EGLContext shareEGLContext = share ? static_cast(share)->eglContext() : EGL_NO_CONTEXT; + + eglBindAPI(EGL_OPENGL_ES_API); + + QVector eglContextAttrs; + eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); + eglContextAttrs.append(format.majorVersion() == 1 ? 1 : 2); + eglContextAttrs.append(EGL_NONE); + + m_context = eglCreateContext(m_eglDisplay, m_config, shareEGLContext, eglContextAttrs.constData()); +} + +QWaylandBrcmGLContext::~QWaylandBrcmGLContext() +{ + eglDestroyContext(m_eglDisplay, m_context); +} + +bool QWaylandBrcmGLContext::makeCurrent(QPlatformSurface *surface) +{ + return static_cast(surface)->makeCurrent(m_context); +} + +void QWaylandBrcmGLContext::doneCurrent() +{ + eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); +} + +void QWaylandBrcmGLContext::swapBuffers(QPlatformSurface *surface) +{ + static_cast(surface)->swapBuffers(); +} + +void (*QWaylandBrcmGLContext::getProcAddress(const QByteArray &procName)) () +{ + return eglGetProcAddress(procName.constData()); +} + +EGLConfig QWaylandBrcmGLContext::eglConfig() const +{ + return m_config; +} + +QT_END_NAMESPACE diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.h b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.h new file mode 100644 index 000000000..7beef166b --- /dev/null +++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDBRCMGLCONTEXT_H +#define QWAYLANDBRCMGLCONTEXT_H + +#include "qwaylanddisplay.h" + +#include + +#include + +QT_BEGIN_NAMESPACE + +class QWaylandWindow; +class QWaylandGLWindowSurface; + +class QWaylandBrcmGLContext : public QPlatformOpenGLContext { +public: + QWaylandBrcmGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformOpenGLContext *share); + ~QWaylandBrcmGLContext(); + + void swapBuffers(QPlatformSurface *surface); + + bool makeCurrent(QPlatformSurface *surface); + void doneCurrent(); + + void (*getProcAddress(const QByteArray &procName)) (); + + QSurfaceFormat format() const { return m_format; } + + EGLConfig eglConfig() const; + EGLContext eglContext() const { return m_context; } + +private: + EGLDisplay m_eglDisplay; + + EGLContext m_context; + EGLConfig m_config; + QSurfaceFormat m_format; +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDBRCMGLCONTEXT_H -- cgit v1.2.3