#ifndef MBGL_MAP_MAP_CONTEXT #define MBGL_MAP_MAP_CONTEXT #include #include #include #include #include #include #include #include #include #include #include namespace mbgl { class View; class MapData; class Painter; class SpriteImage; class FileRequest; class PropertyTransition; namespace gl { class TexturePool; } struct FrameData { std::array framebufferSize; TimePoint timePoint; }; class MapContext : public Style::Observer { public: MapContext(View&, FileSource&, MapMode, GLContextMode, const float pixelRatio); ~MapContext(); MapData& getData() { return data; } void pause(); void triggerUpdate(const TransformState&, Update = Update::Nothing); void renderStill(const TransformState&, const FrameData&, Map::StillImageCallback callback); // Triggers a synchronous render. Returns true if style has been fully loaded. bool renderSync(const TransformState&, const FrameData&); void setStyleURL(const std::string&); void setStyleJSON(const std::string& json, const std::string& base); std::string getStyleURL() const { return styleURL; } std::string getStyleJSON() const { return styleJSON; } bool isLoaded() const; // Annotations void addAnnotationIcon(const std::string&, std::shared_ptr); void removeAnnotationIcon(const std::string&); double getTopOffsetPixelsForAnnotationIcon(const std::string&); void updateAnnotations(); // Style API void addLayer(std::unique_ptr, const optional before); void removeLayer(const std::string& id); void addClass(const std::string&, const PropertyTransition&); void removeClass(const std::string&, const PropertyTransition&); bool hasClass(const std::string&) const; void setClasses(const std::vector&, const PropertyTransition&); std::vector getClasses() const; void setSourceTileCacheSize(size_t size); void onLowMemory(); void cleanup(); void dumpDebugLogs() const; private: void onResourceLoaded() override; void onResourceError(std::exception_ptr) override; // Update the state indicated by the accumulated Update flags, then render. void update(); // Helper function for triggering asynchronous updates. void updateAsync(Update); // Loads the actual JSON object an creates a new Style object. void loadStyleJSON(const std::string& json, const std::string& base); View& view; FileSource& fileSource; std::unique_ptr dataPtr; MapData& data; gl::GLObjectStore glObjectStore; Update updateFlags = Update::Nothing; util::AsyncTask asyncUpdate; util::AsyncTask asyncInvalidate; std::unique_ptr texturePool; std::unique_ptr painter; std::unique_ptr