Stage 1: headless Image and AudioData; GPU and playback caches in the UI

- resource::Image (pixels, size, uid) replaces Texture in documents, undo and
  wizards; it lives in anm2ed_core with no GL. uid changes with the pixels.
- resource::texture::id_get uploads lazily and evicts textures not drawn in a frame
- resource::AudioData (bytes, uid) replaces Audio; resource::audio::play/stop/
  track_detach/is_playing cache decoded audio and tracks per uid
- Resources::icon_id_get shortens the icon call sites
- tests/assets.cpp covers Image png round trip, uid tracking, merge_append

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-10-03 14:52:34 -04:00
1 parent 5311c2835f
commit 26ab394fe4
37 files changed
+538 -614

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
#pragma once
#include <cstddef>
#include <cstdint>
#include <filesystem>
#include <vector>
#include <glm/glm.hpp>
namespace anm2ed::resource::image
{
constexpr auto CHANNELS = 4;
}
namespace anm2ed::resource
{
// CPU-side RGBA pixels. uid changes whenever the pixels do, so GPU copies can be cached by it.
class Image
{
public:
glm::ivec2 size{};
std::vector<uint8_t> pixels{};
bool isLinear{};
std::uint64_t uid{};
Image() = default;
Image(const uint8_t*, glm::ivec2, bool = false);
Image(const unsigned char*, size_t);
Image(const std::filesystem::path&);
bool is_valid() const;
size_t pixel_size_get() const;
bool write_png(const std::filesystem::path&) const;
static bool write_pixels_png(const std::filesystem::path&, glm::ivec2, const uint8_t*);
static Image merge_append(const Image&, const Image&, bool);
glm::vec4 pixel_read(glm::vec2) const;
void pixel_set(glm::ivec2, glm::vec4);
void pixel_line(glm::ivec2, glm::ivec2, glm::vec4);
};
}