#pragma once #include #include #include #include #include #include #include #include #include namespace mbgl { class StyleCascadeParameters; class StyleCalculationParameters; class StyleBucketParameters; class Bucket; class StyleLayer { public: virtual ~StyleLayer() = default; // Check whether this layer is of the given subtype. template bool is() const; // Dynamically cast this layer to the given subtype. template T* as() { return is() ? reinterpret_cast(this) : nullptr; } template const T* as() const { return is() ? reinterpret_cast(this) : nullptr; } // Create a copy of this layer. virtual std::unique_ptr clone() const = 0; virtual void parseLayout(const JSValue& value) = 0; virtual void parsePaints(const JSValue& value) = 0; // If the layer has a ref, the ref. Otherwise, the id. const std::string& bucketName() const; // Partially evaluate paint properties based on a set of classes. virtual void cascade(const StyleCascadeParameters&) = 0; // Fully evaluate cascaded paint properties based on a zoom level. // Returns true if any paint properties have active transitions. virtual bool recalculate(const StyleCalculationParameters&) = 0; virtual std::unique_ptr createBucket(StyleBucketParameters&) const = 0; // 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() const; virtual float getQueryRadius() const { return 0; } virtual bool queryIntersectsGeometry( const GeometryCollection&, const GeometryCollection&, const float, const float) const { return false; }; public: std::string id; std::string ref; std::string source; std::string sourceLayer; Filter filter; float minZoom = -std::numeric_limits::infinity(); float maxZoom = std::numeric_limits::infinity(); VisibilityType visibility = VisibilityType::Visible; protected: enum class Type { Fill, Line, Circle, Symbol, Raster, Background, Custom, }; StyleLayer(Type type_) : type(type_) {} StyleLayer(const StyleLayer&) = default; StyleLayer& operator=(const StyleLayer&) = delete; const Type type; // 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