[core] Avoid unneeded tile sets copying at sources code
This commit is contained in:
@@ -27,21 +27,21 @@ void RenderRasterDEMSource::update(Immutable<style::Source::Impl> baseImpl_,
|
||||
|
||||
enabled = needsRendering;
|
||||
|
||||
optional<Tileset> _tileset = impl().getTileset();
|
||||
const optional<Tileset>& implTileset = impl().tileset;
|
||||
// In Continuous mode, keep the existing tiles if the new tileset is not
|
||||
// yet available, thus providing smart style transitions without flickering.
|
||||
// In other modes, allow clearing the tile pyramid first, before the early
|
||||
// return in order to avoid render tests being flaky.
|
||||
bool canUpdateTileset = _tileset || parameters.mode != MapMode::Continuous;
|
||||
if (canUpdateTileset && tileset != _tileset) {
|
||||
tileset = _tileset;
|
||||
bool canUpdateTileset = implTileset || parameters.mode != MapMode::Continuous;
|
||||
if (canUpdateTileset && tileset != implTileset) {
|
||||
tileset = implTileset;
|
||||
maxzoom = tileset->zoomRange.max;
|
||||
// TODO: this removes existing buckets, and will cause flickering.
|
||||
// Should instead refresh tile data in place.
|
||||
tilePyramid.clearAll();
|
||||
}
|
||||
|
||||
if (!_tileset) {
|
||||
if (!implTileset) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,21 +25,21 @@ void RenderRasterSource::update(Immutable<style::Source::Impl> baseImpl_,
|
||||
|
||||
enabled = needsRendering;
|
||||
|
||||
optional<Tileset> _tileset = impl().getTileset();
|
||||
const optional<Tileset>& implTileset = impl().tileset;
|
||||
// In Continuous mode, keep the existing tiles if the new tileset is not
|
||||
// yet available, thus providing smart style transitions without flickering.
|
||||
// In other modes, allow clearing the tile pyramid first, before the early
|
||||
// return in order to avoid render tests being flaky.
|
||||
bool canUpdateTileset = _tileset || parameters.mode != MapMode::Continuous;
|
||||
if (canUpdateTileset && tileset != _tileset) {
|
||||
tileset = _tileset;
|
||||
bool canUpdateTileset = implTileset || parameters.mode != MapMode::Continuous;
|
||||
if (canUpdateTileset && tileset != implTileset) {
|
||||
tileset = implTileset;
|
||||
|
||||
// TODO: this removes existing buckets, and will cause flickering.
|
||||
// Should instead refresh tile data in place.
|
||||
tilePyramid.clearAll();
|
||||
}
|
||||
|
||||
if (!_tileset) {
|
||||
if (!implTileset) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,21 +25,21 @@ void RenderVectorSource::update(Immutable<style::Source::Impl> baseImpl_,
|
||||
|
||||
enabled = needsRendering;
|
||||
|
||||
optional<Tileset> _tileset = impl().getTileset();
|
||||
const optional<Tileset>& implTileset = impl().tileset;
|
||||
// In Continuous mode, keep the existing tiles if the new tileset is not
|
||||
// yet available, thus providing smart style transitions without flickering.
|
||||
// In other modes, allow clearing the tile pyramid first, before the early
|
||||
// return in order to avoid render tests being flaky.
|
||||
bool canUpdateTileset = _tileset || parameters.mode != MapMode::Continuous;
|
||||
if (canUpdateTileset && tileset != _tileset) {
|
||||
tileset = _tileset;
|
||||
bool canUpdateTileset = implTileset || parameters.mode != MapMode::Continuous;
|
||||
if (canUpdateTileset && tileset != implTileset) {
|
||||
tileset = implTileset;
|
||||
|
||||
// TODO: this removes existing buckets, and will cause flickering.
|
||||
// Should instead refresh tile data in place.
|
||||
tilePyramid.clearAll();
|
||||
}
|
||||
|
||||
if (!_tileset) {
|
||||
if (!implTileset) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ void RasterSource::loadDescription(FileSource& fileSource) {
|
||||
}
|
||||
|
||||
util::mapbox::canonicalizeTileset(*tileset, url, getType(), getTileSize());
|
||||
bool changed = impl().getTileset() != *tileset;
|
||||
bool changed = impl().tileset != *tileset;
|
||||
|
||||
baseImpl = makeMutable<Impl>(impl(), *tileset);
|
||||
loaded = true;
|
||||
|
||||
@@ -10,18 +10,14 @@ RasterSource::Impl::Impl(SourceType sourceType, std::string id_, uint16_t tileSi
|
||||
|
||||
RasterSource::Impl::Impl(const Impl& other, Tileset tileset_)
|
||||
: Source::Impl(other),
|
||||
tileSize(other.tileSize),
|
||||
tileset(std::move(tileset_)) {
|
||||
tileset(std::move(tileset_)),
|
||||
tileSize(other.tileSize) {
|
||||
}
|
||||
|
||||
uint16_t RasterSource::Impl::getTileSize() const {
|
||||
return tileSize;
|
||||
}
|
||||
|
||||
optional<Tileset> RasterSource::Impl::getTileset() const {
|
||||
return tileset;
|
||||
}
|
||||
|
||||
optional<std::string> RasterSource::Impl::getAttribution() const {
|
||||
if (!tileset) {
|
||||
return {};
|
||||
|
||||
@@ -11,14 +11,14 @@ public:
|
||||
Impl(SourceType sourceType, std::string id, uint16_t tileSize);
|
||||
Impl(const Impl&, Tileset);
|
||||
|
||||
optional<Tileset> getTileset() const;
|
||||
uint16_t getTileSize() const;
|
||||
|
||||
optional<std::string> getAttribution() const final;
|
||||
|
||||
const optional<Tileset> tileset;
|
||||
|
||||
private:
|
||||
uint16_t tileSize;
|
||||
optional<Tileset> tileset;
|
||||
};
|
||||
|
||||
} // namespace style
|
||||
|
||||
@@ -62,7 +62,7 @@ void VectorSource::loadDescription(FileSource& fileSource) {
|
||||
}
|
||||
|
||||
util::mapbox::canonicalizeTileset(*tileset, url, getType(), util::tileSize);
|
||||
bool changed = impl().getTileset() != *tileset;
|
||||
bool changed = impl().tileset != *tileset;
|
||||
|
||||
baseImpl = makeMutable<Impl>(impl(), *tileset);
|
||||
loaded = true;
|
||||
|
||||
@@ -12,10 +12,6 @@ VectorSource::Impl::Impl(const Impl& other, Tileset tileset_)
|
||||
tileset(std::move(tileset_)) {
|
||||
}
|
||||
|
||||
optional<Tileset> VectorSource::Impl::getTileset() const {
|
||||
return tileset;
|
||||
}
|
||||
|
||||
optional<std::string> VectorSource::Impl::getAttribution() const {
|
||||
if (!tileset) {
|
||||
return {};
|
||||
|
||||
@@ -11,12 +11,9 @@ public:
|
||||
Impl(std::string id);
|
||||
Impl(const Impl&, Tileset);
|
||||
|
||||
optional<Tileset> getTileset() const;
|
||||
|
||||
optional<std::string> getAttribution() const final;
|
||||
|
||||
private:
|
||||
optional<Tileset> tileset;
|
||||
const optional<Tileset> tileset;
|
||||
};
|
||||
|
||||
} // namespace style
|
||||
|
||||
Reference in New Issue
Block a user