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 namespace Gfx
17 {
18 std::vector<score::gfx::Image> getImages(const ossia::value& val);
19 ossia::value fromImageSet(const tcb::span<score::gfx::Image>& images);
20 void releaseImages(std::vector<score::gfx::Image>& imgs);
21 
22 struct ImageCache
23 {
24 public:
25  std::optional<score::gfx::Image> acquire(const std::string& path);
26  void release(score::gfx::Image&& img);
27 
28  static ImageCache& instance() noexcept;
29 
30 private:
31  ossia::hash_map<std::string, std::pair<int, score::gfx::Image>> m_images;
32 };
33 }
34 W_REGISTER_ARGTYPE(score::gfx::Image)
35 
36 namespace Gfx::Images
37 {
38 class Model final : public Process::ProcessModel
39 {
40  SCORE_SERIALIZE_FRIENDS
41  PROCESS_METADATA_IMPL(Gfx::Images::Model)
42  W_OBJECT(Model)
43 
44 public:
45  constexpr bool hasExternalUI() { return false; }
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  //
64 private:
65  void on_imagesChanged(const ossia::value& v);
66  QString prettyName() const noexcept override;
67  std::vector<score::gfx::Image> m_currentImages;
68 };
69 
71 
73 {
74  SCORE_CONCRETE("0916759f-a5f6-4870-a96b-4e1e5efe5885")
75 
76  QSet<QString> acceptedFiles() const noexcept override;
77 };
78 
80 {
81  SCORE_CONCRETE("f37aa176-d8be-45bc-b833-d014efba6157")
82 public:
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 }
Definition: score-plugin-gfx/Gfx/Images/Process.hpp:80
Definition: score-plugin-gfx/Gfx/Images/Process.hpp:73
Definition: score-plugin-gfx/Gfx/Images/Process.hpp:39
Definition: LibraryInterface.hpp:22
Definition: ProcessDropHandler.hpp:25
Definition: GenericProcessFactory.hpp:15
The Process class.
Definition: score-lib-process/Process/Process.hpp:61
The id_base_t class.
Definition: Identifier.hpp:57
Binds the rendering pipeline to ossia processes.
Definition: CameraDevice.cpp:28
Definition: score-plugin-gfx/Gfx/Images/Process.hpp:23
Definition: TimeValue.hpp:21
Definition: DocumentContext.hpp:18
Image data and metadata.
Definition: score-plugin-gfx/Gfx/Graph/Utils.hpp:146