DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit d3591e3e7b1c26e1de19dfce70aaeaba5d9f648c
parent 12d7dfb467f94cf7e56651593912289279d8b1fd
Author: falkTX <falktx@falktx.com>
Date:   Mon, 17 May 2021 23:12:41 +0100

Add VulkanImage stub, enable vulkan for Demo test

Signed-off-by: falkTX <falktx@falktx.com>

Diffstat:
Mdgl/Cairo.hpp | 4+++-
Mdgl/Vulkan.hpp | 66+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mdgl/src/Vulkan.cpp | 34++++++++++++++++++++++++++++++++++
Mtests/Demo.cpp | 7+++++++
Mtests/Makefile | 1+
5 files changed, 110 insertions(+), 2 deletions(-)

diff --git a/dgl/Cairo.hpp b/dgl/Cairo.hpp @@ -91,8 +91,10 @@ public: CairoImage& operator=(const CairoImage& image) noexcept; // FIXME this should not be needed - inline void loadFromMemory(const char* rawData, uint w, uint h, ImageFormat format) + inline void loadFromMemory(const char* rawData, uint w, uint h, ImageFormat format = kImageFormatBGRA) { loadFromMemory(rawData, Size<uint>(w, h), format); }; + inline void draw(const GraphicsContext& context) + { drawAt(context, Point<int>(0, 0)); }; inline void drawAt(const GraphicsContext& context, int x, int y) { drawAt(context, Point<int>(x, y)); }; diff --git a/dgl/Vulkan.hpp b/dgl/Vulkan.hpp @@ -17,7 +17,7 @@ #ifndef DGL_VULKAN_HPP_INCLUDED #define DGL_VULKAN_HPP_INCLUDED -#include "Base.hpp" +#include "ImageBase.hpp" #include <vulkan/vulkan_core.h> @@ -34,6 +34,70 @@ struct VulkanGraphicsContext : GraphicsContext // -------------------------------------------------------------------------------------------------------------------- +/** + Vulkan Image class. + + TODO ... + */ +class VulkanImage : public ImageBase +{ +public: + /** + Constructor for a null Image. + */ + VulkanImage(); + + /** + Constructor using raw image data. + @note @a rawData must remain valid for the lifetime of this Image. + */ + VulkanImage(const char* rawData, uint width, uint height, ImageFormat format); + + /** + Constructor using raw image data. + @note @a rawData must remain valid for the lifetime of this Image. + */ + VulkanImage(const char* rawData, const Size<uint>& size, ImageFormat format); + + /** + Constructor using another image data. + */ + VulkanImage(const VulkanImage& image); + + /** + Destructor. + */ + ~VulkanImage() override; + + /** + Load image data from memory. + @note @a rawData must remain valid for the lifetime of this Image. + */ + void loadFromMemory(const char* rawData, + const Size<uint>& size, + ImageFormat format = kImageFormatBGRA) noexcept override; + + /** + Draw this image at position @a pos using the graphics context @a context. + */ + void drawAt(const GraphicsContext& context, const Point<int>& pos) override; + + /** + TODO document this. + */ + VulkanImage& operator=(const VulkanImage& image) noexcept; + + // FIXME this should not be needed + inline void loadFromMemory(const char* rawData, uint w, uint h, ImageFormat format = kImageFormatBGRA) + { loadFromMemory(rawData, Size<uint>(w, h), format); }; + inline void draw(const GraphicsContext& context) + { drawAt(context, Point<int>(0, 0)); }; + inline void drawAt(const GraphicsContext& context, int x, int y) + { drawAt(context, Point<int>(x, y)); }; +}; + +// -------------------------------------------------------------------------------------------------------------------- + END_NAMESPACE_DGL #endif diff --git a/dgl/src/Vulkan.cpp b/dgl/src/Vulkan.cpp @@ -165,6 +165,40 @@ template class Rectangle<short>; template class Rectangle<ushort>; // ----------------------------------------------------------------------- +// VulkanImage + +VulkanImage::VulkanImage() + : ImageBase() {} + +VulkanImage::VulkanImage(const char* const rawData, const uint width, const uint height, const ImageFormat format) + : ImageBase(rawData, width, height, format) {} + +VulkanImage::VulkanImage(const char* const rawData, const Size<uint>& size, const ImageFormat format) + : ImageBase(rawData, size, format) {} + +VulkanImage::VulkanImage(const VulkanImage& image) + : ImageBase(image.rawData, image.size, image.format) {} + +VulkanImage::~VulkanImage() {} + +void VulkanImage::loadFromMemory(const char* const rdata, const Size<uint>& s, const ImageFormat fmt) noexcept +{ + ImageBase::loadFromMemory(rdata, s, fmt); +} + +void VulkanImage::drawAt(const GraphicsContext&, const Point<int>&) +{ +} + +VulkanImage& VulkanImage::operator=(const VulkanImage& image) noexcept +{ + rawData = image.rawData; + size = image.size; + format = image.format; + return *this; +} + +// ----------------------------------------------------------------------- void SubWidget::PrivateData::display(const uint width, const uint height, const double autoScaleFactor) { diff --git a/tests/Demo.cpp b/tests/Demo.cpp @@ -35,6 +35,10 @@ typedef DGL_NAMESPACE::CairoImage DemoImage; #include "../dgl/OpenGL.hpp" typedef DGL_NAMESPACE::OpenGLImage DemoImage; #endif +#ifdef DGL_VULKAN +#include "../dgl/Vulkan.hpp" +typedef DGL_NAMESPACE::VulkanImage DemoImage; +#endif START_NAMESPACE_DGL @@ -245,6 +249,9 @@ public: #ifdef DGL_OPENGL static constexpr const char* const kExampleWidgetName = "Demo - OpenGL"; #endif +#ifdef DGL_VULKAN + static constexpr const char* const kExampleWidgetName = "Demo - Vulkan"; +#endif DemoWindow(Application& app) : StandaloneWindow(app), diff --git a/tests/Makefile b/tests/Makefile @@ -27,6 +27,7 @@ TESTS += Demo.opengl WTESTS += Window.opengl endif ifeq ($(HAVE_VULKAN),true) +TESTS += Demo.vulkan WTESTS = Window.vulkan endif