8 #ifndef DXLE_INC_TEXTURE_ANIMATION_GRAPH_HPP_ 9 #define DXLE_INC_TEXTURE_ANIMATION_GRAPH_HPP_ 33 mutable std::mutex counter_mtx;
37 : counter(
std::move(counter_))
42 virtual std::unique_ptr<texture2d_handle_manager>
clone() = 0;
44 template<
typename Cont>
52 typename std::remove_reference<Cont>::type graphs;
56 , graphs(std::forward<Cont>(graphs))
58 std::unique_ptr<texture2d_handle_manager>
clone()
override 60 std::vector<texture2d> temp_graphs;
61 temp_graphs.resize(graphs.size());
62 for(
size_t i = 0;i < graphs.size(); ++i) {
63 temp_graphs[i] = (std::move(*graphs[i].
clone()));
67 template<
typename Cont2>
70 template<
typename... Args>
static inline std::unique_ptr<texture2d_handle_manager> get_unique(Args&&... args) {
71 return std::unique_ptr<texture2d_handle_manager>(
new this_T(std::forward<Args>(args)...));
74 #ifdef DXLE_TEMP_IMPL_MAKE_ANI_HM 75 static_assert(
false,
"");
77 #define DXLE_TEMP_IMPL_MAKE_ANI_HM(template_param, specialization, size)\ 78 template<template_param>\ 79 class animation_handle_manager<specialization> final : public animation_handle_manager_bace\ 82 int get_handle()const override\ 84 DXLE_GET_LOCK(counter_mtx);\ 85 return texture2d_handle_manager::GetTextureRawHandle(graphs.get()[counter.get() % size]);\ 88 using Cont = specialization;\ 89 using this_T = animation_handle_manager<Cont>;\ 90 typename std::remove_reference<Cont>::type graphs;\ 91 animation_handle_manager(time::counter&& counter, Cont&& graphs)\ 92 : animation_handle_manager_bace(std::move(counter))\ 93 , graphs(std::move(graphs))\ 95 std::unique_ptr<texture2d_handle_manager> clone() override\ 97 return get_unique(*this);\ 99 friend animation_graph;\ 100 template<typename... Args> static inline std::unique_ptr<texture2d_handle_manager> get_unique(Args&&... args) {\ 101 return std::unique_ptr<texture2d_handle_manager>(new this_T(std::forward<Args>(args)...));\ 109 #undef DXLE_TEMP_IMPL_MAKE_ANI_HM 111 template<
typename Cont>
118 : graphs(
std::forward<Cont>(graphs))
122 typename std::remove_reference<Cont>::type graphs;
125 template<
typename Cont>
132 : graphs(
std::move(graphs))
136 std::reference_wrapper<Cont> graphs;
145 template<
typename Cont>
149 :
texture2d(gr_impl::animation_handle_manager<Cont>::get_unique(
std::move(counter),
std::move(graphs)))
156 template<
typename Cont>
160 :
texture2d(gr_impl::animation_handle_manager<gr_impl::cont_wrapper_with_size<Cont>>::get_unique(
std::move(counter), gr_impl::cont_wrapper_with_size<Cont>(
std::move(graphs), size)))
173 std::unique_ptr<texture2d>
clone()
const override{
return cloneAni(); }
175 std::unique_ptr<animation_graph> cloneAni()
const;
180 void reset_pass_time(std::chrono::milliseconds = std::chrono::milliseconds{ 0 });
181 std::chrono::milliseconds get_pass_time();
184 void reset_count(
size_t = 0);
188 animation_graph(std::unique_ptr<gr_impl::texture2d_handle_manager>&& handle_manager)
197 return std::unique_ptr<animation_graph>(
new animation_graph(hm_ptr->clone()));
199 inline std::vector<texture2d> animation_graph::cast_to_vector(
derivative_texture2d&& div_texture)
201 std::vector<texture2d> temp_graphs(div_texture.size());
202 for (
size_t i = 0; i < div_texture.size(); ++i){
203 temp_graphs[i] = std::move(div_texture[i]);
236 using namespace graph2d;
DXLE_TEMP_IMPL_MAKE_ANI_HM(typename Cont_value_T, std::reference_wrapper< Cont_value_T >, graphs.get().size())
Template class for 2D sizes specified by its coordinates width and height.
cont_wrapper_with_size(Cont &&graphs, size_t size)
size_t size() const DXLE_NOEXCEPT_OR_NOTHROW
std::chrono::milliseconds get_pass_time()
animation_graph(animation_graph &&other) DXLE_NOEXCEPT_OR_NOTHROW
所有権の譲渡
const texture2d & operator[](size_t i) const
animation_graph & operator=(animation_graph &&other) DXLE_NOEXCEPT_OR_NOTHROW
所有権の譲渡
animation_graph(time::counter counter, const texture2d(&graphs)[N])
std::unique_ptr< texture2d > clone() const override
画像を複製する
texture2d_handle_manager & operator=(const texture2d_handle_manager &) DXLE_NOEXCEPT_OR_NOTHROW
int get_handle() const override
animation_graph(time::counter counter, Cont graphs)
void reset_pass_time(std::chrono::milliseconds=std::chrono::milliseconds{ 0 })
texture2d & operator=(const texture2d &other)=delete
std::unique_ptr< animation_graph > cloneAni() const
画像を複製する
animation_graph(time::counter counter, Cont graphs, size_t size)
#define DXLE_GET_LOCK(mtx)
animation_handle_manager_bace(time::counter &&counter_)
void reset_count(size_t=0)
static int GetTextureRawHandle(const texture2d &)
void reset_pass_time(std::chrono::milliseconds=std::chrono::milliseconds{ 0 })
virtual std::unique_ptr< texture2d_handle_manager > clone()=0
const texture2d & operator[](size_t i) const
#define DXLE_NOEXCEPT_OR_NOTHROW
cont_wrapper_with_size(std::reference_wrapper< Cont > &&graphs, size_t size)
void reset_count(size_t=0)
size_t size() const DXLE_NOEXCEPT_OR_NOTHROW
std::chrono::milliseconds get_pass_time()