8#include <SDL3/SDL_gpu.h>
12#include <unordered_map>
28 bool init(SDL_GPUDevice* device, std::filesystem::path assetDir);
31 [[nodiscard]] std::optional<HudSvgSprite>
sprite(
HudIcon id,
int width,
int height);
52 const auto id =
static_cast<std::size_t
>(key.
id);
53 return id ^ (
static_cast<std::size_t
>(key.
width) << 8u) ^ (
static_cast<std::size_t
>(key.
height) << 24u);
69 std::unordered_map<CacheKey, HudSvgSprite, CacheKeyHash>
sprites_;
73 [[nodiscard]] std::optional<HudSvgSprite>
allocate(
HudIcon id,
int width,
int height);
CPU SVG raster helpers used by the HUD SVG atlas and tests.
HudIcon
Icon identifiers for the HUD icon atlas.
Definition HudTypes.hpp:63
@ None
Definition HudTypes.hpp:64
Definition HudSvgAtlas.hpp:26
int rowH_
Definition HudSvgAtlas.hpp:67
SDL_GPUTexture * texture_
Definition HudSvgAtlas.hpp:58
SDL_GPUDevice * device_
Definition HudSvgAtlas.hpp:57
SDL_GPUTexture * texture() const
Definition HudSvgAtlas.hpp:32
bool uploadSlot(const HudSvgBitmap &bitmap, const HudSvgSprite &sprite)
Definition HudSvgAtlas.cpp:143
SDL_GPUSampler * sampler() const
Definition HudSvgAtlas.hpp:33
void resetPacking()
Definition HudSvgAtlas.cpp:100
bool init(SDL_GPUDevice *device, std::filesystem::path assetDir)
Definition HudSvgAtlas.cpp:11
std::filesystem::path assetDir_
Definition HudSvgAtlas.hpp:60
bool createGpuResources()
Definition HudSvgAtlas.cpp:67
static constexpr int kAtlasSize
Definition HudSvgAtlas.hpp:62
std::unordered_map< CacheKey, HudSvgSprite, CacheKeyHash > sprites_
Definition HudSvgAtlas.hpp:69
SDL_GPUSampler * sampler_
Definition HudSvgAtlas.hpp:59
static constexpr int kPadding
Definition HudSvgAtlas.hpp:63
int cursorY_
Definition HudSvgAtlas.hpp:66
std::optional< HudSvgSprite > allocate(HudIcon id, int width, int height)
Definition HudSvgAtlas.cpp:109
void quit()
Definition HudSvgAtlas.cpp:18
std::optional< HudSvgSprite > sprite(HudIcon id, int width, int height)
Definition HudSvgAtlas.cpp:33
int cursorX_
Definition HudSvgAtlas.hpp:65
Definition HudSvgAtlas.hpp:49
std::size_t operator()(const CacheKey &key) const
Definition HudSvgAtlas.hpp:50
Definition HudSvgAtlas.hpp:37
int width
Definition HudSvgAtlas.hpp:39
HudIcon id
Definition HudSvgAtlas.hpp:38
bool operator==(const CacheKey &other) const
Definition HudSvgAtlas.hpp:42
int height
Definition HudSvgAtlas.hpp:40
Definition HudSvgRaster.hpp:13
Definition HudSvgAtlas.hpp:16
int width
Definition HudSvgAtlas.hpp:21
float u0
Definition HudSvgAtlas.hpp:17
float v0
Definition HudSvgAtlas.hpp:18
float v1
Definition HudSvgAtlas.hpp:20
float u1
Definition HudSvgAtlas.hpp:19
int height
Definition HudSvgAtlas.hpp:22