From 8d41e7fcd92b34a3f2e37a5c6f80985c43632949 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sun, 13 Mar 2022 18:00:47 +0300 Subject: [PATCH] Add gfx::texture_atlas_2d::used_pixels() --- libs/gfx/include/psemek/gfx/texture_atlas.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/gfx/include/psemek/gfx/texture_atlas.hpp b/libs/gfx/include/psemek/gfx/texture_atlas.hpp index afd192b0..d7638a89 100644 --- a/libs/gfx/include/psemek/gfx/texture_atlas.hpp +++ b/libs/gfx/include/psemek/gfx/texture_atlas.hpp @@ -21,9 +21,12 @@ namespace psemek::gfx texture_view find(Key const & key) const; texture_view at(Key const & key) const; + std::size_t used_pixels() const { return used_pixels_; } + private: util::atlas atlas_; texture_2d texture_; + std::size_t used_pixels_ = 0; void update_texture(); @@ -42,6 +45,8 @@ namespace psemek::gfx if (result.second) update_texture(); + used_pixels_ += data.size(); + return {to_view(result.first), result.second}; }