6 const SDL_PixelFormat& PixelFmtStorage::get(
const Id
id) {
7 const size_t i = static_cast<size_t>(
id);
9 if (unsafeRaw()[i] ==
nullptr) {
10 SDL_PixelFormat* tmp = SDL_AllocFormat(id::unsafe::toSDLEnum(
id));
17 return *unsafeRaw()[i];
20 #pragma clang diagnostic push
21 #pragma clang diagnostic ignored "-Wexit-time-destructors"
22 PixelFmtStorage& PixelFmtStorage::instance() noexcept {
23 static PixelFmtStorage res{};
26 #pragma clang diagnostic pop
27 SDL_PixelFormat** PixelFmtStorage::unsafeRaw() noexcept {
28 return instance().data_;
31 PixelFmtStorage::PixelFmtStorage() noexcept :
32 data_(new SDL_PixelFormat*[unique_count])
34 for (
size_t i = 0; i < unique_count; ++i)
37 PixelFmtStorage::~PixelFmtStorage() noexcept {
38 if (data_ !=
nullptr) {
39 for (
size_t i = 0; i < unique_count; ++i)
40 if (data_[i] !=
nullptr)
41 SDL_FreeFormat(data_[i]);