[core] move ProgramMap to within the gl::Program object
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user