summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2017-06-16 13:43:53 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2019-03-06 09:40:21 +0200
commitc2823efc82d96c9f8fa35eb0a6df4172dbccb8a5 (patch)
tree87262b3a112e6edd3330b121a053ca312b814895
parentb2f0608284c860dbf89ada16990073b30eb83d65 (diff)
downloadqtlocation-mapboxgl-c2823efc82d96c9f8fa35eb0a6df4172dbccb8a5.tar.gz
[core] tileCover zoom is uint8_t
-rw-r--r--src/mbgl/renderer/tile_pyramid.cpp15
-rw-r--r--src/mbgl/util/tile_cover.cpp16
-rw-r--r--src/mbgl/util/tile_cover.hpp12
3 files changed, 23 insertions, 20 deletions
diff --git a/src/mbgl/renderer/tile_pyramid.cpp b/src/mbgl/renderer/tile_pyramid.cpp
index b169fddf9c..f781551f31 100644
--- a/src/mbgl/renderer/tile_pyramid.cpp
+++ b/src/mbgl/renderer/tile_pyramid.cpp
@@ -93,15 +93,15 @@ void TilePyramid::update(const std::vector<Immutable<style::Layer::Impl>>& layer
handleWrapJump(parameters.transformState.getLatLng().longitude());
// Determine the overzooming/underzooming amounts and required tiles.
- int32_t overscaledZoom = util::coveringZoomLevel(parameters.transformState.getZoom(), type, tileSize);
- int32_t tileZoom = overscaledZoom;
- int32_t panZoom = zoomRange.max;
+ uint8_t overscaledZoom = util::coveringZoomLevel(parameters.transformState.getZoom(), type, tileSize);
+ uint8_t tileZoom = overscaledZoom;
+ uint8_t panZoom = zoomRange.max;
std::vector<UnwrappedTileID> idealTiles;
std::vector<UnwrappedTileID> panTiles;
if (overscaledZoom >= zoomRange.min) {
- int32_t idealZoom = std::min<int32_t>(zoomRange.max, overscaledZoom);
+ uint8_t idealZoom = std::min(zoomRange.max, overscaledZoom);
// Make sure we're not reparsing overzoomed raster tiles.
@@ -114,7 +114,10 @@ void TilePyramid::update(const std::vector<Immutable<style::Layer::Impl>>& layer
// Request lower zoom level tiles (if configured to do so) in an attempt
// to show something on the screen faster at the cost of a little of bandwidth.
if (parameters.prefetchZoomDelta) {
- panZoom = std::max<int32_t>(tileZoom - parameters.prefetchZoomDelta, zoomRange.min);
+ panZoom = util::clamp(
+ util::min(uint8_t(tileZoom - parameters.prefetchZoomDelta), tileZoom),
+ zoomRange.min,
+ util::min(uint8_t(zoomRange.max - parameters.prefetchZoomDelta), zoomRange.max));
}
if (panZoom < idealZoom) {
@@ -151,7 +154,7 @@ void TilePyramid::update(const std::vector<Immutable<style::Layer::Impl>>& layer
// tiles are used from the cache, but not created.
optional<util::TileRange> tileRange = {};
if (bounds) {
- tileRange = util::TileRange::fromLatLngBounds(*bounds, zoomRange.min, std::min(tileZoom, (int32_t)zoomRange.max));
+ tileRange = util::TileRange::fromLatLngBounds(*bounds, zoomRange.min, std::min(tileZoom, zoomRange.max));
}
auto createTileFn = [&](const OverscaledTileID& tileID) -> Tile* {
if (tileRange && !tileRange->contains(tileID.canonical)) {
diff --git a/src/mbgl/util/tile_cover.cpp b/src/mbgl/util/tile_cover.cpp
index 7979c550a9..4e6da338fb 100644
--- a/src/mbgl/util/tile_cover.cpp
+++ b/src/mbgl/util/tile_cover.cpp
@@ -84,7 +84,7 @@ std::vector<UnwrappedTileID> tileCover(const Point<double>& tl,
const Point<double>& br,
const Point<double>& bl,
const Point<double>& c,
- int32_t z) {
+ uint8_t z) {
const int32_t tiles = 1 << z;
struct ID {
@@ -130,7 +130,7 @@ std::vector<UnwrappedTileID> tileCover(const Point<double>& tl,
} // namespace
-int32_t coveringZoomLevel(double zoom, style::SourceType type, uint16_t size) {
+uint8_t coveringZoomLevel(double zoom, style::SourceType type, uint16_t size) {
zoom += util::log2(util::tileSize / size);
if (type == style::SourceType::Raster || type == style::SourceType::Video) {
return ::round(zoom);
@@ -139,7 +139,7 @@ int32_t coveringZoomLevel(double zoom, style::SourceType type, uint16_t size) {
}
}
-std::vector<UnwrappedTileID> tileCover(const LatLngBounds& bounds_, int32_t z) {
+std::vector<UnwrappedTileID> tileCover(const LatLngBounds& bounds_, uint8_t z) {
if (bounds_.isEmpty() ||
bounds_.south() > util::LATITUDE_MAX ||
bounds_.north() < -util::LATITUDE_MAX) {
@@ -159,7 +159,7 @@ std::vector<UnwrappedTileID> tileCover(const LatLngBounds& bounds_, int32_t z) {
z);
}
-std::vector<UnwrappedTileID> tileCover(const TransformState& state, int32_t z) {
+std::vector<UnwrappedTileID> tileCover(const TransformState& state, uint8_t z) {
assert(state.valid());
const double w = state.getSize().width;
@@ -173,7 +173,7 @@ std::vector<UnwrappedTileID> tileCover(const TransformState& state, int32_t z) {
z);
}
-std::vector<UnwrappedTileID> tileCover(const Geometry<double>& geometry, int32_t z) {
+std::vector<UnwrappedTileID> tileCover(const Geometry<double>& geometry, uint8_t z) {
std::vector<UnwrappedTileID> result;
TileCover tc(geometry, z, true);
while (tc.hasNext()) {
@@ -183,7 +183,7 @@ std::vector<UnwrappedTileID> tileCover(const Geometry<double>& geometry, int32_t
return result;
}
-// Taken from https://github.com/mapbox/sphericalmercator#xyzbbox-zoom-tms_style-srs
+// Taken from https://github.com/mapbox/sphericalmercator#xyzbbox-z-tms_style-srs
// Computes the projected tiles for the lower left and upper right points of the bounds
// and uses that to compute the tile cover count
uint64_t tileCount(const LatLngBounds& bounds, uint8_t zoom){
@@ -213,7 +213,7 @@ uint64_t tileCount(const Geometry<double>& geometry, uint8_t z) {
return tileCount;
}
-TileCover::TileCover(const LatLngBounds&bounds_, int32_t z) {
+TileCover::TileCover(const LatLngBounds&bounds_, uint8_t z) {
LatLngBounds bounds = LatLngBounds::hull(
{ std::max(bounds_.south(), -util::LATITUDE_MAX), bounds_.west() },
{ std::min(bounds_.north(), util::LATITUDE_MAX), bounds_.east() });
@@ -233,7 +233,7 @@ TileCover::TileCover(const LatLngBounds&bounds_, int32_t z) {
impl = std::make_unique<TileCover::Impl>(z, p, false);
}
-TileCover::TileCover(const Geometry<double>& geom, int32_t z, bool project/* = true*/)
+TileCover::TileCover(const Geometry<double>& geom, uint8_t z, bool project/* = true*/)
: impl( std::make_unique<TileCover::Impl>(z, geom, project)) {
}
diff --git a/src/mbgl/util/tile_cover.hpp b/src/mbgl/util/tile_cover.hpp
index c953d764d2..552f252960 100644
--- a/src/mbgl/util/tile_cover.hpp
+++ b/src/mbgl/util/tile_cover.hpp
@@ -18,9 +18,9 @@ namespace util {
// Helper class to stream tile-cover results per row
class TileCover {
public:
- TileCover(const LatLngBounds&, int32_t z);
+ TileCover(const LatLngBounds&, uint8_t z);
// When project == true, projects the geometry points to tile coordinates
- TileCover(const Geometry<double>&, int32_t z, bool project = true);
+ TileCover(const Geometry<double>&, uint8_t z, bool project = true);
~TileCover();
optional<UnwrappedTileID> next();
@@ -31,11 +31,11 @@ private:
std::unique_ptr<Impl> impl;
};
-int32_t coveringZoomLevel(double z, style::SourceType type, uint16_t tileSize);
+uint8_t coveringZoomLevel(double z, style::SourceType type, uint16_t tileSize);
-std::vector<UnwrappedTileID> tileCover(const TransformState&, int32_t z);
-std::vector<UnwrappedTileID> tileCover(const LatLngBounds&, int32_t z);
-std::vector<UnwrappedTileID> tileCover(const Geometry<double>&, int32_t z);
+std::vector<UnwrappedTileID> tileCover(const TransformState&, uint8_t z);
+std::vector<UnwrappedTileID> tileCover(const LatLngBounds&, uint8_t z);
+std::vector<UnwrappedTileID> tileCover(const Geometry<double>&, uint8_t z);
// Compute only the count of tiles needed for tileCover
uint64_t tileCount(const LatLngBounds&, uint8_t z);