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
16#include <score_plugin_gfx_export.h>
17
18namespace Gfx
19{
20SCORE_PLUGIN_GFX_EXPORT std::vector<score::gfx::Image>
21getImages(const ossia::value& val, const score::DocumentContext& ctx);
22SCORE_PLUGIN_GFX_EXPORT ossia::value
23fromImageSet(const std::span<score::gfx::Image>& images);
24SCORE_PLUGIN_GFX_EXPORT void releaseImages(std::vector<score::gfx::Image>& imgs);
25
26struct SCORE_PLUGIN_GFX_EXPORT ImageCache
27{
28public:
29 std::optional<score::gfx::Image> acquire(const QString& path);
30 void release(score::gfx::Image&& img);
31
32 static ImageCache& instance() noexcept;
33
34private:
35 ossia::hash_map<QString, std::pair<int, score::gfx::Image>> m_images;
36};
37}
38W_REGISTER_ARGTYPE(score::gfx::Image)
39
40namespace Gfx::Images
41{
42class SCORE_PLUGIN_GFX_EXPORT Model final : public Process::ProcessModel
43{
44 SCORE_SERIALIZE_FRIENDS
45 PROCESS_METADATA_IMPL(Gfx::Images::Model)
46 W_OBJECT(Model)
47
48public:
49 Model(const TimeVal& duration, const Id<Process::ProcessModel>& id, QObject* parent);
50
51 template <typename Impl>
52 Model(Impl& vis, QObject* parent)
53 : Process::ProcessModel{vis, parent}
54 {
55 vis.writeTo(*this);
56 }
57
58 ~Model() override;
59
60 void mapExternalFiles(Process::ExternalFileMap& map) override;
61
62 //std::vector<score::gfx::Image> images() const noexcept;
63 //void setImages(const std::vector<score::gfx::Image>& f);
64 // void imagesChanged() W_SIGNAL(imagesChanged);
65 // PROPERTY(
66 // std::vector<score::gfx::Image>,
67 // images READ images WRITE setImages NOTIFY imagesChanged)
68 //
69private:
70 void on_imagesChanged(const ossia::value& v);
74 void finishLoad();
75 QString prettyName() const noexcept override;
76 std::vector<score::gfx::Image> m_currentImages;
77};
78
80SCORE_PLUGIN_GFX_EXPORT const QSet<QString>& supportedImageExtensions();
81
82using ProcessFactory = Process::ProcessFactory_T<Gfx::Images::Model>;
83
84class LibraryHandler final : public Library::LibraryInterface
85{
86 SCORE_CONCRETE("0916759f-a5f6-4870-a96b-4e1e5efe5885")
87
88 QSet<QString> acceptedFiles() const noexcept override;
89};
90
91class DropHandler final : public Process::ProcessDropHandler
92{
93 SCORE_CONCRETE("f37aa176-d8be-45bc-b833-d014efba6157")
94public:
95 QSet<QString> mimeTypes() const noexcept override;
96 QSet<QString> fileExtensions() const noexcept override;
97 void dropCustom(
98 std::vector<ProcessDrop>& drops, const QMimeData& data,
99 const score::DocumentContext& ctx) const noexcept override;
100};
101
102}
Collects — and in the same pass rewrites — the files a document references.
Definition ExternalFiles.hpp:93
The Process class.
Definition score-lib-process/Process/Process.hpp:80
The id_base_t class.
Definition Identifier.hpp:59
Binds the rendering pipeline to ossia processes.
Definition AssetTable.cpp:7
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1115
Base toolkit upon which the software is built.
Definition Application.cpp:83
STL namespace.
Definition score-plugin-gfx/Gfx/Images/Process.hpp:27
Definition TimeValue.hpp:21
Definition DocumentContext.hpp:18
Image data and metadata.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:463