#ifndef MBGL_STYLE_STYLE_LAYER #define MBGL_STYLE_STYLE_LAYER #include #include #include #include #include #include #include #include #include #include #include #include #include namespace mbgl { class StyleBucket; class StyleLayer : public util::noncopyable { public: StyleLayer(const std::string &id, std::map &&styles); template const T &getProperties() const { if (properties.is()) { return properties.get(); } else { return defaultStyleProperties(); } } // Determines whether this layer is the background layer. bool isBackground() const; public: // Checks whether this layer needs to be rendered in the given render pass. bool hasRenderPass(RenderPass) const; // Updates the StyleProperties information in this layer by evaluating all // pending transitions and applied classes in order. void updateProperties(float z, const TimePoint& now, ZoomHistory &zoomHistory); // Sets the list of classes and creates transitions to the currently applied values. void setClasses(const std::vector &class_names, const TimePoint& now, const PropertyTransition &defaultTransition); bool hasTransitions() const; private: // Applies all properties from a class, if they haven't been applied already. void applyClassProperties(ClassID class_id, std::set &already_applied, const TimePoint& now, const PropertyTransition &defaultTransition); // Sets the properties of this object by evaluating all pending transitions and // aplied classes in order. template void applyStyleProperties(float z, const TimePoint& now, const ZoomHistory &zoomHistory); template void applyStyleProperty(PropertyKey key, T &, float z, const TimePoint& now, const ZoomHistory &zoomHistory); template void applyTransitionedStyleProperty(PropertyKey key, T &, float z, const TimePoint& now, const ZoomHistory &zoomHistory); // Removes all expired style transitions. void cleanupAppliedStyleProperties(const TimePoint& now); // Checks whether the layer is currently visible at all. bool isVisible() const; public: // The name of this layer. const std::string id; StyleLayerType type = StyleLayerType::Unknown; // Bucket information, telling the renderer how to generate the geometries // for this layer (feature property filters, tessellation instructions, ...). util::ptr bucket; // Contains all style classes that can be applied to this layer. const std::map styles; private: // For every property, stores a list of applied property values, with // optional transition times. std::map appliedStyle; // 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; public: // Stores the evaluated, and cascaded styling information, specific to this // layer's type. StyleProperties properties; }; } #endif