Drawable Renderer (#1570), [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
committed by
Bart Louwers
parent
af39aca061
commit
43a05515e9
@@ -41,8 +41,9 @@ protected:
|
||||
*/
|
||||
class RefChangeRequest : public ChangeRequest {
|
||||
protected:
|
||||
RefChangeRequest(util::SimpleIdentity id_) : id(id_) {}
|
||||
RefChangeRequest(const RefChangeRequest&) = default;
|
||||
RefChangeRequest(util::SimpleIdentity id_)
|
||||
: id(id_) {}
|
||||
RefChangeRequest(const RefChangeRequest &) = default;
|
||||
|
||||
util::SimpleIdentity id;
|
||||
};
|
||||
@@ -57,7 +58,7 @@ public:
|
||||
AddDrawableRequest(AddDrawableRequest &&other)
|
||||
: drawable(std::move(other.drawable)) {}
|
||||
|
||||
void execute(RenderOrchestrator&) override;
|
||||
void execute(RenderOrchestrator &) override;
|
||||
|
||||
protected:
|
||||
gfx::DrawablePtr drawable;
|
||||
@@ -72,7 +73,7 @@ public:
|
||||
: RefChangeRequest(id) {}
|
||||
RemoveDrawableRequest(const RemoveDrawableRequest &) = default;
|
||||
|
||||
void execute(RenderOrchestrator&) override;
|
||||
void execute(RenderOrchestrator &) override;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -85,22 +86,21 @@ public:
|
||||
newColor(color) {}
|
||||
ResetColorRequest(const ResetColorRequest &other) = default;
|
||||
|
||||
void execute(RenderOrchestrator&) override;
|
||||
void execute(RenderOrchestrator &) override;
|
||||
|
||||
protected:
|
||||
Color newColor;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Add a new layer group to the scene
|
||||
*/
|
||||
class AddLayerGroupRequest : public ChangeRequest {
|
||||
public:
|
||||
AddLayerGroupRequest(UniqueLayerGroup&& layerGroup_, bool canReplace);
|
||||
AddLayerGroupRequest(AddLayerGroupRequest&& other);
|
||||
AddLayerGroupRequest(UniqueLayerGroup &&layerGroup_, bool canReplace);
|
||||
AddLayerGroupRequest(AddLayerGroupRequest &&other);
|
||||
|
||||
void execute(RenderOrchestrator&) override;
|
||||
void execute(RenderOrchestrator &) override;
|
||||
|
||||
protected:
|
||||
UniqueLayerGroup layerGroup;
|
||||
@@ -116,8 +116,7 @@ public:
|
||||
: RefChangeRequest(id) {}
|
||||
RemoveLayerGroupRequest(const RemoveLayerGroupRequest &) = default;
|
||||
|
||||
void execute(RenderOrchestrator&) override;
|
||||
void execute(RenderOrchestrator &) override;
|
||||
};
|
||||
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -39,13 +39,13 @@ public:
|
||||
int32_t getLayerIndex() const { return layerIndex; }
|
||||
|
||||
/// Called before starting each frame
|
||||
virtual void preRender(RenderOrchestrator&, PaintParameters&) { }
|
||||
virtual void preRender(RenderOrchestrator&, PaintParameters&) {}
|
||||
/// Called during the upload pass
|
||||
virtual void upload(gfx::Context&, gfx::UploadPass&) { }
|
||||
virtual void upload(gfx::Context&, gfx::UploadPass&) {}
|
||||
/// Called during each render pass
|
||||
virtual void render(RenderOrchestrator&, PaintParameters&) { }
|
||||
virtual void render(RenderOrchestrator&, PaintParameters&) {}
|
||||
/// Called at the end of each frame
|
||||
virtual void postRender(RenderOrchestrator&, PaintParameters&) { }
|
||||
virtual void postRender(RenderOrchestrator&, PaintParameters&) {}
|
||||
|
||||
protected:
|
||||
int32_t layerIndex;
|
||||
@@ -66,5 +66,4 @@ protected:
|
||||
std::unique_ptr<Impl> impl;
|
||||
};
|
||||
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -17,13 +17,12 @@ void ResetColorRequest::execute(RenderOrchestrator &orchestrator) {
|
||||
}
|
||||
}
|
||||
|
||||
AddLayerGroupRequest::AddLayerGroupRequest(UniqueLayerGroup&& layerGroup_, bool canReplace)
|
||||
: layerGroup(std::move(layerGroup_)), replace(canReplace) {
|
||||
}
|
||||
AddLayerGroupRequest::AddLayerGroupRequest(UniqueLayerGroup &&layerGroup_, bool canReplace)
|
||||
: layerGroup(std::move(layerGroup_)),
|
||||
replace(canReplace) {}
|
||||
|
||||
AddLayerGroupRequest::AddLayerGroupRequest(AddLayerGroupRequest&& other)
|
||||
: layerGroup(std::move(other.layerGroup)) {
|
||||
}
|
||||
AddLayerGroupRequest::AddLayerGroupRequest(AddLayerGroupRequest &&other)
|
||||
: layerGroup(std::move(other.layerGroup)) {}
|
||||
|
||||
void AddLayerGroupRequest::execute(RenderOrchestrator &orchestrator) {
|
||||
orchestrator.addLayerGroup(std::move(layerGroup), replace);
|
||||
|
||||
@@ -16,40 +16,34 @@ struct TileLayerGroupTileKey {
|
||||
}
|
||||
struct hash {
|
||||
size_t operator()(const mbgl::TileLayerGroupTileKey& k) const {
|
||||
return (std::hash<mbgl::RenderPass>()(k.renderPass) ^
|
||||
std::hash<OverscaledTileID>()(k.tileID) << 1);
|
||||
return (std::hash<mbgl::RenderPass>()(k.renderPass) ^ std::hash<OverscaledTileID>()(k.tileID) << 1);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
struct TileLayerGroup::Impl {
|
||||
Impl(std::size_t capacity) : tileDrawables(capacity) { }
|
||||
|
||||
Impl(std::size_t capacity)
|
||||
: tileDrawables(capacity) {}
|
||||
|
||||
using TileMap = std::unordered_map<TileLayerGroupTileKey, gfx::UniqueDrawable, TileLayerGroupTileKey::hash>;
|
||||
TileMap tileDrawables;
|
||||
};
|
||||
|
||||
LayerGroup::LayerGroup(int32_t layerIndex_) :
|
||||
layerIndex(layerIndex_) {
|
||||
|
||||
}
|
||||
LayerGroup::LayerGroup(int32_t layerIndex_)
|
||||
: layerIndex(layerIndex_) {}
|
||||
|
||||
TileLayerGroup::TileLayerGroup(int32_t layerIndex_, std::size_t initialCapacity) :
|
||||
LayerGroup(layerIndex_),
|
||||
impl(std::make_unique<Impl>(initialCapacity))
|
||||
{
|
||||
}
|
||||
TileLayerGroup::TileLayerGroup(int32_t layerIndex_, std::size_t initialCapacity)
|
||||
: LayerGroup(layerIndex_),
|
||||
impl(std::make_unique<Impl>(initialCapacity)) {}
|
||||
|
||||
TileLayerGroup::~TileLayerGroup() {
|
||||
}
|
||||
TileLayerGroup::~TileLayerGroup() {}
|
||||
|
||||
void TileLayerGroup::render([[maybe_unused]] RenderOrchestrator& orchestrator, [[maybe_unused]] PaintParameters& parameters) {
|
||||
void TileLayerGroup::render([[maybe_unused]] RenderOrchestrator& orchestrator,
|
||||
[[maybe_unused]] PaintParameters& parameters) {
|
||||
auto pass = mbgl::RenderPass::Opaque;
|
||||
auto id = OverscaledTileID{0,0,0,0,0};
|
||||
auto id = OverscaledTileID{0, 0, 0, 0, 0};
|
||||
auto key = TileLayerGroupTileKey{pass, id};
|
||||
impl->tileDrawables.insert(std::make_pair(key, gfx::UniqueDrawable()));
|
||||
}
|
||||
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
|
||||
@@ -224,7 +224,8 @@ void RenderBackgroundLayer::update(const int32_t layerIndex,
|
||||
shader = context.getGenericShader(shaders, shaderName);
|
||||
}
|
||||
|
||||
changes.emplace_back(std::make_unique<AddLayerGroupRequest>(std::make_unique<TileLayerGroup>(layerIndex, 10), /*replace*/true));
|
||||
changes.emplace_back(
|
||||
std::make_unique<AddLayerGroupRequest>(std::make_unique<TileLayerGroup>(layerIndex, 10), /*replace*/ true));
|
||||
|
||||
const auto& evaluated = getEvaluated<BackgroundLayerProperties>(evaluatedProperties);
|
||||
|
||||
|
||||
@@ -776,9 +776,7 @@ const gfx::DrawablePtr& RenderOrchestrator::getDrawable(const util::SimpleIdenti
|
||||
return (hit != drawables.end()) ? hit->second : noDrawable;
|
||||
}
|
||||
|
||||
void RenderOrchestrator::onRemoveLayerGroup(LayerGroup&) {
|
||||
|
||||
}
|
||||
void RenderOrchestrator::onRemoveLayerGroup(LayerGroup&) {}
|
||||
|
||||
bool RenderOrchestrator::addLayerGroup(UniqueLayerGroup&& layerGroup, const bool replace) {
|
||||
const auto index = layerGroup->getLayerIndex();
|
||||
@@ -833,7 +831,6 @@ void RenderOrchestrator::observeLayerGroups(std::function<void(const LayerGroup&
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RenderOrchestrator::updateLayers(gfx::ShaderRegistry& shaders,
|
||||
gfx::Context& context,
|
||||
const TransformState& state,
|
||||
|
||||
@@ -185,10 +185,9 @@ private:
|
||||
|
||||
DrawableMap drawables;
|
||||
std::vector<std::unique_ptr<ChangeRequest>> pendingChanges;
|
||||
|
||||
|
||||
using LayerGroupMap = std::map<int32_t, UniqueLayerGroup>;
|
||||
LayerGroupMap layerGroupsByLayerIndex;
|
||||
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -104,10 +104,8 @@ void Renderer::Impl::render(const RenderTree& renderTree) {
|
||||
}
|
||||
|
||||
// Give the layers a chance to do setup
|
||||
orchestrator.observeLayerGroups([&](LayerGroup& layerGroup){
|
||||
layerGroup.preRender(orchestrator, parameters);
|
||||
});
|
||||
|
||||
orchestrator.observeLayerGroups([&](LayerGroup& layerGroup) { layerGroup.preRender(orchestrator, parameters); });
|
||||
|
||||
// Sort the drawables
|
||||
std::sort(drawables.begin(), drawables.end(), gfx::DrawablePtrLessByLayer(/*descending=*/true));
|
||||
|
||||
@@ -160,11 +158,9 @@ void Renderer::Impl::render(const RenderTree& renderTree) {
|
||||
drawableGL.setVertexArray(std::move(vertexArray), std::move(vertexBuffer), std::move(indexBuffer));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Give the layers a chance to upload
|
||||
orchestrator.observeLayerGroups([&](LayerGroup& layerGroup){
|
||||
layerGroup.upload(context, *uploadPass);
|
||||
});
|
||||
orchestrator.observeLayerGroups([&](LayerGroup& layerGroup) { layerGroup.upload(context, *uploadPass); });
|
||||
}
|
||||
|
||||
// - 3D PASS
|
||||
@@ -254,9 +250,7 @@ void Renderer::Impl::render(const RenderTree& renderTree) {
|
||||
};
|
||||
|
||||
// draw layer groups, opaque pass
|
||||
orchestrator.observeLayerGroups([&](LayerGroup& layerGroup){
|
||||
layerGroup.render(orchestrator, parameters);
|
||||
});
|
||||
orchestrator.observeLayerGroups([&](LayerGroup& layerGroup) { layerGroup.render(orchestrator, parameters); });
|
||||
|
||||
parameters.pass = RenderPass::Opaque;
|
||||
parameters.currentLayer = 0;
|
||||
@@ -292,9 +286,7 @@ void Renderer::Impl::render(const RenderTree& renderTree) {
|
||||
drawDrawables(parameters.pass);
|
||||
|
||||
// draw layer groups, translucent pass
|
||||
orchestrator.observeLayerGroups([&](LayerGroup& layerGroup){
|
||||
layerGroup.render(orchestrator, parameters);
|
||||
});
|
||||
orchestrator.observeLayerGroups([&](LayerGroup& layerGroup) { layerGroup.render(orchestrator, parameters); });
|
||||
|
||||
parameters.opaquePassCutoff = renderTreeParameters.opaquePassCutOff;
|
||||
|
||||
@@ -339,9 +331,7 @@ void Renderer::Impl::render(const RenderTree& renderTree) {
|
||||
#endif
|
||||
|
||||
// Give the layers a chance to do cleanup
|
||||
orchestrator.observeLayerGroups([&](LayerGroup& layerGroup){
|
||||
layerGroup.postRender(orchestrator, parameters);
|
||||
});
|
||||
orchestrator.observeLayerGroups([&](LayerGroup& layerGroup) { layerGroup.postRender(orchestrator, parameters); });
|
||||
|
||||
// Ends the RenderPass
|
||||
parameters.renderPass.reset();
|
||||
|
||||
Reference in New Issue
Block a user