Drawable Renderer (#1570), refactor

This commit is contained in:
Tim Sylvester
2023-05-02 09:01:39 -07:00
committed by Bart Louwers
parent c7299eaf20
commit b2a3e518c7
4 changed files with 16 additions and 16 deletions

View File

@@ -779,7 +779,17 @@ const gfx::DrawablePtr& RenderOrchestrator::getDrawable(const util::SimpleIdenti
void RenderOrchestrator::updateLayers(gfx::ShaderRegistry& shaders,
gfx::Context& context,
const TransformState& state,
const PropertyEvaluationParameters& evalParameters) {
const std::shared_ptr<UpdateParameters>& updateParameters) {
const bool isMapModeContinuous = updateParameters->mode == MapMode::Continuous;
const auto transitionOptions = isMapModeContinuous ? updateParameters->transitionOptions : style::TransitionOptions();
const auto defDuration = isMapModeContinuous ? util::DEFAULT_TRANSITION_DURATION : Duration::zero();
const PropertyEvaluationParameters evalParameters {
getZoomHistory(),
updateParameters->timePoint,
transitionOptions.duration.value_or(defDuration),
};
std::vector<std::unique_ptr<ChangeRequest>> changes;
for (auto& kv : layersRemoved) {

View File

@@ -104,7 +104,7 @@ public:
void updateLayers(gfx::ShaderRegistry&,
gfx::Context&,
const TransformState&,
const PropertyEvaluationParameters&);
const std::shared_ptr<UpdateParameters>&);
void processChanges();

View File

@@ -33,23 +33,13 @@ void Renderer::render(const std::shared_ptr<UpdateParameters>& updateParameters)
if (auto renderTree = impl->orchestrator.createRenderTree(updateParameters)) {
renderTree->prepare();
const bool isMapModeContinuous = updateParameters->mode == MapMode::Continuous;
const auto transitionOptions = isMapModeContinuous ? updateParameters->transitionOptions : style::TransitionOptions();
//const TransitionParameters transitionParameters{updateParameters->timePoint, transitionOptions};
const auto defDuration = isMapModeContinuous ? util::DEFAULT_TRANSITION_DURATION : Duration::zero();
const PropertyEvaluationParameters evalParameters {
impl->orchestrator.getZoomHistory(),
updateParameters->timePoint,
transitionOptions.duration.value_or(defDuration),
};
const auto& renderTreeParameters = renderTree->getParameters();
const auto& state = renderTreeParameters.transformParams.state;
if (impl->staticData && impl->staticData->shaders) {
auto& context = impl->backend.getContext();
auto& shaders = *impl->staticData->shaders;
impl->orchestrator.updateLayers(shaders, context, state, evalParameters);
impl->orchestrator.updateLayers(shaders, context, state, updateParameters);
}
impl->render(*renderTree);

View File

@@ -70,6 +70,7 @@ void BackgroundLayer::Impl::update(gfx::Context& context,
}
const auto evaluated = unevaluated->evaluate(evalParameters);
// TODO: If background is solid, we can skip drawables and rely on the clear color
//const auto passes = eval.get<style::BackgroundOpacity>() == 0.0f
// ? RenderPass::None
// : (!uneval.get<style::BackgroundPattern>().isUndefined()
@@ -127,10 +128,9 @@ void BackgroundLayer::Impl::update(gfx::Context& context,
}
++iter;
// If the color evaluated to a new value, emit a change request updating all vertexes of
// the existing drawable to the new color.
// If the color evaluated to a new value, update all vertexes of the drawable to the new color
if (colorChange) {
changes.emplace_back(std::make_unique<ResetColorRequest>(drawable->getId(), *color));
drawable->resetColor(*color);
}
}