summaryrefslogtreecommitdiff
path: root/src/mbgl/geometry
diff options
context:
space:
mode:
authorMolly Lloyd <molly@mapbox.com>2018-12-11 16:38:49 -0800
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-03-05 14:04:52 +0200
commitc33516911f96556cf7c1fb49a3b49b309108f22d (patch)
tree79ff5b0bd9e43e1909dd6c50fc5e82af97a5da6b /src/mbgl/geometry
parent05026b704adcbe97c923989b3e2e46feb4fdc7ee (diff)
downloadqtlocation-mapboxgl-c33516911f96556cf7c1fb49a3b49b309108f22d.tar.gz
remove unused dem memory
Diffstat (limited to 'src/mbgl/geometry')
-rw-r--r--src/mbgl/geometry/dem_data.cpp26
-rw-r--r--src/mbgl/geometry/dem_data.hpp11
2 files changed, 15 insertions, 22 deletions
diff --git a/src/mbgl/geometry/dem_data.cpp b/src/mbgl/geometry/dem_data.cpp
index 7fa98950ea..92dd7aee26 100644
--- a/src/mbgl/geometry/dem_data.cpp
+++ b/src/mbgl/geometry/dem_data.cpp
@@ -5,8 +5,8 @@ namespace mbgl {
DEMData::DEMData(const PremultipliedImage& _image, Tileset::DEMEncoding encoding):
dim(_image.size.height),
- border(std::max<int32_t>(std::ceil(_image.size.height / 2), 1)),
- stride(dim + 2 * border),
+ // extra two pixels per row for border backfilling on either edge
+ stride(dim + 2),
image({ static_cast<uint32_t>(stride), static_cast<uint32_t>(stride) }) {
if (_image.size.height != _image.size.width){
@@ -76,22 +76,16 @@ void DEMData::backfillBorder(const DEMData& borderTileData, int8_t dx, int8_t dy
// represents. For example, dx = -1, dy = -1 represents the upper left corner of the
// base tile, so we only need to backfill one pixel at coordinates (-1, -1) of the tile
// image.
- int32_t _xMin = dx * dim;
- int32_t _xMax = dx * dim + dim;
- int32_t _yMin = dy * dim;
- int32_t _yMax = dy * dim + dim;
+ int32_t xMin = dx * dim;
+ int32_t xMax = dx * dim + dim;
+ int32_t yMin = dy * dim;
+ int32_t yMax = dy * dim + dim;
- if (dx == -1) _xMin = _xMax - 1;
- else if (dx == 1) _xMax = _xMin + 1;
+ if (dx == -1) xMin = xMax - 1;
+ else if (dx == 1) xMax = xMin + 1;
- if (dy == -1) _yMin = _yMax - 1;
- else if (dy == 1) _yMax = _yMin + 1;
-
- int32_t xMin = util::clamp(_xMin, -border, dim + border);
- int32_t xMax = util::clamp(_xMax, -border, dim + border);
-
- int32_t yMin = util::clamp(_yMin, -border, dim + border);
- int32_t yMax = util::clamp(_yMax, -border, dim + border);
+ if (dy == -1) yMin = yMax - 1;
+ else if (dy == 1) yMax = yMin + 1;
int32_t ox = -dx * dim;
int32_t oy = -dy * dim;
diff --git a/src/mbgl/geometry/dem_data.hpp b/src/mbgl/geometry/dem_data.hpp
index 817d3cc9c9..21146bc468 100644
--- a/src/mbgl/geometry/dem_data.hpp
+++ b/src/mbgl/geometry/dem_data.hpp
@@ -29,7 +29,6 @@ public:
}
const int32_t dim;
- const int32_t border;
const int32_t stride;
@@ -37,11 +36,11 @@ public:
PremultipliedImage image;
size_t idx(const int32_t x, const int32_t y) const {
- assert(x >= -border);
- assert(x < dim + border);
- assert(y >= -border);
- assert(y < dim + border);
- return (y + border) * stride + (x + border);
+ assert(x >= -1);
+ assert(x < dim + 1);
+ assert(y >= -1);
+ assert(y < dim + 1);
+ return (y + 1) * stride + (x + 1);
}
};