Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] Avoid unneeded tile sets copying at sources code
Browse files Browse the repository at this point in the history
  • Loading branch information
pozdnyakov committed Jul 16, 2019
1 parent 239542c commit 9ce71c2
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 33 deletions.
10 changes: 5 additions & 5 deletions src/mbgl/renderer/sources/render_raster_dem_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
10 changes: 5 additions & 5 deletions src/mbgl/renderer/sources/render_raster_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
10 changes: 5 additions & 5 deletions src/mbgl/renderer/sources/render_vector_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/style/sources/raster_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions src/mbgl/style/sources/raster_source_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/style/sources/raster_source_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ class RasterSource::Impl : public Source::Impl {
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
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/style/sources/vector_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions src/mbgl/style/sources/vector_source_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
Expand Down
5 changes: 1 addition & 4 deletions src/mbgl/style/sources/vector_source_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@ class VectorSource::Impl : public Source::Impl {
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
Expand Down

0 comments on commit 9ce71c2

Please sign in to comment.