summaryrefslogtreecommitdiffstats
path: root/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp')
-rw-r--r--src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp68
1 files changed, 18 insertions, 50 deletions
diff --git a/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp b/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp
index df197ca23..1b5aea29a 100644
--- a/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp
+++ b/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp
@@ -1,48 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWaylandCompositor module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "vulkanserverbufferintegration.h"
#include "vulkanwrapper.h"
+#include <QtOpenGL/QOpenGLTexture>
#include <QtGui/QOpenGLContext>
-#include <QtGui/QOpenGLTexture>
#include <QtGui/QOffscreenSurface>
#include <QtGui/qopengl.h>
@@ -52,7 +16,7 @@
#include <QtCore/QDebug>
QT_BEGIN_NAMESPACE
-static constexpr bool extraDebug = false;
+static constexpr bool vsbiExtraDebug = false;
#define DECL_GL_FUNCTION(name, type) \
type name
@@ -215,7 +179,7 @@ QOpenGLTexture *VulkanServerBuffer::toOpenGlTexture()
return nullptr;
funcs->glCreateMemoryObjectsEXT(1, &m_memoryObject);
- if (extraDebug) qDebug() << "glCreateMemoryObjectsEXT" << hex << glGetError();
+ if (vsbiExtraDebug) qDebug() << "glCreateMemoryObjectsEXT" << Qt::hex << glGetError();
int dupfd = fcntl(m_fd, F_DUPFD_CLOEXEC, 0);
@@ -225,7 +189,7 @@ QOpenGLTexture *VulkanServerBuffer::toOpenGlTexture()
}
funcs->glImportMemoryFdEXT(m_memoryObject, m_memorySize, GL_HANDLE_TYPE_OPAQUE_FD_EXT, dupfd);
- if (extraDebug) qDebug() << "glImportMemoryFdEXT" << hex << glGetError();
+ if (vsbiExtraDebug) qDebug() << "glImportMemoryFdEXT" << Qt::hex << glGetError();
if (!m_texture)
@@ -233,13 +197,13 @@ QOpenGLTexture *VulkanServerBuffer::toOpenGlTexture()
m_texture->create();
GLuint texId = m_texture->textureId();
- if (extraDebug) qDebug() << "created texture" << texId << hex << glGetError();
+ if (vsbiExtraDebug) qDebug() << "created texture" << texId << Qt::hex << glGetError();
m_texture->bind();
- if (extraDebug) qDebug() << "bound texture" << texId << hex << glGetError();
+ if (vsbiExtraDebug) qDebug() << "bound texture" << texId << Qt::hex << glGetError();
funcs->glTexStorageMem2DEXT(GL_TEXTURE_2D, 1, m_glInternalFormat, m_size.width(), m_size.height(), m_memoryObject, 0 );
- if (extraDebug) qDebug() << "glTexStorageMem2DEXT" << hex << glGetError();
- if (extraDebug) qDebug() << "format" << hex << m_glInternalFormat << GL_RGBA8;
+ if (vsbiExtraDebug) qDebug() << "glTexStorageMem2DEXT" << Qt::hex << glGetError();
+ if (vsbiExtraDebug) qDebug() << "format" << Qt::hex << m_glInternalFormat << GL_RGBA8;
return m_texture;
@@ -258,7 +222,7 @@ void VulkanServerBuffer::releaseOpenGlTexture()
bool VulkanServerBuffer::bufferInUse()
{
- return (m_texture && m_texture->isCreated()) || resourceMap().count() > 0;
+ return (m_texture && m_texture->isCreated()) || resourceMap().size() > 0;
}
void VulkanServerBuffer::server_buffer_release(Resource *resource)
@@ -275,11 +239,12 @@ VulkanServerBufferIntegration::~VulkanServerBufferIntegration()
{
}
-void VulkanServerBufferIntegration::initializeHardware(QWaylandCompositor *compositor)
+bool VulkanServerBufferIntegration::initializeHardware(QWaylandCompositor *compositor)
{
Q_ASSERT(QGuiApplication::platformNativeInterface());
QtWaylandServer::zqt_vulkan_server_buffer_v1::init(compositor->display(), 1);
+ return true;
}
bool VulkanServerBufferIntegration::supportsFormat(QtWayland::ServerBuffer::Format format) const
@@ -303,14 +268,17 @@ QtWayland::ServerBuffer *VulkanServerBufferIntegration::createServerBufferFromIm
return new VulkanServerBuffer(this, qimage, format);
}
-QtWayland::ServerBuffer *VulkanServerBufferIntegration::createServerBufferFromData(const QByteArray &data, const QSize &size, uint glInternalFormat)
+QtWayland::ServerBuffer *
+VulkanServerBufferIntegration::createServerBufferFromData(QByteArrayView view, const QSize &size,
+ uint glInternalFormat)
{
if (!m_vulkanWrapper) {
CurrentContext current;
m_vulkanWrapper = new VulkanWrapper(current.context());
}
- auto *vImage = m_vulkanWrapper->createTextureImageFromData(reinterpret_cast<const uchar*>(data.constData()), data.size(), size, glInternalFormat);
+ auto *vImage = m_vulkanWrapper->createTextureImageFromData(
+ reinterpret_cast<const uchar *>(view.constData()), view.size(), size, glInternalFormat);
if (vImage)
return new VulkanServerBuffer(this, vImage, glInternalFormat, size);