Don't use std::function in the renderer hot paths (#1883)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
mwilsnd
2023-11-27 10:36:03 -05:00
committed by GitHub
parent bf472b0703
commit 71d4ceabcd
27 changed files with 260 additions and 311 deletions

View File

@@ -84,7 +84,7 @@ void RenderLayer::replaceTweaker(LayerTweakerPtr& curTweaker,
if (group) {
group->addLayerTweaker(newTweaker);
group->visitDrawables([&](gfx::Drawable& drawable) {
visitLayerGroupDrawables(*group, [&](gfx::Drawable& drawable) {
if (drawable.getLayerTweaker() == prevTweaker) {
drawable.setLayerTweaker(newTweaker);
}
@@ -166,30 +166,6 @@ const LayerRenderData* RenderLayer::getRenderDataForPass(const RenderTile& tile,
}
#if MLN_DRAWABLE_RENDERER
bool RenderLayer::updateTile(RenderPass renderPass,
const OverscaledTileID& tileID,
std::function<bool(gfx::Drawable&)> update) {
bool anyUpdated = false;
if (const auto tileGroup = static_cast<TileLayerGroup*>(layerGroup.get())) {
bool unUpdatedDrawables = false;
tileGroup->visitDrawables(renderPass, tileID, [&](gfx::Drawable& drawable) {
if (update(drawable)) {
anyUpdated = true;
} else {
unUpdatedDrawables = true;
}
});
// If any are updated, the caller shouldn't add new ones.
// If none are updated and some were skipped, remove those.
// This is to handle the case that the style layer changes but the bucket is not re-created.
if (!anyUpdated && unUpdatedDrawables) {
removeTile(renderPass, tileID);
}
}
return anyUpdated;
}
std::size_t RenderLayer::removeTile(RenderPass renderPass, const OverscaledTileID& tileID) {
if (const auto tileGroup = static_cast<TileLayerGroup*>(layerGroup.get())) {
const auto n = tileGroup->removeDrawables(renderPass, tileID).size();