refactor: Remove OverworldEditorManager and GraphicsManager for Simplification
- Deleted OverworldEditorManager and OverworldGraphicsManager classes to streamline the codebase and reduce complexity in the overworld editor. - Updated CMake configuration to remove references to the deleted files, ensuring a clean build environment. - Adjusted OverworldEditor to handle graphics management directly, improving maintainability and reducing the number of dependencies. - Enhanced the initialization and update methods in OverworldEditor to accommodate the removal of the manager classes, ensuring continued functionality. - Cleaned up related header files to reflect the removal of obsolete classes and methods, enhancing clarity and organization.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "app/gfx/arena.h"
|
||||
|
||||
#include <SDL.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "util/sdl_deleter.h"
|
||||
|
||||
@@ -443,5 +444,66 @@ void Arena::ClearBatchQueue() {
|
||||
batch_update_queue_.clear();
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Progressive/Deferred Texture Management
|
||||
// ============================================================================
|
||||
|
||||
void Arena::QueueDeferredTexture(gfx::Bitmap* bitmap, int priority) {
|
||||
if (!bitmap) return;
|
||||
|
||||
std::lock_guard<std::mutex> lock(deferred_mutex_);
|
||||
deferred_textures_.emplace_back(bitmap, priority);
|
||||
}
|
||||
|
||||
std::vector<gfx::Bitmap*> Arena::GetNextDeferredTextureBatch(
|
||||
int high_priority_limit, int low_priority_limit) {
|
||||
std::lock_guard<std::mutex> lock(deferred_mutex_);
|
||||
|
||||
std::vector<gfx::Bitmap*> batch;
|
||||
|
||||
if (deferred_textures_.empty()) {
|
||||
return batch;
|
||||
}
|
||||
|
||||
// Sort by priority (lower number = higher priority)
|
||||
std::sort(deferred_textures_.begin(), deferred_textures_.end(),
|
||||
[](const DeferredTexture& a, const DeferredTexture& b) {
|
||||
return a.priority < b.priority;
|
||||
});
|
||||
|
||||
// Phase 1: Collect high-priority items (priority 0-10)
|
||||
auto it = deferred_textures_.begin();
|
||||
while (it != deferred_textures_.end() && batch.size() < static_cast<size_t>(high_priority_limit)) {
|
||||
if (it->bitmap && it->priority <= 10 && !it->bitmap->texture()) {
|
||||
batch.push_back(it->bitmap);
|
||||
it = deferred_textures_.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
// Phase 2: Collect low-priority items (priority 11+) if we have capacity
|
||||
if (batch.size() < static_cast<size_t>(high_priority_limit)) {
|
||||
it = deferred_textures_.begin();
|
||||
int low_count = 0;
|
||||
while (it != deferred_textures_.end() && low_count < low_priority_limit) {
|
||||
if (it->bitmap && it->priority > 10 && !it->bitmap->texture()) {
|
||||
batch.push_back(it->bitmap);
|
||||
low_count++;
|
||||
it = deferred_textures_.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return batch;
|
||||
}
|
||||
|
||||
void Arena::ClearDeferredTextures() {
|
||||
std::lock_guard<std::mutex> lock(deferred_mutex_);
|
||||
deferred_textures_.clear();
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace yaze
|
||||
@@ -4,12 +4,14 @@
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <tuple>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "util/sdl_deleter.h"
|
||||
#include "app/gfx/background_buffer.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace gfx {
|
||||
@@ -161,6 +163,41 @@ class Arena {
|
||||
*/
|
||||
auto& bg2() { return bg2_; }
|
||||
|
||||
// Progressive/Deferred Texture Management (for large asset loading)
|
||||
/**
|
||||
* @brief Add a bitmap to the deferred texture queue
|
||||
* @param bitmap Bitmap that needs a texture created
|
||||
* @param priority Higher priority items processed first (0 = highest)
|
||||
*
|
||||
* Use this for progressive loading of large asset sets (e.g., overworld maps).
|
||||
* Textures are created incrementally per frame to avoid UI freezes.
|
||||
*/
|
||||
void QueueDeferredTexture(gfx::Bitmap* bitmap, int priority = 0);
|
||||
|
||||
/**
|
||||
* @brief Get next batch of deferred textures to process
|
||||
* @param high_priority_limit Max high-priority items to return
|
||||
* @param low_priority_limit Max low-priority items to return
|
||||
* @return Vector of bitmaps to render (caller renders them via Renderer)
|
||||
*
|
||||
* Call this once per frame in your editor's Update() method, then render each bitmap.
|
||||
* High-priority items (priority 0-10) returned up to high_priority_limit.
|
||||
* Low-priority items (priority 11+) returned up to low_priority_limit.
|
||||
*/
|
||||
std::vector<gfx::Bitmap*> GetNextDeferredTextureBatch(int high_priority_limit = 4,
|
||||
int low_priority_limit = 2);
|
||||
|
||||
/**
|
||||
* @brief Clear all deferred texture items
|
||||
*/
|
||||
void ClearDeferredTextures();
|
||||
|
||||
/**
|
||||
* @brief Get count of remaining deferred textures
|
||||
* @return Number of bitmaps waiting for textures
|
||||
*/
|
||||
size_t GetDeferredTextureCount() const { return deferred_textures_.size(); }
|
||||
|
||||
private:
|
||||
Arena();
|
||||
|
||||
@@ -213,6 +250,16 @@ class Arena {
|
||||
// Helper methods for resource pooling
|
||||
SDL_Texture* CreateNewTexture(SDL_Renderer* renderer, int width, int height);
|
||||
SDL_Surface* CreateNewSurface(int width, int height, int depth, int format);
|
||||
|
||||
// Progressive loading infrastructure
|
||||
struct DeferredTexture {
|
||||
gfx::Bitmap* bitmap;
|
||||
int priority;
|
||||
|
||||
DeferredTexture(gfx::Bitmap* bmp, int prio) : bitmap(bmp), priority(prio) {}
|
||||
};
|
||||
std::vector<DeferredTexture> deferred_textures_;
|
||||
std::mutex deferred_mutex_;
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
Reference in New Issue
Block a user