summaryrefslogtreecommitdiff
path: root/src/mbgl/gl
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-06-05 12:15:27 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-06-13 12:21:50 -0700
commit9d276f3b0f0e5f1b5089a6cd727927361e6634ac (patch)
treebbf0c446055126f060e8ee759b7b71281dea8f80 /src/mbgl/gl
parent18b50f51b4fa14b9f2fe6f865dc47490b22e74c6 (diff)
downloadqtlocation-mapboxgl-9d276f3b0f0e5f1b5089a6cd727927361e6634ac.tar.gz
[core] Dynamic program compilation for data-driven properties
Diffstat (limited to 'src/mbgl/gl')
-rw-r--r--src/mbgl/gl/program.hpp11
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());