[core] move ProgramMap to within the gl::Program object

This commit is contained in:
Konstantin Käfer
2019-03-19 14:02:10 +01:00
parent 53ab65d811
commit 1e30fdac36
53 changed files with 822 additions and 330 deletions

View File

@@ -109,36 +109,6 @@ public:
}
};
template <class Program>
class ProgramMap {
public:
using PaintProperties = typename Program::PaintProperties;
using Binders = typename Program::Binders;
using Bitset = typename Binders::Bitset;
ProgramMap(gfx::Context& context_, ProgramParameters parameters_)
: context(context_),
parameters(std::move(parameters_)) {
}
Program& get(const typename PaintProperties::PossiblyEvaluated& currentProperties) {
Bitset bits = Binders::constants(currentProperties);
auto it = programs.find(bits);
if (it != programs.end()) {
return it->second;
}
return programs.emplace(std::piecewise_construct,
std::forward_as_tuple(bits),
std::forward_as_tuple(context,
parameters.withAdditionalDefines(Binders::defines(currentProperties)))).first->second;
}
private:
gfx::Context& context;
ProgramParameters parameters;
std::unordered_map<Bitset, Program> programs;
};
class LayerTypePrograms {
public:
virtual ~LayerTypePrograms() = default;