#pragma once #include #include #include #include #include #include #include #include #include #include #include #include namespace mbgl { class Painter; class FileSource; class TransformState; class RenderTile; struct ClipID; namespace algorithm { class ClipIDGenerator; } // namespace algorithm namespace style { class Style; class UpdateParameters; class QueryParameters; class SourceObserver; class Source : public TileObserver, private util::noncopyable { public: Source(SourceType, std::string id); ~Source() override; bool loaded = false; virtual void load(FileSource&) = 0; bool isLoaded() const; // Request or parse all the tiles relevant for the "TransformState". This method // will return true if all the tiles were scheduled for updating of false if // they were not. shouldReparsePartialTiles must be set to "true" if there is // new data available that a tile in the "partial" state might be interested at. bool update(const UpdateParameters&); void startRender(algorithm::ClipIDGenerator&, const mat4& projMatrix, const TransformState&); void finishRender(Painter&); const std::map& getRenderTiles() const; Tile* getTile(const OverscaledTileID&) const; std::unordered_map> queryRenderedFeatures(const QueryParameters&) const; void setCacheSize(size_t); void onLowMemory(); void setObserver(SourceObserver* observer); void dumpDebugLogs() const; const SourceType type; const std::string id; bool enabled = false; private: // TileObserver implementation. void onTileLoaded(Tile&, bool isNewTile) override; void onTileError(Tile&, std::exception_ptr) override; void onNeedsRepaint() override; virtual uint16_t getTileSize() const = 0; virtual Range getZoomRange() = 0; virtual std::unique_ptr createTile(const OverscaledTileID&, const UpdateParameters&) = 0; protected: void invalidateTiles(); SourceObserver* observer = nullptr; private: // Stores the time when this source was most recently updated. TimePoint updated = TimePoint::min(); std::map> tiles; std::map renderTiles; TileCache cache; }; } // namespace style } // namespace mbgl