From 9549f3401a70ca0359324a3e56e1e334981e5516 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 19 Apr 2021 01:43:58 +0300 Subject: [PATCH] Convert Technique and RenderPass loaders to use shared actions --- source/materials/renderpass.cpp | 8 +++++--- source/materials/renderpass.h | 5 ++++- source/materials/technique.cpp | 8 +++++--- source/materials/technique.h | 6 +++++- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/source/materials/renderpass.cpp b/source/materials/renderpass.cpp index 702bddea..033c43b1 100644 --- a/source/materials/renderpass.cpp +++ b/source/materials/renderpass.cpp @@ -150,19 +150,21 @@ void RenderPass::apply(Renderer &renderer) const } +DataFile::Loader::ActionMap RenderPass::Loader::shared_actions; + RenderPass::Loader::Loader(RenderPass &p): DataFile::CollectionObjectLoader(p, 0) { - init(); + set_actions(shared_actions); } RenderPass::Loader::Loader(RenderPass &p, Collection &c): DataFile::CollectionObjectLoader(p, &c) { - init(); + set_actions(shared_actions); } -void RenderPass::Loader::init() +void RenderPass::Loader::init_actions() { add("shader", &Loader::shader); add("material", &Loader::material_inline); diff --git a/source/materials/renderpass.h b/source/materials/renderpass.h index 8a69ad12..cb378556 100644 --- a/source/materials/renderpass.h +++ b/source/materials/renderpass.h @@ -24,12 +24,15 @@ class RenderPass public: class Loader: public DataFile::CollectionObjectLoader { + private: + static ActionMap shared_actions; + public: Loader(RenderPass &); Loader(RenderPass &, Collection &); private: - void init(); + virtual void init_actions(); static std::string get_shader_name(const std::string &); diff --git a/source/materials/technique.cpp b/source/materials/technique.cpp index 12111e5e..a4d18162 100644 --- a/source/materials/technique.cpp +++ b/source/materials/technique.cpp @@ -102,19 +102,21 @@ bool Technique::has_shaders() const } +DataFile::Loader::ActionMap Technique::Loader::shared_actions; + Technique::Loader::Loader(Technique &t): DataFile::CollectionObjectLoader(t, 0) { - init(); + set_actions(shared_actions); } Technique::Loader::Loader(Technique &t, Collection &c): DataFile::CollectionObjectLoader(t, &c) { - init(); + set_actions(shared_actions); } -void Technique::Loader::init() +void Technique::Loader::init_actions() { add("inherit", &Loader::inherit); add("pass", &Loader::pass); diff --git a/source/materials/technique.h b/source/materials/technique.h index c3b52453..8e4adf4f 100644 --- a/source/materials/technique.h +++ b/source/materials/technique.h @@ -18,12 +18,16 @@ class Technique public: class Loader: public Msp::DataFile::CollectionObjectLoader { + private: + static ActionMap shared_actions; + public: Loader(Technique &); Loader(Technique &, Collection &); private: - void init(); + virtual void init_actions(); + void inherit(const std::string &); void pass(const std::string &); }; -- 2.45.2