diff options
author | Paul Olav Tvete <paul.tvete@qt.io> | 2019-02-07 08:55:13 +0100 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@qt.io> | 2019-03-25 09:08:51 +0000 |
commit | f710489a341713c675cfd91d22ccd7bf8f29f4dd (patch) | |
tree | 02657b4f1820713e066a4edd5e7ec6fbb104a7f6 /src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp | |
parent | 77e8ee63dc9ad0a4c139f35f8cf078d1a5bd315c (diff) |
Compressed texture support for vulkan server buffers
Adding new virtual function createServerBufferFromData() to the
ServerBufferIntegration class.
Change-Id: I6009fd5aec07f1794431bd52ccd56cfae9d0f77b
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Diffstat (limited to 'src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp')
-rw-r--r-- | src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp b/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp index 5d63a64d4..0d60a9824 100644 --- a/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp +++ b/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp @@ -43,12 +43,15 @@ #include <QtGui/QOpenGLContext> #include <QtGui/QOpenGLTexture> -#include <QOffscreenSurface> +#include <QtGui/QOffscreenSurface> +#include <QtGui/qopengl.h> #include <QtCore/QDebug> QT_BEGIN_NAMESPACE +static constexpr bool extraDebug = false; + VulkanServerBuffer::VulkanServerBuffer(VulkanServerBufferIntegration *integration, const QImage &qimage, QtWayland::ServerBuffer::Format format) : QtWayland::ServerBuffer(qimage.size(),format) , m_integration(integration) @@ -75,6 +78,18 @@ VulkanServerBuffer::VulkanServerBuffer(VulkanServerBufferIntegration *integratio m_fd = vulkanWrapper->getImageInfo(m_vImage, &m_memorySize); } +VulkanServerBuffer::VulkanServerBuffer(VulkanServerBufferIntegration *integration, VulkanImageWrapper *vImage, uint glInternalFormat, const QSize &size) + : QtWayland::ServerBuffer(size, QtWayland::ServerBuffer::Custom) + , m_integration(integration) + , m_width(size.width()) + , m_height(size.height()) + , m_vImage(vImage) + , m_glInternalFormat(glInternalFormat) +{ + auto vulkanWrapper = m_integration->vulkanWrapper(); + m_fd = vulkanWrapper->getImageInfo(m_vImage, &m_memorySize); +} + VulkanServerBuffer::~VulkanServerBuffer() { delete m_texture; //this is always nullptr for now @@ -140,7 +155,7 @@ bool VulkanServerBufferIntegration::supportsFormat(QtWayland::ServerBuffer::Form case QtWayland::ServerBuffer::RGBA32: return true; case QtWayland::ServerBuffer::A8: - return false; // TODO: add more formats + return false; default: return false; } @@ -190,4 +205,20 @@ QtWayland::ServerBuffer *VulkanServerBufferIntegration::createServerBufferFromIm return new VulkanServerBuffer(this, qimage, format); } +QtWayland::ServerBuffer *VulkanServerBufferIntegration::createServerBufferFromData(const QByteArray &data, 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); + + if (vImage) + return new VulkanServerBuffer(this, vImage, glInternalFormat, size); + + qCWarning(qLcWaylandCompositorHardwareIntegration) << "could not load compressed texture"; + return nullptr; +} + QT_END_NAMESPACE |