diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-06-05 12:15:27 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-06-14 11:13:43 -0700 |
commit | d618d4a274023257988a91e96ecf794338189bf8 (patch) | |
tree | 71cdbf029ef7c36520be0efc7e18de68f3ebbbfb /src/mbgl/gl/program.hpp | |
parent | 212ae5273dc3930a035b51c603c540b4f02fa777 (diff) | |
download | qtlocation-mapboxgl-d618d4a274023257988a91e96ecf794338189bf8.tar.gz |
[core] Dynamic program compilation for data-driven properties
Diffstat (limited to 'src/mbgl/gl/program.hpp')
-rw-r--r-- | src/mbgl/gl/program.hpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/mbgl/gl/program.hpp b/src/mbgl/gl/program.hpp index c36543839c..47ad39de7c 100644 --- a/src/mbgl/gl/program.hpp +++ b/src/mbgl/gl/program.hpp @@ -50,7 +50,8 @@ public: const char* vertexSource_, const char* fragmentSource_) { #if MBGL_HAS_BINARY_PROGRAMS - if (!programParameters.cacheDir.empty() && context.supportsProgramBinaries()) { + optional<std::string> cachePath = programParameters.cachePath(name); + if (cachePath && context.supportsProgramBinaries()) { const std::string vertexSource = shaders::vertexSource(programParameters, vertexSource_); const std::string fragmentSource = @@ -58,10 +59,8 @@ public: const std::string identifier = shaders::programIdentifier(vertexSource, fragmentSource_); - const std::string cachePath = programParameters.cachePath(name); - try { - if (auto cachedBinaryProgram = util::readFile(cachePath)) { + if (auto cachedBinaryProgram = util::readFile(*cachePath)) { const BinaryProgram binaryProgram(std::move(*cachedBinaryProgram)); if (binaryProgram.identifier() == identifier) { return Program { context, binaryProgram }; @@ -82,8 +81,8 @@ public: try { if (const auto binaryProgram = result.template get<BinaryProgram>(context, identifier)) { - util::write_file(cachePath, binaryProgram->serialize()); - Log::Warning(Event::OpenGL, "Caching program in: %s", cachePath.c_str()); + util::write_file(*cachePath, binaryProgram->serialize()); + Log::Warning(Event::OpenGL, "Caching program in: %s", (*cachePath).c_str()); } } catch (std::runtime_error& error) { Log::Warning(Event::OpenGL, "Failed to cache program: %s", error.what()); |