summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-05-25 21:02:46 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-05-25 21:37:58 -0700
commit172e645686384a09e5fcde04001c56b82abc9d3a (patch)
tree9d9370acdcd94adbf67cfeb0b995954bc1ab6a48 /src
parentc568a8ad77320c869d8e7c23b86426c094aceb6c (diff)
downloadqtlocation-mapboxgl-172e645686384a09e5fcde04001c56b82abc9d3a.tar.gz
[core] Port "combine line-width and line-gap-width in shader"
https://github.com/mapbox/mapbox-gl-shaders/commit/a9559e911b11a155135888f733a96e5110f8cef6 https://github.com/mapbox/mapbox-gl-js/commit/fcb9bcebae6e00f24ebfde8d7ec09adb95f6b1a3
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/renderer/painter_line.cpp29
-rw-r--r--src/mbgl/shader/line_shader.hpp5
-rw-r--r--src/mbgl/shader/linepattern_shader.hpp5
-rw-r--r--src/mbgl/shader/linesdf_shader.hpp5
4 files changed, 18 insertions, 26 deletions
diff --git a/src/mbgl/renderer/painter_line.cpp b/src/mbgl/renderer/painter_line.cpp
index f1f8403a42..e0592b4bc1 100644
--- a/src/mbgl/renderer/painter_line.cpp
+++ b/src/mbgl/renderer/painter_line.cpp
@@ -33,20 +33,6 @@ void Painter::renderLine(LineBucket& bucket,
bool wireframe = frame.debugOptions & MapDebugOptions::Wireframe;
float blur = properties.lineBlur + antialiasing;
- float edgeWidth = wireframe ? 1 : properties.lineWidth / 2.0;
- float inset = -1;
- float offset = 0;
- float shift = 0;
-
- if (properties.lineGapWidth != 0 && !wireframe) {
- inset = properties.lineGapWidth / 2.0 + antialiasing * 0.5;
- edgeWidth = properties.lineWidth;
-
- // shift outer lines half a pixel towards the middle to eliminate the crack
- offset = inset - antialiasing / 2.0;
- }
-
- float outset = offset + edgeWidth + antialiasing / 2.0 + shift;
Color color = {{ 1.0f, 1.0f, 1.0f, 1.0f }};
float opacity = 1.0f;
@@ -78,8 +64,9 @@ void Painter::renderLine(LineBucket& bucket,
config.program = linesdfShader->getID();
linesdfShader->u_matrix = vtxMatrix;
- linesdfShader->u_exmatrix = extrudeMatrix;
- linesdfShader->u_linewidth = {{ outset, inset }};
+ linesdfShader->u_linewidth = properties.lineWidth / 2;
+ linesdfShader->u_gapwidth = properties.lineGapWidth / 2;
+ linesdfShader->u_antialiasing = antialiasing / 2;
linesdfShader->u_ratio = ratio;
linesdfShader->u_blur = blur;
linesdfShader->u_color = color;
@@ -122,8 +109,9 @@ void Painter::renderLine(LineBucket& bucket,
config.program = linepatternShader->getID();
linepatternShader->u_matrix = vtxMatrix;
- linepatternShader->u_exmatrix = extrudeMatrix;
- linepatternShader->u_linewidth = {{ outset, inset }};
+ linepatternShader->u_linewidth = properties.lineWidth / 2;
+ linepatternShader->u_gapwidth = properties.lineGapWidth / 2;
+ linepatternShader->u_antialiasing = antialiasing / 2;
linepatternShader->u_ratio = ratio;
linepatternShader->u_blur = blur;
@@ -157,8 +145,9 @@ void Painter::renderLine(LineBucket& bucket,
config.program = lineShader->getID();
lineShader->u_matrix = vtxMatrix;
- lineShader->u_exmatrix = extrudeMatrix;
- lineShader->u_linewidth = {{ outset, inset }};
+ lineShader->u_linewidth = properties.lineWidth / 2;
+ lineShader->u_gapwidth = properties.lineGapWidth / 2;
+ lineShader->u_antialiasing = antialiasing / 2;
lineShader->u_ratio = ratio;
lineShader->u_blur = blur;
lineShader->u_extra = extra;
diff --git a/src/mbgl/shader/line_shader.hpp b/src/mbgl/shader/line_shader.hpp
index 4a6d86381c..7e38db1656 100644
--- a/src/mbgl/shader/line_shader.hpp
+++ b/src/mbgl/shader/line_shader.hpp
@@ -12,11 +12,12 @@ public:
void bind(GLbyte *offset) final;
UniformMatrix<4> u_matrix = {"u_matrix", *this};
- UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this};
Uniform<std::array<GLfloat, 4>> u_color = {"u_color", *this};
Uniform<GLfloat> u_opacity = {"u_opacity", *this};
- Uniform<std::array<GLfloat, 2>> u_linewidth = {"u_linewidth", *this};
Uniform<GLfloat> u_ratio = {"u_ratio", *this};
+ Uniform<GLfloat> u_linewidth = {"u_linewidth", *this};
+ Uniform<GLfloat> u_gapwidth = {"u_gapwidth", *this};
+ Uniform<GLfloat> u_antialiasing = {"u_antialiasing", *this};
Uniform<GLfloat> u_blur = {"u_blur", *this};
Uniform<GLfloat> u_extra = {"u_extra", *this};
Uniform<GLfloat> u_offset = {"u_offset", *this};
diff --git a/src/mbgl/shader/linepattern_shader.hpp b/src/mbgl/shader/linepattern_shader.hpp
index 98280af971..3cb91eae9d 100644
--- a/src/mbgl/shader/linepattern_shader.hpp
+++ b/src/mbgl/shader/linepattern_shader.hpp
@@ -12,8 +12,9 @@ public:
void bind(GLbyte *offset) final;
UniformMatrix<4> u_matrix = {"u_matrix", *this};
- UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this};
- Uniform<std::array<GLfloat, 2>> u_linewidth = {"u_linewidth", *this};
+ Uniform<GLfloat> u_linewidth = {"u_linewidth", *this};
+ Uniform<GLfloat> u_gapwidth = {"u_gapwidth", *this};
+ Uniform<GLfloat> u_antialiasing = {"u_antialiasing", *this};
Uniform<std::array<GLfloat, 2>> u_pattern_size_a = {"u_pattern_size_a", *this};
Uniform<std::array<GLfloat, 2>> u_pattern_tl_a = {"u_pattern_tl_a", *this};
Uniform<std::array<GLfloat, 2>> u_pattern_br_a = {"u_pattern_br_a", *this};
diff --git a/src/mbgl/shader/linesdf_shader.hpp b/src/mbgl/shader/linesdf_shader.hpp
index 65d8e74b3a..8465952dac 100644
--- a/src/mbgl/shader/linesdf_shader.hpp
+++ b/src/mbgl/shader/linesdf_shader.hpp
@@ -12,10 +12,11 @@ public:
void bind(GLbyte *offset) final;
UniformMatrix<4> u_matrix = {"u_matrix", *this};
- UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this};
Uniform<std::array<GLfloat, 4>> u_color = {"u_color", *this};
Uniform<GLfloat> u_opacity = {"u_opacity", *this};
- Uniform<std::array<GLfloat, 2>> u_linewidth = {"u_linewidth", *this};
+ Uniform<GLfloat> u_linewidth = {"u_linewidth", *this};
+ Uniform<GLfloat> u_gapwidth = {"u_gapwidth", *this};
+ Uniform<GLfloat> u_antialiasing = {"u_antialiasing", *this};
Uniform<GLfloat> u_ratio = {"u_ratio", *this};
Uniform<GLfloat> u_blur = {"u_blur", *this};
Uniform<std::array<GLfloat, 2>> u_patternscale_a = { "u_patternscale_a", *this};