This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Refactor Source::*Impls into RenderSources and TilePyramid
- Loading branch information
1 parent
197751b
commit 3f0c89d
Showing
44 changed files
with
1,401 additions
and
710 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#include <mbgl/annotation/render_annotation_source.hpp> | ||
#include <mbgl/annotation/annotation_tile.hpp> | ||
#include <mbgl/renderer/render_tile.hpp> | ||
|
||
#include <mbgl/algorithm/generate_clip_ids.hpp> | ||
#include <mbgl/algorithm/generate_clip_ids_impl.hpp> | ||
|
||
namespace mbgl { | ||
|
||
using namespace style; | ||
|
||
RenderAnnotationSource::RenderAnnotationSource(const AnnotationSource::Impl& impl_) | ||
: RenderSource(impl_) { | ||
tilePyramid.setObserver(this); | ||
} | ||
|
||
bool RenderAnnotationSource::isLoaded() const { | ||
return tilePyramid.isLoaded(); | ||
} | ||
|
||
void RenderAnnotationSource::invalidateTiles() { | ||
tilePyramid.invalidateTiles(); | ||
} | ||
|
||
void RenderAnnotationSource::startRender(algorithm::ClipIDGenerator& generator, const mat4& projMatrix, const mat4& clipMatrix, const TransformState& transform) { | ||
generator.update(tilePyramid.getRenderTiles()); | ||
tilePyramid.startRender(projMatrix, clipMatrix, transform); | ||
} | ||
|
||
void RenderAnnotationSource::finishRender(Painter& painter) { | ||
tilePyramid.finishRender(painter); | ||
} | ||
|
||
std::map<UnwrappedTileID, RenderTile>& RenderAnnotationSource::getRenderTiles() { | ||
return tilePyramid.getRenderTiles(); | ||
} | ||
|
||
void RenderAnnotationSource::updateTiles(const UpdateParameters& parameters) { | ||
tilePyramid.updateTiles(parameters, | ||
SourceType::Annotations, | ||
util::tileSize, | ||
{ 0, 22 }, | ||
[&] (const OverscaledTileID& tileID) { | ||
return std::make_unique<AnnotationTile>(tileID, parameters); | ||
}); | ||
} | ||
|
||
void RenderAnnotationSource::removeTiles() { | ||
tilePyramid.removeTiles(); | ||
} | ||
|
||
void RenderAnnotationSource::reloadTiles() { | ||
tilePyramid.reloadTiles(); | ||
} | ||
|
||
std::unordered_map<std::string, std::vector<Feature>> | ||
RenderAnnotationSource::queryRenderedFeatures(const ScreenLineString& geometry, | ||
const TransformState& transformState, | ||
const RenderedQueryOptions& options) const { | ||
return tilePyramid.queryRenderedFeatures(geometry, transformState, options); | ||
} | ||
|
||
std::vector<Feature> RenderAnnotationSource::querySourceFeatures(const SourceQueryOptions&) const { | ||
return {}; | ||
} | ||
|
||
void RenderAnnotationSource::setCacheSize(size_t size) { | ||
tilePyramid.setCacheSize(size); | ||
} | ||
|
||
void RenderAnnotationSource::onLowMemory() { | ||
tilePyramid.onLowMemory(); | ||
} | ||
|
||
void RenderAnnotationSource::dumpDebugLogs() const { | ||
tilePyramid.dumpDebugLogs(); | ||
} | ||
|
||
} // namespace mbgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#pragma once | ||
|
||
#include <mbgl/renderer/render_source.hpp> | ||
#include <mbgl/renderer/tile_pyramid.hpp> | ||
#include <mbgl/annotation/annotation_source.hpp> | ||
|
||
namespace mbgl { | ||
|
||
class RenderAnnotationSource : public RenderSource { | ||
public: | ||
RenderAnnotationSource(const AnnotationSource::Impl&); | ||
|
||
bool isLoaded() const final; | ||
|
||
// Called when the camera has changed. May load new tiles, unload obsolete tiles, or | ||
// trigger re-placement of existing complete tiles. | ||
void updateTiles(const style::UpdateParameters&) final; | ||
|
||
// Removes all tiles (by putting them into the cache). | ||
void removeTiles() final; | ||
|
||
// Remove all tiles and clear the cache. | ||
void invalidateTiles() final; | ||
|
||
// Request that all loaded tiles re-run the layout operation on the existing source | ||
// data with fresh style information. | ||
void reloadTiles() final; | ||
|
||
void startRender(algorithm::ClipIDGenerator&, | ||
const mat4& projMatrix, | ||
const mat4& clipMatrix, | ||
const TransformState&) final; | ||
void finishRender(Painter&) final; | ||
|
||
std::map<UnwrappedTileID, RenderTile>& getRenderTiles() final; | ||
|
||
std::unordered_map<std::string, std::vector<Feature>> | ||
queryRenderedFeatures(const ScreenLineString& geometry, | ||
const TransformState& transformState, | ||
const RenderedQueryOptions& options) const final; | ||
|
||
std::vector<Feature> | ||
querySourceFeatures(const SourceQueryOptions&) const final; | ||
|
||
void setCacheSize(size_t) final; | ||
void onLowMemory() final; | ||
void dumpDebugLogs() const final; | ||
|
||
private: | ||
TilePyramid tilePyramid; | ||
}; | ||
|
||
} // namespace mbgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <mbgl/renderer/render_source.hpp> | ||
#include <mbgl/renderer/render_source_observer.hpp> | ||
#include <mbgl/tile/tile.hpp> | ||
|
||
namespace mbgl { | ||
|
||
static RenderSourceObserver nullObserver; | ||
|
||
RenderSource::RenderSource(const style::Source::Impl& impl) | ||
: baseImpl(impl), | ||
observer(&nullObserver) { | ||
} | ||
|
||
void RenderSource::setObserver(RenderSourceObserver* observer_) { | ||
observer = observer_; | ||
} | ||
|
||
void RenderSource::onTileChanged(Tile& tile) { | ||
observer->onTileChanged(*this, tile.id); | ||
} | ||
|
||
void RenderSource::onTileError(Tile& tile, std::exception_ptr error) { | ||
observer->onTileError(*this, tile.id, error); | ||
} | ||
|
||
} |
Oops, something went wrong.