diff --git a/src/core/include/pw/core/matrix.hpp b/src/core/include/pw/core/matrix.hpp index 1111708..40e3b0e 100644 --- a/src/core/include/pw/core/matrix.hpp +++ b/src/core/include/pw/core/matrix.hpp @@ -70,8 +70,8 @@ struct matrix final { template auto get(this auto&& self) -> decltype(auto) { static_assert(idx < Rows, "Out of bounds access to a member."); // TODO: use forward_like when clang is catching up - return std::forward_like(self.m_[idx]); - // return std::forward(self).m_[idx]; + // return std::forward_like(self.m_[idx]); + return std::forward(self).m_[idx]; } constexpr auto diagonal() const noexcept -> diag_type { diff --git a/src/core/tests/pwcore_test_image.cpp b/src/core/tests/pwcore_test_image.cpp index b4b3932..79cf378 100644 --- a/src/core/tests/pwcore_test_image.cpp +++ b/src/core/tests/pwcore_test_image.cpp @@ -11,28 +11,14 @@ namespace pw { struct image_layout { - enum struct pixel_layout { RGB8, RGBA8, LUM8, DEPTH }; + enum pixel_layout { RGB8, RGBA8, LUM8, DEPTH }; static constexpr auto bits_per_channel(pixel_layout layout) { - constexpr static auto lut = std::array{ - std::make_tuple(pixel_layout::RGB8, sizeof(std::uint8_t) << 3), - std::make_tuple(pixel_layout::RGBA8, sizeof(std::uint8_t) << 3), - std::make_tuple(pixel_layout::LUM8, sizeof(std::uint8_t) << 3), - std::make_tuple(pixel_layout::DEPTH, sizeof(float) << 3)}; - - const auto iter = std::find_if( - std::begin(lut), std::end(lut), - [&layout](const auto& v) { return std::get<0>(v) == layout; }); - - return iter != std::end(lut) ? std::get<1>(*iter) : 0u; - } - - static constexpr auto channels(pixel_layout layout) { constexpr static auto lut = - std::array{std::make_tuple(pixel_layout::RGB8, 3), - std::make_tuple(pixel_layout::RGBA8, 4), - std::make_tuple(pixel_layout::LUM8, 1), - std::make_tuple(pixel_layout::DEPTH, 1)}; + std::array{std::make_tuple(RGB8, sizeof(std::uint8_t) << 3), + std::make_tuple(RGBA8, sizeof(std::uint8_t) << 3), + std::make_tuple(LUM8, sizeof(std::uint8_t) << 3), + std::make_tuple(DEPTH, sizeof(float) << 3)}; const auto iter = std::find_if( std::begin(lut), std::end(lut), @@ -40,39 +26,16 @@ struct image_layout { return iter != std::end(lut) ? std::get<1>(*iter) : 0u; } - - size size_{}; - pixel_layout layout_{pixel_layout::RGB8}; -}; - -struct image_new { - - using buffer_type = std::vector; - using size_type = pw::size; - - image_layout layout; - buffer_type buffer{}; - - static constexpr auto make(const image_new::size_type& size_, - image_layout::pixel_layout layout_) - -> image_new { - - return {.layout{.layout_ = layout_}, - .buffer{buffer_type{ - static_cast( - (image_layout::bits_per_channel(layout_) >> 3) * - size_.area() * image_layout::channels(layout_)), - buffer_type::value_type{0}}}}; - } }; } // namespace pw auto main() -> int { - std::print("RGB8 = {}bits per channel\n", - pw::image_layout::bits_per_channel( - pw::image_layout::pixel_layout::RGB8)); + auto val = pw::image_layout::bits_per_channel( + pw::image_layout::pixel_layout::RGB8); + + std::print("RGB8 = {}bits per channel\n", val); std::print("DEPTH = {}bits per channel\n", pw::image_layout::bits_per_channel( pw::image_layout::pixel_layout::DEPTH)); @@ -80,16 +43,5 @@ auto main() -> int { pw::image_layout::bits_per_channel( pw::image_layout::pixel_layout::LUM8)); - std::print( - "RGB8 = {}channels\n", - pw::image_layout::channels(pw::image_layout::pixel_layout::RGB8)); - std::print( - "DEPTH = {}channels\n", - pw::image_layout::channels(pw::image_layout::pixel_layout::DEPTH)); - std::print( - "LUM8 = {}channels\n", - pw::image_layout::channels(pw::image_layout::pixel_layout::LUM8)); // pw::image - - pw::image_new::make(pw::iamge, image_layout::pixel_layout layout_) }