Loading...
Searching...
No Matches
score-plugin-gfx/Gfx/Images/Process.hpp
1#pragma once
2#include <Process/Dataflow/Port.hpp>
3#include <Process/Drop/ProcessDropHandler.hpp>
4#include <Process/GenericProcessFactory.hpp>
5#include <Process/Process.hpp>
6
7#include <Gfx/CommandFactory.hpp>
8#include <Gfx/Graph/ImageNode.hpp>
9#include <Gfx/Images/Metadata.hpp>
10#include <Library/LibraryInterface.hpp>
11
12#include <score/command/PropertyCommand.hpp>
13
14#include <ossia/detail/hash_map.hpp>
15
16namespace Gfx
17{
18std::vector<score::gfx::Image>
19getImages(const ossia::value& val, const score::DocumentContext& ctx);
20ossia::value fromImageSet(const std::span<score::gfx::Image>& images);
21void releaseImages(std::vector<score::gfx::Image>& imgs);
22
24{
25public:
26 std::optional<score::gfx::Image> acquire(const QString& path);
27 void release(score::gfx::Image&& img);
28
29 static ImageCache& instance() noexcept;
30
31private:
32 ossia::hash_map<QString, std::pair<int, score::gfx::Image>> m_images;
33};
34}
35W_REGISTER_ARGTYPE(score::gfx::Image)
36
37namespace Gfx::Images
38{
39class Model final : public Process::ProcessModel
40{
41 SCORE_SERIALIZE_FRIENDS
42 PROCESS_METADATA_IMPL(Gfx::Images::Model)
43 W_OBJECT(Model)
44
45public:
46 Model(const TimeVal& duration, const Id<Process::ProcessModel>& id, QObject* parent);
47
48 template <typename Impl>
49 Model(Impl& vis, QObject* parent)
50 : Process::ProcessModel{vis, parent}
51 {
52 vis.writeTo(*this);
53 }
54
55 ~Model() override;
56
57 //std::vector<score::gfx::Image> images() const noexcept;
58 //void setImages(const std::vector<score::gfx::Image>& f);
59 // void imagesChanged() W_SIGNAL(imagesChanged);
60 // PROPERTY(
61 // std::vector<score::gfx::Image>,
62 // images READ images WRITE setImages NOTIFY imagesChanged)
63 //
64private:
65 void on_imagesChanged(const ossia::value& v);
66 QString prettyName() const noexcept override;
67 std::vector<score::gfx::Image> m_currentImages;
68};
69
70using ProcessFactory = Process::ProcessFactory_T<Gfx::Images::Model>;
71
72class LibraryHandler final : public Library::LibraryInterface
73{
74 SCORE_CONCRETE("0916759f-a5f6-4870-a96b-4e1e5efe5885")
75
76 QSet<QString> acceptedFiles() const noexcept override;
77};
78
79class DropHandler final : public Process::ProcessDropHandler
80{
81 SCORE_CONCRETE("f37aa176-d8be-45bc-b833-d014efba6157")
82public:
83 QSet<QString> mimeTypes() const noexcept override;
84 QSet<QString> fileExtensions() const noexcept override;
85 void dropCustom(
86 std::vector<ProcessDrop>& drops, const QMimeData& data,
87 const score::DocumentContext& ctx) const noexcept override;
88};
89
90}
The Process class.
Definition score-lib-process/Process/Process.hpp:62
The id_base_t class.
Definition Identifier.hpp:59
Binds the rendering pipeline to ossia processes.
Definition CameraDevice.cpp:24
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1115
Base toolkit upon which the software is built.
Definition Application.cpp:99
STL namespace.
Definition score-plugin-gfx/Gfx/Images/Process.hpp:24
Definition TimeValue.hpp:21
Definition DocumentContext.hpp:18
Image data and metadata.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:151