|
From: Tapio V. <aa...@us...> - 2010-10-19 16:27:41
|
Module: performous
Branch: master
Commit: 3201b2c79c81fd27fd596b9371160f3a2640c574
Author: Tapio Vierros <tap...@gm...>
Date: Tue Oct 19 19:26:57 2010 +0300
Uses SVG caching also for non-theme files.
---
game/cache.cc | 10 +++++-----
game/cache.hh | 4 ++--
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/game/cache.cc b/game/cache.cc
index babd3b2..e549763 100644
--- a/game/cache.cc
+++ b/game/cache.cc
@@ -10,13 +10,13 @@ namespace cache {
std::string const lod = (boost::format("%.2f") % factor).str();
std::string const cache_basename = svgfilename.filename() + ".cache_" + lod + ".png";
- // presently only theme resources are cachable, "true ||" makes sure the compiler optimize out the conditional code
- if(true || isThemeResource(svgfilename)){
+ if (isThemeResource(svgfilename)) {
std::string const theme_name = (config["game/theme"].s().empty() ? "default" : config["game/theme"].s());
cache_filename = getCacheDir() / "themes" / theme_name / cache_basename;
- }else {
- // RFC: is this a sensible "fallback"?
- cache_filename = getCacheDir() / "misc" / cache_basename;
+ } else {
+ // We use the full path under cache to avoid name collisions
+ // with images other than theme files (mostly backgrounds).
+ cache_filename = getCacheDir() / "misc" / svgfilename.parent_path() / cache_basename;
}
return cache_filename;
diff --git a/game/cache.hh b/game/cache.hh
index e45fd5d..564cd8b 100644
--- a/game/cache.hh
+++ b/game/cache.hh
@@ -23,8 +23,8 @@ namespace cache {
/** Given a path to an SVG the caching policy is returned **/
inline bool cachableSVGResource(fs::path const& svgfilename) {
- // currently only theme files are cachable
- return isThemeResource(svgfilename);
+ // FIXME: Currently all is cached, so should this be removed?
+ return true;
}
/** Load an SVG from the cache, if loading fails invalid_cache_error is thrown **/
|