summaryrefslogtreecommitdiff
path: root/src/mbgl
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-11-03 12:07:13 +0100
committerKonstantin Käfer <mail@kkaefer.com>2016-11-07 18:51:47 +0100
commitbd3d4bc89a7ce072a32782f2113ef5d838a7913c (patch)
tree4be6bb340ed22a5d90b74cf56114d7cc00236e01 /src/mbgl
parented72581e0c9a1f42dda2d659a1596de20201ce3e (diff)
downloadqtlocation-mapboxgl-bd3d4bc89a7ce072a32782f2113ef5d838a7913c.tar.gz
[core] force explicit initialization of uniform values
force users to use the actual names to avoid implicit conversion accidentally targeting the wrong shader
Diffstat (limited to 'src/mbgl')
-rw-r--r--src/mbgl/gl/uniform.hpp1
-rw-r--r--src/mbgl/renderer/painter_background.cpp10
-rw-r--r--src/mbgl/renderer/painter_circle.cpp23
-rw-r--r--src/mbgl/renderer/painter_clipping.cpp10
-rw-r--r--src/mbgl/renderer/painter_debug.cpp10
-rw-r--r--src/mbgl/renderer/painter_fill.cpp14
-rw-r--r--src/mbgl/renderer/painter_raster.cpp26
-rw-r--r--src/mbgl/renderer/painter_symbol.cpp8
-rw-r--r--src/mbgl/shader/fill_uniforms.cpp32
-rw-r--r--src/mbgl/shader/line_uniforms.cpp58
-rw-r--r--src/mbgl/shader/symbol_uniforms.cpp34
11 files changed, 113 insertions, 113 deletions
diff --git a/src/mbgl/gl/uniform.hpp b/src/mbgl/gl/uniform.hpp
index 645a638024..b6723e2e4d 100644
--- a/src/mbgl/gl/uniform.hpp
+++ b/src/mbgl/gl/uniform.hpp
@@ -18,7 +18,6 @@ class Uniform {
public:
class Value {
public:
- Value(T t_) : t(std::move(t_)) {}
T t;
};
diff --git a/src/mbgl/renderer/painter_background.cpp b/src/mbgl/renderer/painter_background.cpp
index 431a8ca628..a8ebf0de05 100644
--- a/src/mbgl/renderer/painter_background.cpp
+++ b/src/mbgl/renderer/painter_background.cpp
@@ -54,11 +54,11 @@ void Painter::renderBackground(PaintParameters& parameters, const BackgroundLaye
colorModeForRenderPass(),
parameters.shaders.fill,
FillColorUniforms::Values {
- matrixForTile(tileID),
- properties.backgroundOpacity.value,
- properties.backgroundColor.value,
- properties.backgroundColor.value,
- context.viewport.getCurrentValue().size
+ uniforms::u_matrix::Value{ matrixForTile(tileID) },
+ uniforms::u_opacity::Value{ properties.backgroundOpacity.value },
+ uniforms::u_color::Value{ properties.backgroundColor.value },
+ uniforms::u_outline_color::Value{ properties.backgroundColor.value },
+ uniforms::u_world::Value{ context.viewport.getCurrentValue().size },
},
gl::Unindexed<gl::TriangleStrip>(tileTriangleVertexBuffer)
});
diff --git a/src/mbgl/renderer/painter_circle.cpp b/src/mbgl/renderer/painter_circle.cpp
index 731bb7d0ae..fedd1985ba 100644
--- a/src/mbgl/renderer/painter_circle.cpp
+++ b/src/mbgl/renderer/painter_circle.cpp
@@ -21,6 +21,7 @@ void Painter::renderCircle(PaintParameters& parameters,
}
const CirclePaintProperties& properties = layer.impl->paint;
+ const bool scaleWithMap = properties.circlePitchScale.value == CirclePitchScaleType::Map;
context.draw({
depthModeForSublayer(0, gl::DepthMode::ReadOnly),
@@ -30,21 +31,21 @@ void Painter::renderCircle(PaintParameters& parameters,
colorModeForRenderPass(),
parameters.shaders.circle,
CircleUniforms::Values {
- tile.translatedMatrix(properties.circleTranslate.value,
- properties.circleTranslateAnchor.value,
- state),
- properties.circleOpacity.value,
- properties.circleColor.value,
- properties.circleRadius.value,
- properties.circleBlur.value,
- properties.circlePitchScale.value == CirclePitchScaleType::Map,
- properties.circlePitchScale.value == CirclePitchScaleType::Map
+ uniforms::u_matrix::Value{ tile.translatedMatrix(properties.circleTranslate.value,
+ properties.circleTranslateAnchor.value,
+ state) },
+ uniforms::u_opacity::Value{ properties.circleOpacity.value },
+ uniforms::u_color::Value{ properties.circleColor.value },
+ uniforms::u_radius::Value{ properties.circleRadius.value },
+ uniforms::u_blur::Value{ properties.circleBlur.value },
+ uniforms::u_scale_with_map::Value{ scaleWithMap },
+ uniforms::u_extrude_scale::Value{ scaleWithMap
? std::array<float, 2> {{
pixelsToGLUnits[0] * state.getAltitude(),
pixelsToGLUnits[1] * state.getAltitude()
}}
- : pixelsToGLUnits,
- frame.pixelRatio
+ : pixelsToGLUnits },
+ uniforms::u_devicepixelratio::Value{ frame.pixelRatio },
},
gl::Segmented<gl::Triangles>(
*bucket.vertexBuffer,
diff --git a/src/mbgl/renderer/painter_clipping.cpp b/src/mbgl/renderer/painter_clipping.cpp
index d3e9c86a1a..64558d667f 100644
--- a/src/mbgl/renderer/painter_clipping.cpp
+++ b/src/mbgl/renderer/painter_clipping.cpp
@@ -19,11 +19,11 @@ void Painter::renderClippingMask(const UnwrappedTileID& tileID, const ClipID& cl
gl::ColorMode::disabled(),
shaders->fill,
FillColorUniforms::Values {
- matrixForTile(tileID),
- 0.0f,
- Color {},
- Color {},
- context.viewport.getCurrentValue().size
+ uniforms::u_matrix::Value{ matrixForTile(tileID) },
+ uniforms::u_opacity::Value{ 0.0f },
+ uniforms::u_color::Value{ Color {} },
+ uniforms::u_outline_color::Value{ Color {} },
+ uniforms::u_world::Value{ context.viewport.getCurrentValue().size },
},
gl::Unindexed<gl::Triangles>(tileTriangleVertexBuffer)
});
diff --git a/src/mbgl/renderer/painter_debug.cpp b/src/mbgl/renderer/painter_debug.cpp
index a9a50b3a26..08877949f6 100644
--- a/src/mbgl/renderer/painter_debug.cpp
+++ b/src/mbgl/renderer/painter_debug.cpp
@@ -25,11 +25,11 @@ void Painter::renderTileDebug(const RenderTile& renderTile) {
gl::ColorMode::unblended(),
shaders->fill,
FillColorUniforms::Values {
- renderTile.matrix,
- 1.0f,
- color,
- color,
- context.viewport.getCurrentValue().size
+ uniforms::u_matrix::Value{ renderTile.matrix },
+ uniforms::u_opacity::Value{ 1.0f },
+ uniforms::u_color::Value{ color },
+ uniforms::u_outline_color::Value{ color },
+ uniforms::u_world::Value{ context.viewport.getCurrentValue().size },
},
subject
});
diff --git a/src/mbgl/renderer/painter_fill.cpp b/src/mbgl/renderer/painter_fill.cpp
index 5726858450..5a9e7a9096 100644
--- a/src/mbgl/renderer/painter_fill.cpp
+++ b/src/mbgl/renderer/painter_fill.cpp
@@ -83,13 +83,13 @@ void Painter::renderFill(PaintParameters& parameters,
colorModeForRenderPass(),
shader,
FillColorUniforms::Values {
- tile.translatedMatrix(properties.fillTranslate.value,
- properties.fillTranslateAnchor.value,
- state),
- properties.fillOpacity.value,
- properties.fillColor.value,
- outlineColor,
- context.viewport.getCurrentValue().size
+ uniforms::u_matrix::Value{ tile.translatedMatrix(properties.fillTranslate.value,
+ properties.fillTranslateAnchor.value,
+ state) },
+ uniforms::u_opacity::Value{ properties.fillOpacity.value },
+ uniforms::u_color::Value{ properties.fillColor.value },
+ uniforms::u_outline_color::Value{ outlineColor },
+ uniforms::u_world::Value{ context.viewport.getCurrentValue().size },
},
subject
});
diff --git a/src/mbgl/renderer/painter_raster.cpp b/src/mbgl/renderer/painter_raster.cpp
index 441bca9dc8..6acd29eb37 100644
--- a/src/mbgl/renderer/painter_raster.cpp
+++ b/src/mbgl/renderer/painter_raster.cpp
@@ -60,19 +60,19 @@ void Painter::renderRaster(PaintParameters& parameters,
colorModeForRenderPass(),
parameters.shaders.raster,
RasterUniforms::Values {
- tile.matrix,
- 0,
- 1,
- properties.rasterOpacity.value,
- 0,
- properties.rasterBrightnessMin.value,
- properties.rasterBrightnessMax.value,
- saturationFactor(properties.rasterSaturation.value),
- contrastFactor(properties.rasterContrast.value),
- spinWeights(properties.rasterHueRotate.value),
- 1.0f,
- 1.0f,
- std::array<float, 2> {{ 0.0f, 0.0f }}
+ uniforms::u_matrix::Value{ tile.matrix },
+ uniforms::u_image0::Value{ 0 },
+ uniforms::u_image1::Value{ 1 },
+ uniforms::u_opacity0::Value{ properties.rasterOpacity.value },
+ uniforms::u_opacity1::Value{ 0 },
+ uniforms::u_brightness_low::Value{ properties.rasterBrightnessMin.value },
+ uniforms::u_brightness_high::Value{ properties.rasterBrightnessMax.value },
+ uniforms::u_saturation_factor::Value{ saturationFactor(properties.rasterSaturation.value) },
+ uniforms::u_contrast_factor::Value{ contrastFactor(properties.rasterContrast.value) },
+ uniforms::u_spin_weights::Value{ spinWeights(properties.rasterHueRotate.value) },
+ uniforms::u_buffer_scale::Value{ 1.0f },
+ uniforms::u_scale_parent::Value{ 1.0f },
+ uniforms::u_tl_parent::Value{ std::array<float, 2> {{ 0.0f, 0.0f }} },
},
gl::Unindexed<gl::TriangleStrip>(rasterVertexBuffer)
});
diff --git a/src/mbgl/renderer/painter_symbol.cpp b/src/mbgl/renderer/painter_symbol.cpp
index 11d48db90e..cf4bb9ee86 100644
--- a/src/mbgl/renderer/painter_symbol.cpp
+++ b/src/mbgl/renderer/painter_symbol.cpp
@@ -125,10 +125,10 @@ void Painter::renderSymbol(PaintParameters& parameters,
colorModeForRenderPass(),
shaders->collisionBox,
CollisionBoxUniforms::Values {
- tile.matrix,
- std::pow(2.0f, state.getZoom() - tile.tile.id.overscaledZ),
- state.getZoom() * 10,
- (tile.id.canonical.z + 1) * 10
+ uniforms::u_matrix::Value{ tile.matrix },
+ uniforms::u_scale::Value{ std::pow(2.0f, float(state.getZoom() - tile.tile.id.overscaledZ)) },
+ uniforms::u_zoom::Value{ float(state.getZoom() * 10) },
+ uniforms::u_maxzoom::Value{ float((tile.id.canonical.z + 1) * 10) },
},
gl::Unindexed<gl::Lines>(
*bucket.collisionBox.vertexBuffer,
diff --git a/src/mbgl/shader/fill_uniforms.cpp b/src/mbgl/shader/fill_uniforms.cpp
index 368cb12fcf..acd207c5d4 100644
--- a/src/mbgl/shader/fill_uniforms.cpp
+++ b/src/mbgl/shader/fill_uniforms.cpp
@@ -23,22 +23,22 @@ FillPatternUniforms::values(mat4 matrix,
int32_t pixelY = tileSizeAtNearestZoom * tileID.canonical.y;
return FillPatternUniforms::Values {
- matrix,
- opacity,
- framebufferSize,
- a.tl,
- a.br,
- b.tl,
- b.br,
- a.size,
- b.size,
- fading.fromScale,
- fading.toScale,
- fading.t,
- 0,
- std::array<float, 2> {{ float(pixelX >> 16), float(pixelY >> 16) }},
- std::array<float, 2> {{ float(pixelX & 0xFFFF), float(pixelY & 0xFFFF) }},
- 1.0f / tileID.pixelsToTileUnits(1.0f, state.getIntegerZoom())
+ uniforms::u_matrix::Value{ matrix },
+ uniforms::u_opacity::Value{ opacity },
+ uniforms::u_world::Value{ framebufferSize },
+ uniforms::u_pattern_tl_a::Value{ a.tl },
+ uniforms::u_pattern_br_a::Value{ a.br },
+ uniforms::u_pattern_tl_b::Value{ b.tl },
+ uniforms::u_pattern_br_b::Value{ b.br },
+ uniforms::u_pattern_size_a::Value{ a.size },
+ uniforms::u_pattern_size_b::Value{ b.size },
+ uniforms::u_scale_a::Value{ fading.fromScale },
+ uniforms::u_scale_b::Value{ fading.toScale },
+ uniforms::u_mix::Value{ fading.t },
+ uniforms::u_image::Value{ 0 },
+ uniforms::u_pixel_coord_upper::Value{ std::array<float, 2> {{ float(pixelX >> 16), float(pixelY >> 16) }} },
+ uniforms::u_pixel_coord_lower::Value{ std::array<float, 2> {{ float(pixelX & 0xFFFF), float(pixelY & 0xFFFF) }} },
+ uniforms::u_tile_units_to_pixels::Value{ 1.0f / tileID.pixelsToTileUnits(1.0f, state.getIntegerZoom()) },
};
}
diff --git a/src/mbgl/shader/line_uniforms.cpp b/src/mbgl/shader/line_uniforms.cpp
index f1d73e20eb..0e9e5e27f0 100644
--- a/src/mbgl/shader/line_uniforms.cpp
+++ b/src/mbgl/shader/line_uniforms.cpp
@@ -29,18 +29,18 @@ Values makeValues(const style::LinePaintProperties& properties,
float x = state.getSize().height / 2.0f * std::tan(state.getPitch());
return Values {
- tile.translatedMatrix(properties.lineTranslate.value,
- properties.lineTranslateAnchor.value,
- state),
- properties.lineOpacity.value,
- properties.lineWidth.value / 2,
- properties.lineGapWidth.value / 2,
- properties.lineBlur.value + antialiasing,
- -properties.lineOffset.value,
- antialiasing / 2,
- antialiasingMatrix,
- 1.0f / tile.id.pixelsToTileUnits(1.0, state.getZoom()),
- (topedgelength + x) / topedgelength - 1.0f,
+ uniforms::u_matrix::Value{ tile.translatedMatrix(properties.lineTranslate.value,
+ properties.lineTranslateAnchor.value,
+ state) },
+ uniforms::u_opacity::Value{ properties.lineOpacity.value },
+ uniforms::u_linewidth::Value{ properties.lineWidth.value / 2 },
+ uniforms::u_gapwidth::Value{ properties.lineGapWidth.value / 2 },
+ uniforms::u_blur::Value{ properties.lineBlur.value + antialiasing },
+ uniforms::u_offset::Value{ -properties.lineOffset.value },
+ uniforms::u_antialiasing::Value{ antialiasing / 2 },
+ uniforms::u_antialiasingmatrix::Value{ antialiasingMatrix },
+ uniforms::u_ratio::Value{ 1.0f / tile.id.pixelsToTileUnits(1.0, state.getZoom()) },
+ uniforms::u_extra::Value{ (topedgelength + x) / topedgelength - 1.0f },
std::forward<Args>(args)...
};
}
@@ -55,7 +55,7 @@ LineColorUniforms::values(const style::LinePaintProperties& properties,
pixelRatio,
tile,
state,
- properties.lineColor.value
+ uniforms::u_color::Value{ properties.lineColor.value }
);
}
@@ -86,14 +86,14 @@ LineSDFUniforms::values(const style::LinePaintProperties& properties,
pixelRatio,
tile,
state,
- properties.lineColor.value,
- scaleA,
- scaleB,
- posA.y,
- posB.y,
- properties.lineDasharray.value.t,
- atlasWidth / (std::min(widthA, widthB) * 256.0f * pixelRatio) / 2.0f,
- 0
+ uniforms::u_color::Value{ properties.lineColor.value },
+ uniforms::u_patternscale_a::Value{ scaleA },
+ uniforms::u_patternscale_b::Value{ scaleB },
+ uniforms::u_tex_y_a::Value{ posA.y },
+ uniforms::u_tex_y_b::Value{ posB.y },
+ uniforms::u_mix::Value{ properties.lineDasharray.value.t },
+ uniforms::u_sdfgamma::Value{ atlasWidth / (std::min(widthA, widthB) * 256.0f * pixelRatio) / 2.0f },
+ uniforms::u_image::Value{ 0 }
);
}
@@ -119,14 +119,14 @@ LinePatternUniforms::values(const style::LinePaintProperties& properties,
pixelRatio,
tile,
state,
- posA.tl,
- posA.br,
- posB.tl,
- posB.br,
- sizeA,
- sizeB,
- properties.linePattern.value.t,
- 0
+ uniforms::u_pattern_tl_a::Value{ posA.tl },
+ uniforms::u_pattern_br_a::Value{ posA.br },
+ uniforms::u_pattern_tl_b::Value{ posB.tl },
+ uniforms::u_pattern_br_b::Value{ posB.br },
+ uniforms::u_pattern_size_a::Value{ sizeA },
+ uniforms::u_pattern_size_b::Value{ sizeB },
+ uniforms::u_fade::Value{ properties.linePattern.value.t },
+ uniforms::u_image::Value{ 0 }
);
}
diff --git a/src/mbgl/shader/symbol_uniforms.cpp b/src/mbgl/shader/symbol_uniforms.cpp
index 7071eff07c..ec2cf26c8a 100644
--- a/src/mbgl/shader/symbol_uniforms.cpp
+++ b/src/mbgl/shader/symbol_uniforms.cpp
@@ -30,16 +30,16 @@ Values makeValues(const style::SymbolPropertyValues& values,
float zoomAdjust = std::log(values.paintSize / values.layoutSize) / std::log(2);
return Values {
- tile.translatedMatrix(values.translate,
- values.translateAnchor,
- state),
- values.opacity,
- extrudeScale,
- std::array<float, 2> {{ float(texsize.width) / 4, float(texsize.height) / 4 }},
- (state.getZoom() - zoomAdjust) * 10.0f,
- values.rotationAlignment == AlignmentType::Map,
- 0,
- 1,
+ uniforms::u_matrix::Value{ tile.translatedMatrix(values.translate,
+ values.translateAnchor,
+ state) },
+ uniforms::u_opacity::Value{ values.opacity },
+ uniforms::u_extrude_scale::Value{ extrudeScale },
+ uniforms::u_texsize::Value{ std::array<float, 2> {{ float(texsize.width) / 4, float(texsize.height) / 4 }} },
+ uniforms::u_zoom::Value{ float((state.getZoom() - zoomAdjust) * 10) },
+ uniforms::u_rotate_with_map::Value{ values.rotationAlignment == AlignmentType::Map },
+ uniforms::u_texture::Value{ 0 },
+ uniforms::u_fadetexture::Value{ 1 },
std::forward<Args>(args)...
};
}
@@ -83,13 +83,13 @@ static SymbolSDFUniforms::Values makeSDFValues(const style::SymbolPropertyValues
pixelsToGLUnits,
tile,
state,
- color,
- buffer,
- (gammaBase + gammaAdjust) * gammaScale,
- state.getPitch(),
- -1.0f * state.getAngle(),
- (state.getSize().width * 1.0f) / (state.getSize().height * 1.0f),
- values.pitchAlignment == AlignmentType::Map
+ uniforms::u_color::Value{ color },
+ uniforms::u_buffer::Value{ buffer },
+ uniforms::u_gamma::Value{ (gammaBase + gammaAdjust) * gammaScale },
+ uniforms::u_pitch::Value{ state.getPitch() },
+ uniforms::u_bearing::Value{ -1.0f * state.getAngle() },
+ uniforms::u_aspect_ratio::Value{ (state.getSize().width * 1.0f) / (state.getSize().height * 1.0f) },
+ uniforms::u_pitch_with_map::Value{ values.pitchAlignment == AlignmentType::Map }
);
}