summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer/render_layer.hpp
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-04-21 09:19:47 -0700
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2017-04-25 17:23:54 -0700
commit3c175adf30546fe58713b8fed29ac35a85e150be (patch)
tree5666e9bcf311ed1b86a13444e50dc7a030c10da9 /src/mbgl/renderer/render_layer.hpp
parentea8ec38df156c6683c886253dbb1f6bc828686ff (diff)
downloadqtlocation-mapboxgl-3c175adf30546fe58713b8fed29ac35a85e150be.tar.gz
[core] split off render layers
Diffstat (limited to 'src/mbgl/renderer/render_layer.hpp')
-rw-r--r--src/mbgl/renderer/render_layer.hpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/src/mbgl/renderer/render_layer.hpp b/src/mbgl/renderer/render_layer.hpp
new file mode 100644
index 0000000000..af5345d5e3
--- /dev/null
+++ b/src/mbgl/renderer/render_layer.hpp
@@ -0,0 +1,87 @@
+#pragma once
+
+#include <mbgl/renderer/render_pass.hpp>
+#include <mbgl/style/layer_impl.hpp>
+#include <mbgl/style/layer_type.hpp>
+#include <mbgl/tile/geometry_tile_data.hpp>
+
+#include <memory>
+#include <string>
+
+namespace mbgl {
+
+class Bucket;
+class BucketParameters;
+
+namespace style {
+class CascadeParameters;
+class PropertyEvaluationParameters;
+} // namespace style
+
+class RenderLayer {
+
+protected:
+ RenderLayer(style::LayerType, const style::Layer::Impl&);
+
+ const style::LayerType type;
+
+public:
+
+ virtual ~RenderLayer() = default;
+
+ // Create an identical copy of this layer.
+ virtual std::unique_ptr<RenderLayer> clone() const = 0;
+
+ // Partially evaluate paint properties based on a set of classes.
+ virtual void cascade(const style::CascadeParameters&) = 0;
+
+ // Fully evaluate cascaded paint properties based on a zoom level.
+ // Returns true if any paint properties have active transitions.
+ virtual bool evaluate(const style::PropertyEvaluationParameters&) = 0;
+
+ // Check whether this layer is of the given subtype.
+ template <class T>
+ bool is() const;
+
+ // Dynamically cast this layer to the given subtype.
+ template <class T>
+ T* as() {
+ return is<T>() ? reinterpret_cast<T*>(this) : nullptr;
+ }
+
+ template <class T>
+ const T* as() const {
+ return is<T>() ? reinterpret_cast<const T*>(this) : nullptr;
+ }
+
+ const std::string& getID() const;
+
+ // Checks whether this layer needs to be rendered in the given render pass.
+ bool hasRenderPass(RenderPass) const;
+
+ // Checks whether this layer can be rendered.
+ bool needsRendering(float zoom) const;
+
+ // Check wether the given geometry intersects
+ // with the feature
+ virtual bool queryIntersectsFeature(
+ const GeometryCoordinates&,
+ const GeometryTileFeature&,
+ const float,
+ const float,
+ const float) const { return false; };
+
+ virtual std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<const RenderLayer*>&) const = 0;
+
+ // Private implementation
+ const style::Layer::Impl& baseImpl;
+
+ friend std::string layoutKey(const RenderLayer&);
+protected:
+
+ // Stores what render passes this layer is currently enabled for. This depends on the
+ // evaluated StyleProperties object and is updated accordingly.
+ RenderPass passes = RenderPass::None;
+};
+
+} // namespace mbgl