diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-20 17:11:50 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-02 08:45:09 -0700 |
commit | 3f0c89d633a5056006557ad5f4b9e446807d00ee (patch) | |
tree | 5405c50dd26a5a393a982e8e0f76b764dbbccf48 /src/mbgl/renderer/render_source.hpp | |
parent | 197751bace6181f2c2dbe4c890f277a0dc7e58b1 (diff) | |
download | qtlocation-mapboxgl-3f0c89d633a5056006557ad5f4b9e446807d00ee.tar.gz |
[core] Refactor Source::*Impls into RenderSources and TilePyramid
Diffstat (limited to 'src/mbgl/renderer/render_source.hpp')
-rw-r--r-- | src/mbgl/renderer/render_source.hpp | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/src/mbgl/renderer/render_source.hpp b/src/mbgl/renderer/render_source.hpp new file mode 100644 index 0000000000..5d93ae49d6 --- /dev/null +++ b/src/mbgl/renderer/render_source.hpp @@ -0,0 +1,87 @@ +#pragma once + +#include <mbgl/tile/tile_id.hpp> +#include <mbgl/tile/tile_observer.hpp> +#include <mbgl/util/mat4.hpp> +#include <mbgl/util/geo.hpp> +#include <mbgl/util/feature.hpp> +#include <mbgl/style/source_impl.hpp> + +#include <unordered_map> +#include <vector> +#include <map> +#include <memory> + +namespace mbgl { + +class Painter; +class TransformState; +class RenderTile; +class RenderedQueryOptions; +class SourceQueryOptions; +class Tile; +class RenderSourceObserver; + +namespace algorithm { +class ClipIDGenerator; +} // namespace algorithm + +namespace style { +class UpdateParameters; +} // namespace style + +class RenderSource : protected TileObserver { +public: + RenderSource(const style::Source::Impl&); + virtual ~RenderSource() = default; + + virtual bool isLoaded() const = 0; + + // Called when the camera has changed. May load new tiles, unload obsolete tiles, or + // trigger re-placement of existing complete tiles. + virtual void updateTiles(const style::UpdateParameters&) = 0; + + // Removes all tiles (by putting them into the cache). + virtual void removeTiles() = 0; + + // Remove all tiles and clear the cache. + virtual void invalidateTiles() = 0; + + // Request that all loaded tiles re-run the layout operation on the existing source + // data with fresh style information. + virtual void reloadTiles() = 0; + + virtual void startRender(algorithm::ClipIDGenerator&, + const mat4& projMatrix, + const mat4& clipMatrix, + const TransformState&) = 0; + virtual void finishRender(Painter&) = 0; + + virtual std::map<UnwrappedTileID, RenderTile>& getRenderTiles() = 0; + + virtual std::unordered_map<std::string, std::vector<Feature>> + queryRenderedFeatures(const ScreenLineString& geometry, + const TransformState& transformState, + const RenderedQueryOptions& options) const = 0; + + virtual std::vector<Feature> + querySourceFeatures(const SourceQueryOptions&) const = 0; + + virtual void setCacheSize(size_t) = 0; + virtual void onLowMemory() = 0; + + virtual void dumpDebugLogs() const = 0; + + void setObserver(RenderSourceObserver*); + + const style::Source::Impl& baseImpl; + bool enabled = false; + +protected: + RenderSourceObserver* observer; + + void onTileChanged(Tile&) final; + void onTileError(Tile&, std::exception_ptr) final; +}; + +} // namespace mbgl |