summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-07-16 15:41:13 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-07-22 10:41:03 +0300
commitff42997b01ee8034338b3ff1591f35d1e6d782c1 (patch)
treec06ca14e7c25ccbcd4744f7a28da24d806c53e66 /src
parentbbe7679bc66ac6848d3b38931a3065de1b7a30ae (diff)
downloadqtlocation-mapboxgl-ff42997b01ee8034338b3ff1591f35d1e6d782c1.tar.gz
[core] Avoid unneeded tile sets copying at sources code
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/renderer/sources/render_raster_dem_source.cpp10
-rw-r--r--src/mbgl/renderer/sources/render_raster_source.cpp10
-rw-r--r--src/mbgl/renderer/sources/render_vector_source.cpp10
-rw-r--r--src/mbgl/style/sources/raster_source.cpp2
-rw-r--r--src/mbgl/style/sources/raster_source_impl.cpp8
-rw-r--r--src/mbgl/style/sources/raster_source_impl.hpp4
-rw-r--r--src/mbgl/style/sources/vector_source.cpp2
-rw-r--r--src/mbgl/style/sources/vector_source_impl.cpp4
-rw-r--r--src/mbgl/style/sources/vector_source_impl.hpp5
9 files changed, 22 insertions, 33 deletions
diff --git a/src/mbgl/renderer/sources/render_raster_dem_source.cpp b/src/mbgl/renderer/sources/render_raster_dem_source.cpp
index 06ddf3e7e0..b86b0bba7b 100644
--- a/src/mbgl/renderer/sources/render_raster_dem_source.cpp
+++ b/src/mbgl/renderer/sources/render_raster_dem_source.cpp
@@ -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;
}
diff --git a/src/mbgl/renderer/sources/render_raster_source.cpp b/src/mbgl/renderer/sources/render_raster_source.cpp
index 7c7a987c85..310a4cbc57 100644
--- a/src/mbgl/renderer/sources/render_raster_source.cpp
+++ b/src/mbgl/renderer/sources/render_raster_source.cpp
@@ -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;
}
diff --git a/src/mbgl/renderer/sources/render_vector_source.cpp b/src/mbgl/renderer/sources/render_vector_source.cpp
index 3990cb86fa..7035be9cf2 100644
--- a/src/mbgl/renderer/sources/render_vector_source.cpp
+++ b/src/mbgl/renderer/sources/render_vector_source.cpp
@@ -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;
}
diff --git a/src/mbgl/style/sources/raster_source.cpp b/src/mbgl/style/sources/raster_source.cpp
index 2d08e4be80..b4fbe22ae1 100644
--- a/src/mbgl/style/sources/raster_source.cpp
+++ b/src/mbgl/style/sources/raster_source.cpp
@@ -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;
diff --git a/src/mbgl/style/sources/raster_source_impl.cpp b/src/mbgl/style/sources/raster_source_impl.cpp
index 4db25aafd1..4201fd0578 100644
--- a/src/mbgl/style/sources/raster_source_impl.cpp
+++ b/src/mbgl/style/sources/raster_source_impl.cpp
@@ -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 {};
diff --git a/src/mbgl/style/sources/raster_source_impl.hpp b/src/mbgl/style/sources/raster_source_impl.hpp
index 96f59a2159..bb58455140 100644
--- a/src/mbgl/style/sources/raster_source_impl.hpp
+++ b/src/mbgl/style/sources/raster_source_impl.hpp
@@ -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
diff --git a/src/mbgl/style/sources/vector_source.cpp b/src/mbgl/style/sources/vector_source.cpp
index d141d291e1..8fa694e4d0 100644
--- a/src/mbgl/style/sources/vector_source.cpp
+++ b/src/mbgl/style/sources/vector_source.cpp
@@ -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;
diff --git a/src/mbgl/style/sources/vector_source_impl.cpp b/src/mbgl/style/sources/vector_source_impl.cpp
index b06f0557bf..8f85a41ddb 100644
--- a/src/mbgl/style/sources/vector_source_impl.cpp
+++ b/src/mbgl/style/sources/vector_source_impl.cpp
@@ -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 {};
diff --git a/src/mbgl/style/sources/vector_source_impl.hpp b/src/mbgl/style/sources/vector_source_impl.hpp
index 5e559b9266..4526fbe356 100644
--- a/src/mbgl/style/sources/vector_source_impl.hpp
+++ b/src/mbgl/style/sources/vector_source_impl.hpp
@@ -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