diff options
author | Molly Lloyd <mollymerp@users.noreply.github.com> | 2017-07-27 14:54:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-27 14:54:03 -0700 |
commit | ba7574ec51e2cfd4a55565d5a8337c47f1784bc2 (patch) | |
tree | c9f36f4b0a0ec24228b5ff39aac082252e9d8e21 /src | |
parent | 175e7e26e2008d1e55664bd1064536c23b6de86a (diff) | |
download | qtlocation-mapboxgl-ba7574ec51e2cfd4a55565d5a8337c47f1784bc2.tar.gz |
[core] modify texture coordinate scaling (#9153)
ignore unsupported dds property tests
fix tests
remove unneeded texture extent variable
bump gl-js to master
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/renderer/buckets/raster_bucket.cpp | 13 | ||||
-rw-r--r-- | src/mbgl/renderer/render_static_data.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/renderer/sources/render_image_source.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/shaders/debug.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/shaders/raster.cpp | 7 |
5 files changed, 23 insertions, 17 deletions
diff --git a/src/mbgl/renderer/buckets/raster_bucket.cpp b/src/mbgl/renderer/buckets/raster_bucket.cpp index 1a0409f456..a66dd42d74 100644 --- a/src/mbgl/renderer/buckets/raster_bucket.cpp +++ b/src/mbgl/renderer/buckets/raster_bucket.cpp @@ -69,16 +69,11 @@ void RasterBucket::setMask(TileMask&& mask_) { for (const auto& id : mask) { // Create a quad for every masked tile. const int32_t vertexExtent = util::EXTENT >> id.z; - const int32_t textureExtent = 32768 >> id.z; const Point<int16_t> tlVertex = { static_cast<int16_t>(id.x * vertexExtent), static_cast<int16_t>(id.y * vertexExtent) }; const Point<int16_t> brVertex = { static_cast<int16_t>(tlVertex.x + vertexExtent), static_cast<int16_t>(tlVertex.y + vertexExtent) }; - const Point<uint16_t> tlTexture = { static_cast<uint16_t>(id.x * textureExtent), - static_cast<uint16_t>(id.y * textureExtent) }; - const Point<uint16_t> brTexture = { static_cast<uint16_t>(tlTexture.x + textureExtent), - static_cast<uint16_t>(tlTexture.y + textureExtent) }; if (segments.back().vertexLength + vertexLength > std::numeric_limits<uint16_t>::max()) { // Move to a new segments because the old one can't hold the geometry. @@ -86,13 +81,13 @@ void RasterBucket::setMask(TileMask&& mask_) { } vertices.emplace_back( - RasterProgram::layoutVertex({ tlVertex.x, tlVertex.y }, { tlTexture.x, tlTexture.y })); + RasterProgram::layoutVertex({ tlVertex.x, tlVertex.y }, { static_cast<uint16_t>(tlVertex.x), static_cast<uint16_t>(tlVertex.y) })); vertices.emplace_back( - RasterProgram::layoutVertex({ brVertex.x, tlVertex.y }, { brTexture.x, tlTexture.y })); + RasterProgram::layoutVertex({ brVertex.x, tlVertex.y }, { static_cast<uint16_t>(brVertex.x), static_cast<uint16_t>(tlVertex.y) })); vertices.emplace_back( - RasterProgram::layoutVertex({ tlVertex.x, brVertex.y }, { tlTexture.x, brTexture.y })); + RasterProgram::layoutVertex({ tlVertex.x, brVertex.y }, { static_cast<uint16_t>(tlVertex.x), static_cast<uint16_t>(brVertex.y) })); vertices.emplace_back( - RasterProgram::layoutVertex({ brVertex.x, brVertex.y }, { brTexture.x, brTexture.y })); + RasterProgram::layoutVertex({ brVertex.x, brVertex.y }, { static_cast<uint16_t>(brVertex.x), static_cast<uint16_t>(brVertex.y) })); auto& segment = segments.back(); assert(segment.vertexLength <= std::numeric_limits<uint16_t>::max()); diff --git a/src/mbgl/renderer/render_static_data.cpp b/src/mbgl/renderer/render_static_data.cpp index 4c6028d7b6..ccf239e643 100644 --- a/src/mbgl/renderer/render_static_data.cpp +++ b/src/mbgl/renderer/render_static_data.cpp @@ -32,9 +32,9 @@ static gl::IndexVector<gl::LineStrip> tileLineStripIndices() { static gl::VertexVector<RasterLayoutVertex> rasterVertices() { gl::VertexVector<RasterLayoutVertex> result; result.emplace_back(RasterProgram::layoutVertex({ 0, 0 }, { 0, 0 })); - result.emplace_back(RasterProgram::layoutVertex({ util::EXTENT, 0 }, { 32767, 0 })); - result.emplace_back(RasterProgram::layoutVertex({ 0, util::EXTENT }, { 0, 32767 })); - result.emplace_back(RasterProgram::layoutVertex({ util::EXTENT, util::EXTENT }, { 32767, 32767 })); + result.emplace_back(RasterProgram::layoutVertex({ util::EXTENT, 0 }, { util::EXTENT, 0 })); + result.emplace_back(RasterProgram::layoutVertex({ 0, util::EXTENT }, { 0, util::EXTENT })); + result.emplace_back(RasterProgram::layoutVertex({ util::EXTENT, util::EXTENT }, { util::EXTENT, util::EXTENT })); return result; } diff --git a/src/mbgl/renderer/sources/render_image_source.cpp b/src/mbgl/renderer/sources/render_image_source.cpp index 11ff8c26b1..50d5b17ec2 100644 --- a/src/mbgl/renderer/sources/render_image_source.cpp +++ b/src/mbgl/renderer/sources/render_image_source.cpp @@ -10,6 +10,7 @@ #include <mbgl/util/tile_coordinate.hpp> #include <mbgl/util/tile_cover.hpp> #include <mbgl/util/logging.hpp> +#include <mbgl/util/constants.hpp> namespace mbgl { @@ -193,11 +194,11 @@ void RenderImageSource::update(Immutable<style::Source::Impl> baseImpl_, bucket->vertices.emplace_back( RasterProgram::layoutVertex({ geomCoords[0].x, geomCoords[0].y }, { 0, 0 })); bucket->vertices.emplace_back( - RasterProgram::layoutVertex({ geomCoords[1].x, geomCoords[1].y }, { 32767, 0 })); + RasterProgram::layoutVertex({ geomCoords[1].x, geomCoords[1].y }, { util::EXTENT, 0 })); bucket->vertices.emplace_back( - RasterProgram::layoutVertex({ geomCoords[3].x, geomCoords[3].y }, { 0, 32767 })); + RasterProgram::layoutVertex({ geomCoords[3].x, geomCoords[3].y }, { 0, util::EXTENT })); bucket->vertices.emplace_back( - RasterProgram::layoutVertex({ geomCoords[2].x, geomCoords[2].y }, { 32767, 32767 })); + RasterProgram::layoutVertex({ geomCoords[2].x, geomCoords[2].y }, { util::EXTENT, util::EXTENT })); bucket->indices.emplace_back(0, 1, 2); bucket->indices.emplace_back(1, 2, 3); diff --git a/src/mbgl/shaders/debug.cpp b/src/mbgl/shaders/debug.cpp index d39dcf25be..d18f3be5d1 100644 --- a/src/mbgl/shaders/debug.cpp +++ b/src/mbgl/shaders/debug.cpp @@ -12,7 +12,12 @@ attribute vec2 a_pos; uniform mat4 u_matrix; void main() { - gl_Position = u_matrix * vec4(a_pos, step(32767.0, a_pos.x), 1); + // We are using Int16 for texture position coordinates to give us enough precision for + // fractional coordinates. We use 8192 to scale the texture coordinates in the buffer + // as an arbitrarily high number to preserve adequate precision when rendering. + // This is also the same value as the EXTENT we are using for our tile buffer pos coordinates, + // so math for modifying either is consistent. + gl_Position = u_matrix * vec4(a_pos, step(8192.0, a_pos.x), 1); } )MBGL_SHADER"; diff --git a/src/mbgl/shaders/raster.cpp b/src/mbgl/shaders/raster.cpp index f454078310..98291bfec6 100644 --- a/src/mbgl/shaders/raster.cpp +++ b/src/mbgl/shaders/raster.cpp @@ -20,7 +20,12 @@ varying vec2 v_pos1; void main() { gl_Position = u_matrix * vec4(a_pos, 0, 1); - v_pos0 = (((a_texture_pos / 32767.0) - 0.5) / u_buffer_scale ) + 0.5; + // We are using Int16 for texture position coordinates to give us enough precision for + // fractional coordinates. We use 8192 to scale the texture coordinates in the buffer + // as an arbitrarily high number to preserve adequate precision when rendering. + // This is also the same value as the EXTENT we are using for our tile buffer pos coordinates, + // so math for modifying either is consistent. + v_pos0 = (((a_texture_pos / 8192.0) - 0.5) / u_buffer_scale ) + 0.5; v_pos1 = (v_pos0 * u_scale_parent) + u_tl_parent; } |