Files
MapLibreParticleLab/src/mbgl/style/layers/custom_layer.cpp
Mikhail Pozdnyakov 361982fef8 [core][Android][Darwin] LayerManager creates RenderLayer instances
`LayerManager` is now responsible for `RenderLayer` instances creation,
so that there is a single entry point for creating of objects, which
correspond to a certain layer type.

The `LayerType type` field is dropped from `Layer::Impl`.
2018-11-27 18:10:21 +02:00

74 lines
2.1 KiB
C++

#include <mbgl/style/layers/custom_layer.hpp>
#include <mbgl/style/layers/custom_layer_impl.hpp>
#include <mbgl/style/layer_observer.hpp>
#include <mbgl/renderer/layers/render_custom_layer.hpp>
namespace mbgl {
namespace style {
namespace {
const LayerTypeInfo typeInfoCustom
{ "",
LayerTypeInfo::Source::NotRequired,
LayerTypeInfo::Pass3D::NotRequired,
LayerTypeInfo::Layout::NotRequired,
LayerTypeInfo::Clipping::NotRequired };
} // namespace
CustomLayer::CustomLayer(const std::string& layerID,
std::unique_ptr<CustomLayerHost> host)
: Layer(makeMutable<Impl>(layerID, std::move(host))) {
}
CustomLayer::~CustomLayer() = default;
const CustomLayer::Impl& CustomLayer::impl() const {
return static_cast<const Impl&>(*baseImpl);
}
Mutable<CustomLayer::Impl> CustomLayer::mutableImpl() const {
return makeMutable<Impl>(impl());
}
std::unique_ptr<Layer> CustomLayer::cloneRef(const std::string&) const {
assert(false);
return nullptr;
}
using namespace conversion;
optional<Error> CustomLayer::setPaintProperty(const std::string&, const Convertible&) {
return Error { "layer doesn't support this property" };
}
optional<Error> CustomLayer::setLayoutProperty(const std::string&, const Convertible&) {
return Error { "layer doesn't support this property" };
}
Mutable<Layer::Impl> CustomLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
// static
const LayerTypeInfo* CustomLayer::Impl::staticTypeInfo() noexcept {
return &typeInfoCustom;
}
} // namespace style
const style::LayerTypeInfo* CustomLayerFactory::getTypeInfo() const noexcept {
return &style::typeInfoCustom;
}
std::unique_ptr<style::Layer> CustomLayerFactory::createLayer(const std::string&, const style::conversion::Convertible&) noexcept {
assert(false);
return nullptr;
}
std::unique_ptr<RenderLayer> CustomLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
return std::make_unique<RenderCustomLayer>(staticImmutableCast<style::CustomLayer::Impl>(std::move(impl)));
}
} // namespace mbgl