diff --git a/include/pd/common.hpp b/include/pd/common.hpp index 3b8901b..0ed260d 100644 --- a/include/pd/common.hpp +++ b/include/pd/common.hpp @@ -71,6 +71,7 @@ void Log(LogLevel lvl, std::format_string fmt, Args&&... args) { } template std::string TypeName() { +#ifdef __RTTI #if defined(__GNUG__) && !defined(_MSC_VER) int res = 0; std::unique_ptr up{ @@ -79,6 +80,9 @@ std::string TypeName() { #else return typeid(T).name(); // no demangler available :/ #endif +#else + return ""; +#endif } } // namespace PD diff --git a/include/pd/core/pool.hpp b/include/pd/core/pool.hpp index 6ce6101..529bd28 100644 --- a/include/pd/core/pool.hpp +++ b/include/pd/core/pool.hpp @@ -107,6 +107,31 @@ class Pool { pPos = 0; } + /** + * Copy the data of another pool + */ + void AppendCopy(const Pool& v) { + if (!v.size()) return; + ExpandIf(v.size()); + for (size_t i = 0; i < v.size(); i++) { + pData[pPos + i] = v.pData[i]; + } + pPos += v.size(); + } + + /** + * Move the data of another pool + */ + void AppendMove(Pool& v) { + if (!v.size()) return; + ExpandIf(v.size()); + for (size_t i = 0; i < v.size(); i++) { + pData[pPos + i] = std::move(v.pData[i]); + } + pPos += v.size(); + v.ResetFast(); + } + size_t size() const { return pPos; } size_t capacity() const { return pCap; } T& at(size_t idx) { return pData[idx]; } diff --git a/include/pd/lithium/texture.hpp b/include/pd/lithium/texture.hpp index 9f25d3e..b88440b 100644 --- a/include/pd/lithium/texture.hpp +++ b/include/pd/lithium/texture.hpp @@ -16,7 +16,7 @@ enum class TextureFormat { A8, }; namespace Li { -static int TextureFormat2Bpp(TextureFormat fmt) { +inline int TextureFormat2Bpp(TextureFormat fmt) { switch (fmt) { case PD::TextureFormat::A8: return 1; diff --git a/source/lithium/drawlist.cpp b/source/lithium/drawlist.cpp index ef7c89a..8d12693 100644 --- a/source/lithium/drawlist.cpp +++ b/source/lithium/drawlist.cpp @@ -10,9 +10,14 @@ PD_API Drawlist::Drawlist() { Clear(); } PD_API Drawlist::~Drawlist() { Clear(); } -PD_API void Drawlist::Merge(Drawlist& other) {} +PD_API void Drawlist::Merge(Drawlist& other) { + pCommands.AppendMove(other.pCommands); + other.Clear(); +} -PD_API void Drawlist::Copy(Drawlist& other) {} +PD_API void Drawlist::Copy(Drawlist& other) { + pCommands.AppendCopy(other.pCommands); +} PD_API void Drawlist::Optimize() {}