ZenitUI
Retained-mode C++20 UI framework
Loading...
Searching...
No Matches
MockAssetProvider.hpp
1#pragma once
2
3#include "UIContext.hpp"
4
5#include <cstdint>
6#include <string>
7#include <string_view>
8#include <unordered_map>
9
10namespace ZenitUI::Test
11{
15
22 class MockAssetProvider final : public IAssetProvider
23 {
24 public:
27 void registerEffect(std::string name);
29
32 TextureHandle getTexture(std::string_view name) override;
33 EffectHandle getEffect(std::string_view name) override;
34
35 TextureHandle loadTexture(std::string_view name, std::string_view path) override;
36 TextureHandle loadTextureFromMemory(std::string_view name,
37 const void *data,
38 size_t size) override;
39 void unloadTexture(std::string_view name) override;
40
41 EffectHandle loadEffect(std::string_view name,
42 std::string_view fsPath,
43 std::string_view vsPath = {}) override;
44 EffectHandle loadEffectFromMemory(std::string_view name,
45 std::string_view fsSource,
46 std::string_view vsSource = {}) override;
47 void unloadEffect(std::string_view name) override;
49
50 private:
51 std::unordered_map<std::string, EffectHandle> effects_;
52 std::unordered_map<std::string, TextureHandle> textures_;
53 uint32_t nextEffectId_{100};
54 uint32_t nextTextureId_{300};
55 };
56
58} // namespace ZenitUI::Test
Per-application state: renderer, platform, pointer, focus, portals.
Abstract name-based lookup and runtime lifecycle for textures and shaders.
Definition UIContext.hpp:449
In-memory IAssetProvider that mints synthetic texture and shader handles without touching the filesys...
Definition MockAssetProvider.hpp:23
TextureHandle loadTextureFromMemory(std::string_view name, const void *data, size_t size) override
Optional runtime hook to load a 2D texture from encoded image bytes in memory.
EffectHandle getEffect(std::string_view name) override
Look up a loaded shader effect by logical name; returns {0} if not found.
EffectHandle loadEffect(std::string_view name, std::string_view fsPath, std::string_view vsPath={}) override
Optional runtime hook to load a fragment (and optional vertex) shader from disk under name.
void unloadTexture(std::string_view name) override
Optional runtime hook to unload a texture by logical name.
void unloadEffect(std::string_view name) override
Optional runtime hook to unload a shader effect by logical name.
TextureHandle getTexture(std::string_view name) override
Look up a loaded 2D texture by logical name; returns {0} if not found.
EffectHandle loadEffectFromMemory(std::string_view name, std::string_view fsSource, std::string_view vsSource={}) override
Optional runtime hook to load a shader effect from in-memory source strings.
TextureHandle loadTexture(std::string_view name, std::string_view path) override
Optional runtime hook to load a 2D texture from disk under name.
Opaque handle to a shader/effect owned by the asset provider.
Definition CoreTypes.hpp:142
Opaque handle to a GPU/software texture owned by the asset provider.
Definition CoreTypes.hpp:127