diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-06-22 20:58:13 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-06-22 20:58:13 +0300 |
commit | 8ad99cc3f4dd98f0b73a2ece9323f01099a81e80 (patch) | |
tree | 33115940e6efabec34efb71e0be6b6d7dfd7e4df /src/resources | |
parent | 04f47f060f94ec0e2dfc3cccf62cff167e0ecd68 (diff) | |
download | plus-8ad99cc3f4dd98f0b73a2ece9323f01099a81e80.tar.gz plus-8ad99cc3f4dd98f0b73a2ece9323f01099a81e80.tar.bz2 plus-8ad99cc3f4dd98f0b73a2ece9323f01099a81e80.tar.xz plus-8ad99cc3f4dd98f0b73a2ece9323f01099a81e80.zip |
Add profiler lines into some functions.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/atlasmanager.cpp | 18 | ||||
-rw-r--r-- | src/resources/imagehelper.cpp | 3 | ||||
-rw-r--r-- | src/resources/map/map.cpp | 20 | ||||
-rw-r--r-- | src/resources/mapreader.cpp | 15 |
4 files changed, 56 insertions, 0 deletions
diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp index 50e8cbc80..cadf917f9 100644 --- a/src/resources/atlasmanager.cpp +++ b/src/resources/atlasmanager.cpp @@ -50,6 +50,7 @@ AtlasManager::AtlasManager() AtlasResource *AtlasManager::loadTextureAtlas(const std::string &name, const StringVect &files) { + BLOCK_START("AtlasManager::loadTextureAtlas") std::vector<TextureAtlas*> atlases; std::vector<Image*> images; AtlasResource *resource = new AtlasResource; @@ -91,12 +92,14 @@ AtlasResource *AtlasManager::loadTextureAtlas(const std::string &name, resource->atlases.push_back(atlas); } + BLOCK_END("AtlasManager::loadTextureAtlas") return resource; } void AtlasManager::loadImages(const StringVect &files, std::vector<Image*> &images) { + BLOCK_START("AtlasManager::loadImages") ResourceManager *const resman = ResourceManager::getInstance(); FOR_EACH (StringVectCIter, it, files) @@ -139,6 +142,7 @@ void AtlasManager::loadImages(const StringVect &files, } delete d; } + BLOCK_END("AtlasManager::loadImages") } void AtlasManager::simpleSort(const std::string &restrict name, @@ -146,6 +150,7 @@ void AtlasManager::simpleSort(const std::string &restrict name, const std::vector<Image*> &restrict images, int size) { + BLOCK_START("AtlasManager::simpleSort") int x = 0; int y = 0; int tempHeight = 0; @@ -208,10 +213,12 @@ void AtlasManager::simpleSort(const std::string &restrict name, atlases.push_back(atlas); else delete atlas; + BLOCK_END("AtlasManager::simpleSort") } SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas) { + BLOCK_START("AtlasManager::createSDLAtlas") #if SDL_BYTEORDER == SDL_BIG_ENDIAN const unsigned int rmask = 0xff000000; const unsigned int gmask = 0x00ff0000; @@ -226,7 +233,10 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas) // do not create atlas based on only one image if (atlas->items.size() == 1) + { + BLOCK_END("AtlasManager::createSDLAtlas") return nullptr; + } // using only power of two sizes. atlas->width = powerOfTwo(atlas->width); @@ -234,11 +244,16 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas) const int width = atlas->width; const int height = atlas->height; + BLOCK_START("AtlasManager::createSDLAtlas create surface") // temp SDL surface for atlas SDL_Surface *const surface = MSDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32U, rmask, gmask, bmask, amask); if (!surface) + { + BLOCK_END("AtlasManager::createSDLAtlas") return nullptr; + } + BLOCK_END("AtlasManager::createSDLAtlas create surface") SurfaceGraphics *const graphics = new SurfaceGraphics(); graphics->setTarget(surface); @@ -254,6 +269,7 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas) { if (image->mSDLSurface) { + BLOCK_START("AtlasManager::createSDLAtlas set surface attr") #ifdef USE_SDL2 SDL_SetSurfaceAlphaMod(image->mSDLSurface, SDL_ALPHA_OPAQUE); SDL_SetSurfaceBlendMode(image->mSDLSurface, @@ -261,6 +277,7 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas) #else SDL_SetAlpha(image->mSDLSurface, 0, SDL_ALPHA_OPAQUE); #endif + BLOCK_END("AtlasManager::createSDLAtlas set surface attr") graphics->drawImage(image, item->x, item->y); } } @@ -268,6 +285,7 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas) delete graphics; atlas->surface = surface; + BLOCK_END("AtlasManager::createSDLAtlas") return surface; } diff --git a/src/resources/imagehelper.cpp b/src/resources/imagehelper.cpp index 329a487da..43c1d5d1c 100644 --- a/src/resources/imagehelper.cpp +++ b/src/resources/imagehelper.cpp @@ -57,10 +57,12 @@ Image *ImageHelper::load(SDL_RWops *const rw) Image *ImageHelper::load(SDL_RWops *const rw, Dye const &dye) { + BLOCK_START("ImageHelper::load") SDL_Surface *const tmpImage = loadPng(rw); if (!tmpImage) { logger->log("Error, image load failed: %s", IMG_GetError()); + BLOCK_END("ImageHelper::load") return nullptr; } @@ -114,6 +116,7 @@ Image *ImageHelper::load(SDL_RWops *const rw, Dye const &dye) Image *const image = load(surf); MSDL_FreeSurface(surf); + BLOCK_END("ImageHelper::load") return image; } diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp index 279262124..3d13ba2e5 100644 --- a/src/resources/map/map.cpp +++ b/src/resources/map/map.cpp @@ -743,6 +743,7 @@ Path Map::findPath(const int startX, const int startY, const int destX, const int destY, const unsigned char walkmask, const int maxCost) { + BLOCK_START("Map::findPath") // The basic walking cost of a tile. static const int basicCost = 100; const int basicCost2 = 100 * 362 / 256; @@ -752,16 +753,25 @@ Path Map::findPath(const int startX, const int startY, Path path; if (startX >= mWidth || startY >= mHeight || startX < 0 || startY < 0) + { + BLOCK_END("Map::findPath") return path; + } // Return when destination not walkable if (!getWalk(destX, destY, walkmask)) + { + BLOCK_END("Map::findPath") return path; + } // Reset starting tile's G cost to 0 MetaTile *const startTile = &mMetaTiles[startX + startY * mWidth]; if (!startTile) + { + BLOCK_END("Map::findPath") return path; + } startTile->Gcost = 0; @@ -960,6 +970,7 @@ Path Map::findPath(const int startX, const int startY, } } + BLOCK_END("Map::findPath") return path; } @@ -977,8 +988,12 @@ void Map::addParticleEffect(const std::string &effectFile, void Map::initializeParticleEffects(Particle *const engine) { + BLOCK_START("Map::initializeParticleEffects") if (!engine) + { + BLOCK_END("Map::initializeParticleEffects") return; + } if (config.getBoolValue("particleeffects")) { @@ -991,13 +1006,16 @@ void Map::initializeParticleEffects(Particle *const engine) p->adjustEmitterSize(i->w, i->h); } } + BLOCK_END("Map::initializeParticleEffects") } void Map::addExtraLayer() { + BLOCK_START("Map::addExtraLayer") if (!mSpecialLayer) { logger->log1("No special layer"); + BLOCK_END("Map::addExtraLayer") return; } const std::string mapFileName = getUserMapDirectory().append( @@ -1011,6 +1029,7 @@ void Map::addExtraLayer() if (!mapFile.is_open()) { mapFile.close(); + BLOCK_END("Map::addExtraLayer") return; } char line[201]; @@ -1062,6 +1081,7 @@ void Map::addExtraLayer() } mapFile.close(); } + BLOCK_END("Map::addExtraLayer") } void Map::saveExtraLayer() const diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index f8515d021..95321fc0f 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -273,7 +273,9 @@ Map *MapReader::readMap(const std::string &restrict filename, void MapReader::loadLayers(const std::string &path) { + BLOCK_START("MapReader::loadLayers") loadXmlDir2(path, addLayerToList, ".tmx"); + BLOCK_END("MapReader::loadLayers") } void MapReader::unloadTempLayers() @@ -326,6 +328,7 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path) ResourceManager *const resman = ResourceManager::getInstance(); #ifdef USE_OPENGL + BLOCK_START("MapReader::readMap load atlas") if (graphicsManager.getUseAtlases()) { const MapInfo *const info = MapDB::getMapAtlas(fileName); @@ -335,6 +338,7 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path) info->atlas, *info->files)); } } + BLOCK_END("MapReader::readMap load atlas") #endif for_each_xml_child_node(childNode, node) @@ -460,8 +464,12 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path) void MapReader::readProperties(const XmlNodePtrConst node, Properties *const props) { + BLOCK_START("MapReader::readProperties") if (!node || !props) + { + BLOCK_END("MapReader::readProperties") return; + } for_each_xml_child_node(childNode, node) { @@ -475,6 +483,7 @@ void MapReader::readProperties(const XmlNodePtrConst node, if (!name.empty() && !value.empty()) props->setProperty(name, value); } + BLOCK_END("MapReader::readProperties") } inline static void setTile(Map *const map, MapLayer *const layer, @@ -863,8 +872,12 @@ Tileset *MapReader::readTileset(XmlNodePtr node, const std::string &path, Map *const map) { + BLOCK_START("MapReader::readTileset") if (!map) + { + BLOCK_END("MapReader::readTileset") return nullptr; + } const int firstGid = XML::getProperty(node, "firstgid", 0); const int margin = XML::getProperty(node, "margin", 0); @@ -884,6 +897,7 @@ Tileset *MapReader::readTileset(XmlNodePtr node, if (!node) { delete doc; + BLOCK_END("MapReader::readTileset") return nullptr; } @@ -1029,6 +1043,7 @@ Tileset *MapReader::readTileset(XmlNodePtr node, if (set) set->setProperties(props); + BLOCK_END("MapReader::readTileset") return set; } |