[core] Add DDS support for {text,icon}-size (#8593)
* Update gl-js and generate style code
* Factor out packUint8Pair() helper function
* Draft implementation of DDS for {text,icon}-size
Ports https://github.com/mapbox/mapbox-gl-js/pull/4455
* Fix text-size/composite-function-line-placement test
* Refactor to PaintPropertyBinders-like strategy
* Dedupe gl::Program construction
* Use exponential function base for interpolation
* Dedupe coveringZoomStops method
* Fixup tests
* Fix CI errors (hidden within #if block)
This commit is contained in:
@@ -34,55 +34,12 @@ public:
|
||||
ProgramType program;
|
||||
|
||||
Program(gl::Context& context, const ProgramParameters& programParameters)
|
||||
: program([&] {
|
||||
#if MBGL_HAS_BINARY_PROGRAMS
|
||||
if (!programParameters.cacheDir.empty() && context.supportsProgramBinaries()) {
|
||||
const std::string vertexSource =
|
||||
shaders::vertexSource(programParameters, Shaders::vertexSource);
|
||||
const std::string fragmentSource =
|
||||
shaders::fragmentSource(programParameters, Shaders::fragmentSource);
|
||||
const std::string cachePath =
|
||||
shaders::programCachePath(programParameters, Shaders::name);
|
||||
const std::string identifier =
|
||||
shaders::programIdentifier(vertexSource, fragmentSource);
|
||||
|
||||
try {
|
||||
if (auto cachedBinaryProgram = util::readFile(cachePath)) {
|
||||
const BinaryProgram binaryProgram(std::move(*cachedBinaryProgram));
|
||||
if (binaryProgram.identifier() == identifier) {
|
||||
return ProgramType{ context, binaryProgram };
|
||||
} else {
|
||||
Log::Warning(Event::OpenGL,
|
||||
"Cached program %s changed. Recompilation required.",
|
||||
Shaders::name);
|
||||
}
|
||||
}
|
||||
} catch (std::runtime_error& error) {
|
||||
Log::Warning(Event::OpenGL, "Could not load cached program: %s",
|
||||
error.what());
|
||||
}
|
||||
|
||||
// Compile the shader
|
||||
ProgramType result{ context, vertexSource, fragmentSource };
|
||||
|
||||
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());
|
||||
}
|
||||
} catch (std::runtime_error& error) {
|
||||
Log::Warning(Event::OpenGL, "Failed to cache program: %s", error.what());
|
||||
}
|
||||
|
||||
return std::move(result);
|
||||
}
|
||||
#endif
|
||||
return ProgramType{
|
||||
context, shaders::vertexSource(programParameters, Shaders::vertexSource),
|
||||
shaders::fragmentSource(programParameters, Shaders::fragmentSource)
|
||||
};
|
||||
}()) {
|
||||
: program(ProgramType::createProgram(
|
||||
context,
|
||||
programParameters,
|
||||
Shaders::name,
|
||||
Shaders::vertexSource,
|
||||
Shaders::fragmentSource)) {
|
||||
}
|
||||
|
||||
template <class DrawMode>
|
||||
|
||||
Reference in New Issue
Block a user