summaryrefslogtreecommitdiff
path: root/src/mbgl/style/layers/custom_layer_impl.cpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-04-26 16:39:56 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-06-02 14:51:39 -0700
commitc902f9098b331302aaa1baac77d1575db624a132 (patch)
tree211901cd04454aedbac40c469198438e46d7038c /src/mbgl/style/layers/custom_layer_impl.cpp
parent18149cbcc27a926f280b08d8d0e09104b2147688 (diff)
downloadqtlocation-mapboxgl-c902f9098b331302aaa1baac77d1575db624a132.tar.gz
[core] Rationalize naming for style-related code
Diffstat (limited to 'src/mbgl/style/layers/custom_layer_impl.cpp')
-rw-r--r--src/mbgl/style/layers/custom_layer_impl.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/mbgl/style/layers/custom_layer_impl.cpp b/src/mbgl/style/layers/custom_layer_impl.cpp
new file mode 100644
index 0000000000..214d4ce663
--- /dev/null
+++ b/src/mbgl/style/layers/custom_layer_impl.cpp
@@ -0,0 +1,68 @@
+#include <mbgl/style/layers/custom_layer_impl.hpp>
+#include <mbgl/renderer/bucket.hpp>
+#include <mbgl/map/transform_state.hpp>
+
+namespace mbgl {
+namespace style {
+
+CustomLayer::Impl::Impl(const std::string& id_,
+ CustomLayerInitializeFunction initializeFn_,
+ CustomLayerRenderFunction renderFn_,
+ CustomLayerDeinitializeFunction deinitializeFn_,
+ void* context_) {
+ id = id_;
+ initializeFn = initializeFn_;
+ renderFn = renderFn_;
+ deinitializeFn = deinitializeFn_;
+ context = context_;
+}
+
+CustomLayer::Impl::Impl(const CustomLayer::Impl& other)
+ : Layer::Impl(other) {
+ id = other.id;
+ // Don't copy anything else.
+}
+
+CustomLayer::Impl::~Impl() {
+ if (deinitializeFn) {
+ deinitializeFn(context);
+ }
+}
+
+std::unique_ptr<Layer> CustomLayer::Impl::clone() const {
+ return std::make_unique<CustomLayer>(*this);
+}
+
+void CustomLayer::Impl::initialize() {
+ assert(initializeFn);
+ initializeFn(context);
+}
+
+void CustomLayer::Impl::render(const TransformState& state) const {
+ assert(renderFn);
+
+ CustomLayerRenderParameters parameters;
+
+ parameters.width = state.getWidth();
+ parameters.height = state.getHeight();
+ parameters.latitude = state.getLatLng().latitude;
+ parameters.longitude = state.getLatLng().longitude;
+ parameters.zoom = state.getZoom();
+ parameters.bearing = -state.getAngle() * util::RAD2DEG;
+ parameters.pitch = state.getPitch();
+ parameters.altitude = state.getAltitude();
+
+ renderFn(context, parameters);
+}
+
+bool CustomLayer::Impl::recalculate(const CalculationParameters&) {
+ passes = RenderPass::Translucent;
+ return false;
+}
+
+std::unique_ptr<Bucket> CustomLayer::Impl::createBucket(BucketParameters&) const {
+ return nullptr;
+}
+
+} // namespace style
+} // namespace mbgl