#include "app.hpp" #include "src/anim-atlas.hpp" #include "loader/loader.hpp" #include "compat/assert.hpp" #include "compat/array-size.hpp" #include #include namespace floormat { namespace { const unsigned char src[] = { #include "bitmask.embed.inc" }; constexpr auto data_nbytes = array_size(src); constexpr auto size = Vector2i{21, 52}; //static_assert(size_t{size.product()+7}/8 <= data_nbytes); void bitmask_test() { auto img = loader.texture("images/", "bitmask-test1"_s); auto bitmask = anim_atlas::make_bitmask(img); fm_assert(bitmask.size() >= size_t{size.product()}); fm_assert(img.pixelSize() == 4); //#define DO_GENERATE #ifdef DO_GENERATE fputc('\n', stdout); for (auto i = 0u; i < (bitmask.size()+7)/8; i++) { printf("0x%02hhx,", bitmask.data()[i]); if (i % 15 == 14) printf("\n"); } printf("\n"); fflush(stdout); #endif const auto len = Math::min(data_nbytes, (size_t)bitmask.size()+7 >> 3); fm_assert(array_size(src) >= len); for (auto i = 0uz; i < len; i++) { auto a = (unsigned char)bitmask.data()[i]; if (a != src[i]) fm_abort("wrong value 0x%02hhx at byte %zu, should be' 0x%02hhx'", a, i, src[i]); } } } // namespace void Test::test_bitmask() { bitmask_test(); //bitmask_benchmark(); } } // namespace floormat