diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-03-15 18:43:58 +0100 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-03 11:01:43 -0700 |
commit | f86333961eeacb9f2dd83a4c3680d30e06f947a7 (patch) | |
tree | e26d375a7852526196428bc86e9b7b94e2baf6f9 /src/mbgl/shaders/shaders.cpp | |
parent | c1cd6759b4a87ef58442e864a192317284cf20ae (diff) | |
download | qtlocation-mapboxgl-f86333961eeacb9f2dd83a4c3680d30e06f947a7.tar.gz |
[core] cache binary shaders on Android
Diffstat (limited to 'src/mbgl/shaders/shaders.cpp')
-rw-r--r-- | src/mbgl/shaders/shaders.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mbgl/shaders/shaders.cpp b/src/mbgl/shaders/shaders.cpp index f7f5b4d44f..03d796edba 100644 --- a/src/mbgl/shaders/shaders.cpp +++ b/src/mbgl/shaders/shaders.cpp @@ -4,6 +4,7 @@ #include <cassert> #include <sstream> +#include <iomanip> namespace mbgl { namespace shaders { @@ -29,5 +30,18 @@ std::string vertexSource(const ProgramParameters& parameters, const char* vertex return pixelRatioDefine(parameters) + vertexPrelude + vertexSource; } +std::string programCachePath(const ProgramParameters& parameters, const char* name) { + return parameters.cacheDir + "/com.mapbox.gl.shader." + name + + (parameters.overdraw ? ".overdraw.pbf" : ".pbf"); +} + +std::string programIdentifier(const std::string& vertexSource, const std::string& fragmentSource) { + std::ostringstream ss; + ss << std::setfill('0') << std::setw(sizeof(size_t) * 2) << std::hex; + ss << std::hash<std::string>()(vertexSource); + ss << std::hash<std::string>()(fragmentSource); + return ss.str(); +} + } // namespace shaders } // namespace mbgl |