diff options
author | Molly Lloyd <molly@mapbox.com> | 2018-12-11 16:38:49 -0800 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-03-05 14:04:52 +0200 |
commit | c33516911f96556cf7c1fb49a3b49b309108f22d (patch) | |
tree | 79ff5b0bd9e43e1909dd6c50fc5e82af97a5da6b /src | |
parent | 05026b704adcbe97c923989b3e2e46feb4fdc7ee (diff) | |
download | qtlocation-mapboxgl-c33516911f96556cf7c1fb49a3b49b309108f22d.tar.gz |
remove unused dem memory
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/geometry/dem_data.cpp | 26 | ||||
-rw-r--r-- | src/mbgl/geometry/dem_data.hpp | 11 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_hillshade_layer.cpp | 6 |
3 files changed, 18 insertions, 25 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); } }; diff --git a/src/mbgl/renderer/layers/render_hillshade_layer.cpp b/src/mbgl/renderer/layers/render_hillshade_layer.cpp index 2ee824dcf3..9cdba21c2d 100644 --- a/src/mbgl/renderer/layers/render_hillshade_layer.cpp +++ b/src/mbgl/renderer/layers/render_hillshade_layer.cpp @@ -125,8 +125,8 @@ void RenderHillshadeLayer::render(PaintParameters& parameters, RenderSource* src } if (!bucket.isPrepared() && parameters.pass == RenderPass::Pass3D) { - const uint16_t tilesize = bucket.getDEMData().dim; - OffscreenTexture view(parameters.context, { tilesize, tilesize }); + const uint16_t stride = bucket.getDEMData().stride; + OffscreenTexture view(parameters.context, { stride, stride }); view.bind(); parameters.context.bindTexture(*bucket.dem, 0, gl::TextureFilter::Nearest, gl::TextureMipMap::No, gl::TextureWrap::Clamp, gl::TextureWrap::Clamp); @@ -138,7 +138,7 @@ void RenderHillshadeLayer::render(PaintParameters& parameters, RenderSource* src const auto allUniformValues = programInstance.computeAllUniformValues( HillshadePrepareProgram::UniformValues { uniforms::u_matrix::Value( mat ), - uniforms::u_dimension::Value( {{uint16_t(tilesize * 2), uint16_t(tilesize * 2)}} ), + uniforms::u_dimension::Value( {{stride, stride}} ), uniforms::u_zoom::Value( float(tile.id.canonical.z) ), uniforms::u_maxzoom::Value( float(maxzoom) ), uniforms::u_image::Value( 0 ) |