#pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace mbgl { class FileSource; class GlyphAtlas; class SpriteAtlas; class SpriteLoader; class LineAtlas; class RenderData; class TransformState; class RenderedQueryOptions; class Scheduler; class UpdateParameters; namespace style { class Layer; class QueryParameters; class Style : public GlyphAtlasObserver, public SpriteLoaderObserver, public SourceObserver, public RenderSourceObserver, public LayerObserver, public LightObserver, public util::noncopyable { public: Style(Scheduler&, FileSource&, float pixelRatio); ~Style() override; void setJSON(const std::string&); void setObserver(Observer*); bool isLoaded() const; void update(const UpdateParameters&); bool hasTransitions() const; std::exception_ptr getLastError() const { return lastError; } std::vector getSources() const; std::vector getSources(); Source* getSource(const std::string& id) const; void addSource(std::unique_ptr); std::unique_ptr removeSource(const std::string& sourceID); std::vector getLayers() const; std::vector getLayers(); Layer* getLayer(const std::string& id) const; Layer* addLayer(std::unique_ptr, optional beforeLayerID = {}); std::unique_ptr removeLayer(const std::string& layerID); // Should be moved to Impl eventually std::vector getRenderLayers() const; std::vector getRenderLayers(); RenderLayer* getRenderLayer(const std::string& id) const; std::string getName() const; LatLng getDefaultLatLng() const; double getDefaultZoom() const; double getDefaultBearing() const; double getDefaultPitch() const; TransitionOptions getTransitionOptions() const; void setTransitionOptions(const TransitionOptions&); void setLight(std::unique_ptr); Light* getLight() const; const RenderLight& getRenderLight() const; const style::Image* getImage(const std::string&) const; void addImage(std::unique_ptr); void removeImage(const std::string&); RenderData getRenderData(MapDebugOptions, float angle) const; std::vector queryRenderedFeatures(const ScreenLineString& geometry, const TransformState& transformState, const RenderedQueryOptions& options) const; void setSourceTileCacheSize(size_t); void onLowMemory(); void dumpDebugLogs() const; Scheduler& scheduler; FileSource& fileSource; std::unique_ptr glyphAtlas; std::unique_ptr spriteLoader; std::unique_ptr spriteAtlas; std::unique_ptr lineAtlas; RenderSource* getRenderSource(const std::string& id) const; private: std::vector> sources; std::vector> layers; TransitionOptions transitionOptions; std::unique_ptr light; // Defaults std::string name; LatLng defaultLatLng; double defaultZoom = 0; double defaultBearing = 0; double defaultPitch = 0; std::vector> sourceImpls; std::vector> layerImpls; std::unordered_map> renderSources; std::unordered_map> renderLayers; RenderLight renderLight; std::vector>::const_iterator findLayer(const std::string& layerID) const; // GlyphAtlasObserver implementation. void onGlyphsError(const FontStack&, const GlyphRange&, std::exception_ptr) override; // SpriteLoaderObserver implementation. std::unordered_map> spriteImages; void onSpriteLoaded(std::vector>&&) override; void onSpriteError(std::exception_ptr) override; // SourceObserver implementation. void onSourceLoaded(Source&) override; void onSourceChanged(Source&) override; void onSourceError(Source&, std::exception_ptr) override; void onSourceDescriptionChanged(Source&) override; void onTileChanged(RenderSource&, const OverscaledTileID&) override; void onTileError(RenderSource&, const OverscaledTileID&, std::exception_ptr) override; // LayerObserver implementation. void onLayerFilterChanged(Layer&) override; void onLayerVisibilityChanged(Layer&) override; void onLayerPaintPropertyChanged(Layer&) override; void onLayerDataDrivenPaintPropertyChanged(Layer&) override; void onLayerLayoutPropertyChanged(Layer&, const char *) override; // LightObserver implementation. void onLightChanged(const Light&) override; Observer nullObserver; Observer* observer = &nullObserver; std::exception_ptr lastError; UpdateBatch updateBatch; ZoomHistory zoomHistory; public: bool loaded = false; }; } // namespace style } // namespace mbgl