#pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace mbgl { class CollisionIndex; class ImageManager; class ImageSourceRenderData; class PaintParameters; class RenderedQueryOptions; class RenderItem; class RenderLayer; class RenderSourceObserver; class RenderTile; class Scheduler; class SourceQueryOptions; class Tile; class TileParameters; class TransformParameters; class TransformState; class UpdateParameters; namespace gfx { class UploadPass; } // namespace gfx class SourcePrepareParameters { public: const TransformParameters& transform; const MapDebugOptions& debugOptions; const ImageManager& imageManager; const std::string sourceName; }; using RenderTiles = std::shared_ptr>>; struct RenderSourceReadinessStats { bool tileBacked = false; std::optional tileCount; std::optional incompleteTileCount; std::optional loadedTileCount; bool hasFadingTiles = false; }; class RenderSource : protected TileObserver { public: static std::unique_ptr create(const Immutable&, const TaggedScheduler&); ~RenderSource() override; bool isEnabled() const; virtual bool isLoaded() const = 0; virtual void update(Immutable, const std::vector>&, bool needsRendering, bool needsRelayout, const TileParameters&) = 0; // Note: calling of this method might reset the contained render data. virtual std::unique_ptr createRenderItem() = 0; // Creates the render data to be passed to the render item. virtual void prepare(const SourcePrepareParameters&) = 0; virtual void updateFadingTiles() = 0; virtual bool hasFadingTiles() const = 0; // Read on the renderer thread while the source and its tile pyramid are owned by RenderOrchestrator. // This is an observational summary and must not define or modify isLoaded(). virtual RenderSourceReadinessStats getReadinessDiagnostics() const { return { .tileBacked = false, .tileCount = std::nullopt, .incompleteTileCount = std::nullopt, .loadedTileCount = std::nullopt, .hasFadingTiles = hasFadingTiles(), }; } // If supported, returns a shared list of RenderTiles, sorted by tile id and // excluding tiles hold for fade; returns nullptr otherwise. virtual RenderTiles getRenderTiles() const { return nullptr; } // If supported, returns a shared list of RenderTiles, sorted in opposite y // position, so tiles with overlapping symbols are drawn on top of each other, // with lower symbols being drawn on top of higher symbols; returns nullptr otherwise. virtual RenderTiles getRenderTilesSortedByYPosition() const { return nullptr; } // If supported, returns pointer to image data; returns nullptr otherwise. virtual const ImageSourceRenderData* getImageRenderData() const { return nullptr; } virtual const Tile* getRenderedTile(const UnwrappedTileID&) const { return nullptr; } virtual Immutable> getRawRenderTiles() const; virtual std::unordered_map> queryRenderedFeatures( const ScreenLineString& geometry, const TransformState& transformState, const std::unordered_map& layers, const RenderedQueryOptions& options, const mat4& projMatrix) const = 0; virtual std::vector querySourceFeatures(const SourceQueryOptions&) const = 0; virtual FeatureExtensionValue queryFeatureExtensions(const Feature&, const std::string&, const std::string&, const std::optional>&) const { return {}; } virtual void setFeatureState(const std::optional&, const std::string&, const FeatureState&) {} virtual void getFeatureState(FeatureState&, const std::optional&, const std::string&) const {} virtual void removeFeatureState(const std::optional&, const std::optional&, const std::optional&) {} virtual void setCacheEnabled(bool) {} virtual void setFastPFOREnabled(bool) {} virtual void reduceMemoryUse() = 0; virtual void dumpDebugLogs() const = 0; virtual uint8_t getMaxZoom() const; void setObserver(RenderSourceObserver*); Immutable baseImpl; protected: RenderSource(Immutable); RenderSourceObserver* observer; bool enabled = false; void onTileChanged(Tile&) override; void onTileError(Tile&, std::exception_ptr) final; void onTileAction(OverscaledTileID, std::string, TileOperation) override; }; } // namespace mbgl