21#include <unordered_map>
49using ImageDecodeFn = std::function<std::optional<DecodedImage>(
const std::string& uri)>;
80 uint64_t last_used = 0;
86 mutable std::mutex mu_;
87 std::unordered_map<std::string, Entry> entries_;
90 std::size_t total_bytes_ = 0;
91 std::size_t budget_ = 0;
void set_releaser(ImageReleaseFn fn)
Definition image_cache.hpp:60
ImageCacheStats stats() const
void set_decoder(ImageDecodeFn fn)
Definition image_cache.hpp:59
void set_byte_budget(std::size_t bytes)
Soft byte cap.
Definition image_cache.hpp:65
void clear()
Drop everything rebuildable.
const DecodedImage * get(const std::string &uri)
Look up (and decode if absent) the image at uri.
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
std::function< std::optional< DecodedImage >(const std::string &uri)> ImageDecodeFn
Pluggable decode callback.
Definition image_cache.hpp:49
std::function< void(DecodedImage &)> ImageReleaseFn
Release the platform handle when an entry is evicted.
Definition image_cache.hpp:53
Definition image_cache.hpp:26
std::size_t bytes
Best-effort estimate of the resident memory this entry costs (e.g.
Definition image_cache.hpp:35
void * native_handle
Platform-owned handle.
Definition image_cache.hpp:31
uint32_t height
Definition image_cache.hpp:28
uint32_t width
Definition image_cache.hpp:27
Definition image_cache.hpp:38
std::size_t evictions
Definition image_cache.hpp:43
std::size_t misses
Definition image_cache.hpp:42
std::size_t entry_count
Definition image_cache.hpp:39
std::size_t hits
Definition image_cache.hpp:41
std::size_t total_bytes
Definition image_cache.hpp:40