86 lines
2.0 KiB
C++
Executable File
86 lines
2.0 KiB
C++
Executable File
#pragma once
|
|
|
|
#include <cinttypes>
|
|
#include <bit>
|
|
#include <memory>
|
|
#include <algorithm>
|
|
#include "assets/components/texture_components.hpp"
|
|
|
|
namespace assets
|
|
{
|
|
|
|
class texture_data
|
|
{
|
|
public:
|
|
using value_type = std::uint8_t;
|
|
using dim_type = std::int32_t;
|
|
using size_type = std::make_signed_t<std::size_t>;
|
|
using difference_type = size_type;
|
|
using reference = value_type&;
|
|
using const_reference = const value_type&;
|
|
using pointer = std::uint8_t*;
|
|
using const_pointer = const std::uint8_t*;
|
|
using iterator = pointer;
|
|
using const_iterator = const_pointer;
|
|
|
|
texture_data() = default;
|
|
|
|
inline texture_data(
|
|
std::unique_ptr<value_type[]>&& data,
|
|
dim_type width,
|
|
dim_type height,
|
|
texture_components::flags components
|
|
);;
|
|
|
|
inline texture_data(const texture_data&);
|
|
|
|
inline texture_data(texture_data&&) noexcept;
|
|
|
|
[[nodiscard]] inline texture_data& operator=(const texture_data&);
|
|
|
|
[[nodiscard]] inline texture_data& operator=(texture_data&&) noexcept;
|
|
|
|
[[nodiscard]] inline texture_components::flags components() const;
|
|
|
|
[[nodiscard]] inline dim_type width() const;
|
|
|
|
[[nodiscard]] inline dim_type height() const;
|
|
|
|
[[nodiscard]] inline std::pair<dim_type, dim_type> dimensions() const;
|
|
|
|
[[nodiscard]] inline size_type pixel_count() const;
|
|
|
|
[[nodiscard]] inline size_type component_count() const;
|
|
|
|
[[nodiscard]] inline size_type size() const;
|
|
|
|
[[nodiscard]] inline const_iterator begin() const;
|
|
|
|
[[nodiscard]] inline iterator begin();
|
|
|
|
[[nodiscard]] inline const_iterator end() const;
|
|
|
|
[[nodiscard]] inline iterator end();
|
|
|
|
[[nodiscard]] inline const_iterator cbegin() const;
|
|
|
|
[[nodiscard]] inline const_iterator cend() const;
|
|
|
|
[[nodiscard]] inline const_pointer data() const;
|
|
|
|
[[nodiscard]] inline pointer data();
|
|
|
|
void inline clear();
|
|
|
|
private:
|
|
std::unique_ptr<value_type[]> m_data{ nullptr };
|
|
dim_type m_width{ 0 }, m_height{ 0 };
|
|
texture_components::flags m_components{ texture_components::flags::none };
|
|
};
|
|
|
|
}
|
|
|
|
#define INCLUDE_DYNAMIC_TEXTURE_DATA_IMPLEMENTATION
|
|
#include "assets/data/texture_data.ipp"
|
|
#undef INCLUDE_DYNAMIC_TEXTURE_DATA_IMPLEMENTATION
|