diff --git a/src/Util.cpp b/src/Util.cpp index 79fe55bcf..888ffbbb5 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -1,4 +1,5 @@ #include "Util.h" +#include std::string strToUpper(const char* from) { @@ -59,3 +60,11 @@ Eigen::Vector2f roundVector(const Eigen::Vector2f& vec) ret[1] = round(ret[1]); return ret; } + +std::string getCanonicalPath(const std::string& path) +{ + if(boost::filesystem::exists(path)) + return boost::filesystem::canonical(path).generic_string(); + else + return ""; +} diff --git a/src/Util.h b/src/Util.h index c057cb747..254520619 100644 --- a/src/Util.h +++ b/src/Util.h @@ -12,3 +12,5 @@ Eigen::Vector3f roundVector(const Eigen::Vector3f& vec); Eigen::Vector2f roundVector(const Eigen::Vector2f& vec); float round(float num); + +std::string getCanonicalPath(const std::string& str); \ No newline at end of file diff --git a/src/components/ImageComponent.cpp b/src/components/ImageComponent.cpp index 9da04aab7..09fbfeb82 100644 --- a/src/components/ImageComponent.cpp +++ b/src/components/ImageComponent.cpp @@ -283,14 +283,11 @@ bool ImageComponent::hasImage() void ImageComponent::applyTheme(const std::shared_ptr& theme, const std::string& view, const std::string& element, unsigned int properties) { - LOG(LogInfo) << " req image [" << view << "." << element << "] (flags: " << properties << ")"; - using namespace ThemeFlags; const ThemeData::ThemeElement* elem = theme->getElement(view, element, "image"); if(!elem) { - LOG(LogInfo) << " (missing)"; return; } diff --git a/src/resources/Font.cpp b/src/resources/Font.cpp index 9056e7f0b..0bba66bc3 100644 --- a/src/resources/Font.cpp +++ b/src/resources/Font.cpp @@ -73,7 +73,9 @@ void Font::unload(std::shared_ptr& rm) std::shared_ptr Font::get(int size, const std::string& path) { - std::pair def(path.empty() ? getDefaultPath() : path, size); + const std::string canonicalPath = getCanonicalPath(path); + + std::pair def(canonicalPath.empty() ? getDefaultPath() : canonicalPath, size); auto foundFont = sFontMap.find(def); if(foundFont != sFontMap.end()) { diff --git a/src/resources/SVGResource.cpp b/src/resources/SVGResource.cpp index 1051303f4..f6d8608ad 100644 --- a/src/resources/SVGResource.cpp +++ b/src/resources/SVGResource.cpp @@ -69,10 +69,6 @@ void SVGResource::rasterizeAt(size_t width, size_t height) mLastHeight = height; } - LOG(LogInfo) << "Rasterizing \"" << mPath << "\"..."; - LOG(LogInfo) << " Original width: " << mSVGImage->width << ", original height: " << mSVGImage->height; - LOG(LogInfo) << " width: " << width << ", height: " << height << ", scale: " << height / mSVGImage->height; - unsigned char* imagePx = (unsigned char*)malloc(width * height * 4); NSVGrasterizer* rast = nsvgCreateRasterizer(); diff --git a/src/resources/TextureResource.cpp b/src/resources/TextureResource.cpp index af87506b6..120f01d19 100644 --- a/src/resources/TextureResource.cpp +++ b/src/resources/TextureResource.cpp @@ -4,7 +4,7 @@ #include GLHEADER #include "../ImageIO.h" #include "../Renderer.h" - +#include "../Util.h" #include "SVGResource.h" std::map< TextureResource::TextureKeyType, std::weak_ptr > TextureResource::sTextureMap; @@ -102,14 +102,16 @@ std::shared_ptr TextureResource::get(const std::string& path, b { std::shared_ptr& rm = ResourceManager::getInstance(); - if(path.empty()) + const std::string canonicalPath = getCanonicalPath(path); + + if(canonicalPath.empty()) { std::shared_ptr tex(new TextureResource("", tile)); rm->addReloadable(tex); //make sure we get properly deinitialized even though we do nothing on reinitialization return tex; } - TextureKeyType key(path, tile); + TextureKeyType key(canonicalPath, tile); auto foundTexture = sTextureMap.find(key); if(foundTexture != sTextureMap.end()) { @@ -121,18 +123,18 @@ std::shared_ptr TextureResource::get(const std::string& path, b std::shared_ptr tex; // is it an SVG? - if(path.substr(path.size() - 4, std::string::npos) == ".svg") + if(key.first.substr(key.first.size() - 4, std::string::npos) == ".svg") { // probably // don't add it to our map because 2 svgs might be rasterized at different sizes - tex = std::shared_ptr(new SVGResource(path, tile)); + tex = std::shared_ptr(new SVGResource(key.first, tile)); sTextureList.push_back(tex); // add it to our list though rm->addReloadable(tex); tex->reload(rm); return tex; }else{ // normal texture - tex = std::shared_ptr(new TextureResource(path, tile)); + tex = std::shared_ptr(new TextureResource(key.first, tile)); sTextureMap[key] = std::weak_ptr(tex); sTextureList.push_back(tex); rm->addReloadable(tex);