[core] Dynamic program compilation for data-driven properties
This commit is contained in:
@@ -7,7 +7,7 @@ namespace mbgl {
|
||||
|
||||
ProgramParameters::ProgramParameters(const float pixelRatio,
|
||||
const bool overdraw,
|
||||
std::string cacheDir_)
|
||||
optional<std::string> cacheDir_)
|
||||
: defines([&] {
|
||||
std::ostringstream ss;
|
||||
ss.imbue(std::locale("C"));
|
||||
@@ -18,15 +18,31 @@ ProgramParameters::ProgramParameters(const float pixelRatio,
|
||||
}
|
||||
return ss.str();
|
||||
}()),
|
||||
hash(std::hash<std::string>()(defines)),
|
||||
cacheDir(std::move(cacheDir_)) {
|
||||
}
|
||||
|
||||
std::string ProgramParameters::cachePath(const char* name) const {
|
||||
std::ostringstream ss;
|
||||
ss << cacheDir << "/com.mapbox.gl.shader." << name << "." << std::setfill('0')
|
||||
<< std::setw(sizeof(size_t) * 2) << std::hex << hash << ".pbf";
|
||||
return ss.str();
|
||||
const std::string& ProgramParameters::getDefines() const {
|
||||
return defines;
|
||||
}
|
||||
|
||||
optional<std::string> ProgramParameters::cachePath(const char* name) const {
|
||||
if (!cacheDir) {
|
||||
return {};
|
||||
} else {
|
||||
std::ostringstream ss;
|
||||
ss << *cacheDir << "/com.mapbox.gl.shader." << name << "." << std::setfill('0')
|
||||
<< std::setw(sizeof(size_t) * 2) << std::hex << std::hash<std::string>()(defines) << ".pbf";
|
||||
return ss.str();
|
||||
}
|
||||
}
|
||||
|
||||
ProgramParameters ProgramParameters::withAdditionalDefines(const std::vector<std::string>& additionalDefines) const {
|
||||
ProgramParameters result(*this);
|
||||
for (const auto& define : additionalDefines) {
|
||||
result.defines += define;
|
||||
result.defines += "\n";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
Reference in New Issue
Block a user