diff --git a/include/assets/assets_module.h b/include/assets/assets_module.h index b220a58..0765953 100644 --- a/include/assets/assets_module.h +++ b/include/assets/assets_module.h @@ -4,20 +4,16 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include #include #include -#include #include -#include #include namespace extra2d { @@ -261,19 +257,6 @@ private: std::unique_ptr> textureLoader_; std::unique_ptr> shaderLoader_; - // 路径缓存(避免重复加载) - std::unordered_map> texturePathCache_; - std::unordered_map> shaderPathCache_; - - // 默认资源 - Handle defaultTexture_; - Handle defaultShader_; - Handle defaultMaterial_; - Handle defaultQuad_; - - // 线程安全 - mutable std::shared_mutex mutex_; - // 事件监听器 std::unique_ptr onShowListener_; @@ -286,12 +269,9 @@ private: public: struct LoadTask { enum class Type { Texture, Shader }; - enum class Priority { Low = 0, Normal = 1, High = 2 }; Type type; - Priority priority; std::string path; - std::string secondaryPath; // 用于着色器的片段着色器路径 std::function)> textureCallback; std::function)> shaderCallback; }; @@ -321,15 +301,6 @@ public: // 资源依赖跟踪 //=========================================================================== public: - /** - * @brief 资源依赖关系 - */ - struct DependencyInfo { - Handle texture; - Handle shader; - std::vector> dependentMaterials; - }; - /** * @brief 注册材质对纹理的依赖 */ diff --git a/include/event/event_bus.h b/include/event/event_bus.h index ee6e076..bca3990 100644 --- a/include/event/event_bus.h +++ b/include/event/event_bus.h @@ -79,13 +79,11 @@ struct EventTrait { */ template struct TupleExtractor { - using FuncType = void(); using StdFuncType = std::function; }; template struct TupleExtractor> { - using FuncType = void(Args...); using StdFuncType = std::function; }; @@ -120,9 +118,6 @@ public: } } - const char* busName() const { return EHandler::BUS_NAME; } - const char* eventName() const { return EHandler::NAME; } - private: bool enabled_ = true; StdFuncType callback_; diff --git a/src/event/event_bus.cpp b/src/event/event_bus.cpp index 9833765..cfbb20b 100644 --- a/src/event/event_bus.cpp +++ b/src/event/event_bus.cpp @@ -2,6 +2,21 @@ namespace extra2d::event { +static void appendListenerEntry(ListenerEntry *&head, ListenerEntry *entry) { + entry->next = nullptr; + entry->prev = nullptr; + if (!head) { + head = entry; + return; + } + ListenerEntry *tail = head; + while (tail->next) { + tail = tail->next; + } + tail->next = entry; + entry->prev = tail; +} + ListenerContainer::~ListenerContainer() { ListenerEntry *curr = listenerList_; while (curr) { @@ -27,34 +42,9 @@ void ListenerContainer::addListener(ListenerBase *listener) { return; if (broadcasting_ > 0) { - // 广播期间,添加到待添加列表(保持顺序,使用尾插) - listener->entry_->next = nullptr; - if (!listenersToAdd_) { - listenersToAdd_ = listener->entry_; - } else { - // 找到尾部 - ListenerEntry* tail = listenersToAdd_; - while (tail->next) { - tail = tail->next; - } - tail->next = listener->entry_; - } + appendListenerEntry(listenersToAdd_, listener->entry_); } else { - // 非广播期间,添加到主列表尾部(保持顺序) - listener->entry_->next = nullptr; - listener->entry_->prev = nullptr; - - if (!listenerList_) { - listenerList_ = listener->entry_; - } else { - // 找到尾部 - ListenerEntry* tail = listenerList_; - while (tail->next) { - tail = tail->next; - } - tail->next = listener->entry_; - listener->entry_->prev = tail; - } + appendListenerEntry(listenerList_, listener->entry_); } } @@ -85,13 +75,7 @@ void ListenerContainer::processPendingListeners() { while (listenersToAdd_) { ListenerEntry *entry = listenersToAdd_; listenersToAdd_ = entry->next; - - entry->next = listenerList_; - entry->prev = nullptr; - if (listenerList_) { - listenerList_->prev = entry; - } - listenerList_ = entry; + appendListenerEntry(listenerList_, entry); } for (auto *entry : listenersToRemove_) {