From a698e2e44e3dfa157c2b184a184db204b44a6a30 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 4 Mar 2018 02:38:36 +0300 Subject: Show current atlases count in debug window. If use too many images, atlase can be split to more than one. And this is performance issue. --- src/gui/widgets/tabs/debugwindowtabs.cpp | 13 ++++++++++++- src/gui/widgets/tabs/debugwindowtabs.h | 1 + src/resources/loaders/atlasloader.cpp | 8 +++++--- src/resources/loaders/atlasloader.h | 6 +++--- src/resources/map/map.cpp | 9 +++++++++ src/resources/map/map.h | 7 +++++-- 6 files changed, 35 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/gui/widgets/tabs/debugwindowtabs.cpp b/src/gui/widgets/tabs/debugwindowtabs.cpp index 5a6485dca..e3d7d7498 100644 --- a/src/gui/widgets/tabs/debugwindowtabs.cpp +++ b/src/gui/widgets/tabs/debugwindowtabs.cpp @@ -67,6 +67,9 @@ MapDebugTab::MapDebugTab(const Widget2 *const widget) : mMapActorCountLabel(new Label(this, strprintf("%s %d", // TRANSLATORS: debug window label _("Map actors count:"), 88888))), + mMapAtlasCountLabel(new Label(this, strprintf("%s %d", + // TRANSLATORS: debug window label + _("Map atlas count:"), 88888))), // TRANSLATORS: debug window label mXYLabel(new Label(this, strprintf("%s (?,?)", _("Player Position:")))), mTexturesLabel(nullptr), @@ -141,6 +144,7 @@ MapDebugTab::MapDebugTab(const Widget2 *const widget) : place(0, 7, mTileMouseLabel, 2, 1); place(0, 8, mParticleCountLabel, 2, 1); place(0, 9, mMapActorCountLabel, 2, 1); + place(0, 10, mMapAtlasCountLabel, 2, 1); #ifdef USE_OPENGL #if defined (DEBUG_OPENGL_LEAKS) || defined(DEBUG_DRAW_CALLS) \ || defined(DEBUG_BIND_TEXTURE) @@ -221,6 +225,10 @@ void MapDebugTab::logic() // TRANSLATORS: debug window label strprintf("%s %d", _("Map actors count:"), map->getActorsCount())); + mMapAtlasCountLabel->setCaption( + // TRANSLATORS: debug window label + strprintf("%s %d", _("Map atlas count:"), + map->getAtlasCount())); #ifdef USE_OPENGL #ifdef DEBUG_OPENGL_LEAKS mTexturesLabel->setCaption(strprintf("%s %d", @@ -258,13 +266,16 @@ void MapDebugTab::logic() mMapLabel->setCaption(strprintf("%s ?", _("Map:"))); // TRANSLATORS: debug window label mMapNameLabel->setCaption(strprintf("%s ?", _("Map name:"))); - mMapActorCountLabel->setCaption( // TRANSLATORS: debug window label strprintf("%s ?", _("Map actors count:"))); + mMapAtlasCountLabel->setCaption( + // TRANSLATORS: debug window label + strprintf("%s ?", _("Map atlas count:"))); } mMapActorCountLabel->adjustSize(); + mMapAtlasCountLabel->adjustSize(); mParticleCountLabel->adjustSize(); mFPSLabel->setCaption(strprintf(mFPSText.c_str(), fps)); diff --git a/src/gui/widgets/tabs/debugwindowtabs.h b/src/gui/widgets/tabs/debugwindowtabs.h index 064259393..e4c41dda8 100644 --- a/src/gui/widgets/tabs/debugwindowtabs.h +++ b/src/gui/widgets/tabs/debugwindowtabs.h @@ -66,6 +66,7 @@ class MapDebugTab final : public DebugTab Label *mTileMouseLabel A_NONNULLPOINTER; Label *mParticleCountLabel A_NONNULLPOINTER; Label *mMapActorCountLabel A_NONNULLPOINTER; + Label *mMapAtlasCountLabel A_NONNULLPOINTER; Label *mXYLabel A_NONNULLPOINTER; Label *mTexturesLabel A_NONNULLPOINTER; time_t mUpdateTime; diff --git a/src/resources/loaders/atlasloader.cpp b/src/resources/loaders/atlasloader.cpp index 6ca23ddea..aa2585b27 100644 --- a/src/resources/loaders/atlasloader.cpp +++ b/src/resources/loaders/atlasloader.cpp @@ -52,11 +52,13 @@ struct AtlasLoader final } }; -Resource *Loader::getAtlas(const std::string &name, - const StringVect &files) +AtlasResource *Loader::getAtlas(const std::string &name, + const StringVect &files) { AtlasLoader rl = { name, &files }; - return ResourceManager::get("atlas_" + name, AtlasLoader::load, &rl); + return static_cast(ResourceManager::get( + "atlas_" + name, + AtlasLoader::load, &rl)); } #endif // USE_OPENGL diff --git a/src/resources/loaders/atlasloader.h b/src/resources/loaders/atlasloader.h index 50d078626..c7cdabae5 100644 --- a/src/resources/loaders/atlasloader.h +++ b/src/resources/loaders/atlasloader.h @@ -26,12 +26,12 @@ #include "localconsts.h" -class Resource; +class AtlasResource; namespace Loader { - Resource *getAtlas(const std::string &name, - const StringVect &files) A_WARN_UNUSED; + AtlasResource *getAtlas(const std::string &name, + const StringVect &files) A_WARN_UNUSED; } // namespace Loader #endif // USE_OPENGL diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp index 1e97597bf..c9636183e 100644 --- a/src/resources/map/map.cpp +++ b/src/resources/map/map.cpp @@ -42,6 +42,8 @@ #include "resources/ambientlayer.h" +#include "resources/atlas/atlasresource.h" + #include "resources/image/subimage.h" #include "resources/loaders/imageloader.h" @@ -1791,3 +1793,10 @@ int Map::calcMemoryChilds(const int level) const mHeights->calcMemory(level + 1); return sz; } + +int Map::getAtlasCount() const restrict2 +{ + if (mAtlas == nullptr) + return 0; + return CAST_S32(mAtlas->atlases.size()); +} diff --git a/src/resources/map/map.h b/src/resources/map/map.h index fbb3e43da..a3397ad2e 100644 --- a/src/resources/map/map.h +++ b/src/resources/map/map.h @@ -42,6 +42,7 @@ #include "resources/map/properties.h" class AmbientLayer; +class AtlasResource; class MapHeights; class MapItem; class MapLayer; @@ -283,6 +284,8 @@ class Map final : public Properties, int getActorsCount() const restrict2 A_WARN_UNUSED { return CAST_S32(mActors.size()); } + int getAtlasCount() const restrict2 A_WARN_UNUSED; + void setPvpMode(const int mode) restrict2; int getPvpMode() const restrict2 noexcept2 A_WARN_UNUSED @@ -327,7 +330,7 @@ class Map final : public Properties, restrict2 noexcept2 A_WARN_UNUSED { return mTileAnimations; } - void setAtlas(Resource *restrict const atlas) restrict2 noexcept2 + void setAtlas(AtlasResource *restrict const atlas) restrict2 noexcept2 { mAtlas = atlas; } const MetaTile *getMetaTiles() const restrict2 noexcept2 @@ -483,7 +486,7 @@ class Map final : public Properties, int mDrawScrollX; int mDrawScrollY; int mMask; - Resource *mAtlas; + AtlasResource *mAtlas; const MapHeights *mHeights; bool mRedrawMap; bool mBeingOpacity; -- cgit v1.2.3-70-g09d2