mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
still working on code refactoring
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/11 01:00:13 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/28 22:13:23 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/04/23 22:08:02 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -27,11 +27,11 @@ namespace mlx
|
||||
|
||||
TextureRenderDescriptor(NonOwningPtr<Texture> _texture, int _x, int _y) : texture(_texture), x(_x), y(_y) {}
|
||||
inline bool operator==(const TextureRenderDescriptor& rhs) const { return texture == rhs.texture && x == rhs.x && y == rhs.y; }
|
||||
inline void Render(std::array<VkDescriptorSet, 2>& sets, class Renderer& renderer) override
|
||||
inline void Render(class Renderer& renderer) override
|
||||
{
|
||||
if(!texture->IsInit())
|
||||
return;
|
||||
texture->Render(sets, renderer, x, y);
|
||||
texture->Render(renderer, x, y);
|
||||
}
|
||||
inline void ResetUpdate() override
|
||||
{
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* TextureManager.h :+: :+: :+: */
|
||||
/* TextureRegistry.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/11 00:56:15 by maldavid #+# #+# */
|
||||
/* Updated: 2024/04/03 16:24:51 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/04/23 22:10:08 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -17,48 +17,23 @@
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
class TextureManager
|
||||
class TextureRegistry
|
||||
{
|
||||
public:
|
||||
TextureManager() = default;
|
||||
TextureRegistry() = default;
|
||||
|
||||
inline void Clear() { m_texture_descriptors.clear(); }
|
||||
inline void Clear();
|
||||
inline std::pair<NonOwningPtr<DrawableResource>, bool> RegisterTexture(NonOwningPtr<Texture> texture, int x, int y);
|
||||
inline bool IsTextureKnown(NonOwningPtr<Texture> texture) noexcept;
|
||||
inline void EraseTextures(NonOwningPtr<Texture> texture);
|
||||
|
||||
inline std::pair<NonOwningPtr<DrawableResource>, bool> RegisterTexture(NonOwningPtr<Texture> texture, int x, int y)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
auto res = m_texture_descriptors.emplace(texture, x, y);
|
||||
return std::make_pair(static_cast<DrawableResource*>(&const_cast<TextureRenderDescriptor&>(*res.first)), res.second);
|
||||
}
|
||||
|
||||
inline bool IsTextureKnown(NonOwningPtr<Texture> texture) noexcept
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
for(const auto& desc : m_texture_descriptors)
|
||||
{
|
||||
if(desc.texture == texture)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline void EraseTextures(NonOwningPtr<Texture> texture)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
for(auto it = m_texture_descriptors.begin(); it != m_texture_descriptors.end();)
|
||||
{
|
||||
if(it->texture == texture)
|
||||
it = m_texture_descriptors.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
~TextureManager() = default;
|
||||
~TextureRegistry() = default;
|
||||
|
||||
private:
|
||||
std::unordered_set<TextureRenderDescriptor> m_texture_descriptors;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Renderer/Image/TextureRegistry.inl>
|
||||
|
||||
#endif
|
||||
52
runtime/Includes/Renderer/Images/TextureRegistry.inl
git.filemode.normal_file
52
runtime/Includes/Renderer/Images/TextureRegistry.inl
git.filemode.normal_file
@@ -0,0 +1,52 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* TextureRegistry.inl :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/23 22:08:46 by maldavid #+# #+# */
|
||||
/* Updated: 2024/04/23 22:11:09 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#pragma once
|
||||
#include <Renderer/Images/TextureRegistry.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
void TextureRegistry::Clear()
|
||||
{
|
||||
m_texture_descriptors.clear();
|
||||
}
|
||||
|
||||
std::pair<NonOwningPtr<DrawableResource>, bool> TextureRegistry::RegisterTexture(NonOwningPtr<Texture> texture, int x, int y)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
auto res = m_texture_descriptors.emplace(texture, x, y);
|
||||
return std::make_pair(static_cast<DrawableResource*>(&const_cast<TextureRenderDescriptor&>(*res.first)), res.second);
|
||||
}
|
||||
|
||||
bool TextureRegistry::IsTextureKnown(NonOwningPtr<Texture> texture) noexcept
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
for(const auto& desc : m_texture_descriptors)
|
||||
{
|
||||
if(desc.texture == texture)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void TextureRegistry::EraseTextures(NonOwningPtr<Texture> texture)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
for(auto it = m_texture_descriptors.begin(); it != m_texture_descriptors.end();)
|
||||
{
|
||||
if(it->texture == texture)
|
||||
it = m_texture_descriptors.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user