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

Commit

Permalink
remove hardcoded tilesizes and allow for @2x tile requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Molly Lloyd committed Jan 17, 2018
1 parent 1bcc9ab commit 0bc33c9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/mbgl/programs/hillshade_prepare_program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace mbgl {

namespace uniforms {
MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_dimension);
MBGL_DEFINE_UNIFORM_VECTOR(uint16_t, 2, u_dimension);
} // namespace uniforms

class HillshadePrepareProgram : public Program<
Expand Down
5 changes: 3 additions & 2 deletions src/mbgl/renderer/layers/render_hillshade_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ void RenderHillshadeLayer::render(PaintParameters& parameters, RenderSource*) {
if (!bucket.hasData())
continue;
if (!bucket.isPrepared() && parameters.pass == RenderPass::Pass3D) {
OffscreenTexture view(parameters.context, { 256, 256 });
const uint16_t tilesize = bucket.getDEMData().level.dim;
OffscreenTexture view(parameters.context, { tilesize, tilesize });
view.bind();

parameters.context.bindTexture(*bucket.dem, 0, gl::TextureFilter::Nearest, gl::TextureMipMap::No, gl::TextureWrap::Clamp, gl::TextureWrap::Clamp);
Expand All @@ -115,7 +116,7 @@ void RenderHillshadeLayer::render(PaintParameters& parameters, RenderSource*) {
parameters.colorModeForRenderPass(),
HillshadePrepareProgram::UniformValues {
uniforms::u_matrix::Value { mat },
uniforms::u_dimension::Value { {{512, 512 }} },
uniforms::u_dimension::Value { {{uint16_t(tilesize * 2), uint16_t(tilesize * 2) }} },
uniforms::u_zoom::Value{ float(tile.id.canonical.z) },
uniforms::u_image::Value{ 0 }
},
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/renderer/sources/render_raster_dem_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void RenderRasterDEMSource::onTileChanged(Tile& tile){

if (tile.isRenderable() && demtile.neighboringTiles != DEMTileNeighbors::Complete) {
const CanonicalTileID canonical = tile.id.canonical;
const uint dim = std::pow(2, canonical.z);
const uint16_t dim = std::pow(2, canonical.z);
const uint32_t px = (canonical.x - 1 + dim) % dim;
const int pxw = canonical.x == 0 ? tile.id.wrap - 1 : tile.id.wrap;
const uint32_t nx = (canonical.x + 1 + dim) % dim;
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/util/mapbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ canonicalizeTileURL(const std::string& str, const style::SourceType type, const
std::string result = "mapbox://tiles/";
result.append(str, path.directory.first + versionLen, path.directory.second - versionLen);
result.append(str, path.filename.first, path.filename.second);
if (type == style::SourceType::Raster) {
if (type == style::SourceType::Raster || type == style::SourceType::RasterDEM) {
result += tileSize == util::tileSize ? "@2x" : "{ratio}";
}

Expand Down

0 comments on commit 0bc33c9

Please sign in to comment.