summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVladimir Agafonkin <agafonkin@gmail.com>2018-01-15 20:03:08 +0200
committerVladimir Agafonkin <agafonkin@gmail.com>2018-01-15 20:03:08 +0200
commit247894281544b28553081b044c25014a0e1514e0 (patch)
treec5a340cbf4747aa26b999e325ad5d546fed7d8af /src
parentb88b9743bc95951a4b574c1435c8d430a4456fa9 (diff)
downloadqtlocation-mapboxgl-247894281544b28553081b044c25014a0e1514e0.tar.gz
WIP heatmaps, crashing commit
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/programs/heatmap_program.hpp2
-rw-r--r--src/mbgl/programs/uniforms.hpp4
-rw-r--r--src/mbgl/renderer/layers/render_heatmap_layer.cpp68
-rw-r--r--src/mbgl/style/conversion/layer.cpp3
4 files changed, 42 insertions, 35 deletions
diff --git a/src/mbgl/programs/heatmap_program.hpp b/src/mbgl/programs/heatmap_program.hpp
index cff04ffad7..d52133f4c3 100644
--- a/src/mbgl/programs/heatmap_program.hpp
+++ b/src/mbgl/programs/heatmap_program.hpp
@@ -20,7 +20,7 @@ class HeatmapProgram : public Program<
attributes::a_pos>,
gl::Uniforms<
uniforms::u_matrix,
- uniforms::u_extrude_scale>,
+ uniforms::heatmap::u_extrude_scale>,
style::HeatmapPaintProperties>
{
public:
diff --git a/src/mbgl/programs/uniforms.hpp b/src/mbgl/programs/uniforms.hpp
index 5cd3f3b5b9..003e736475 100644
--- a/src/mbgl/programs/uniforms.hpp
+++ b/src/mbgl/programs/uniforms.hpp
@@ -41,6 +41,10 @@ MBGL_DEFINE_UNIFORM_SCALAR(float, u_weight);
MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_extrude_scale);
+namespace heatmap {
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_extrude_scale);
+}
+
MBGL_DEFINE_UNIFORM_VECTOR(uint16_t, 2, u_pattern_tl_a);
MBGL_DEFINE_UNIFORM_VECTOR(uint16_t, 2, u_pattern_br_a);
MBGL_DEFINE_UNIFORM_VECTOR(uint16_t, 2, u_pattern_tl_b);
diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.cpp b/src/mbgl/renderer/layers/render_heatmap_layer.cpp
index 6e5d78031a..f3cf50cf67 100644
--- a/src/mbgl/renderer/layers/render_heatmap_layer.cpp
+++ b/src/mbgl/renderer/layers/render_heatmap_layer.cpp
@@ -36,10 +36,9 @@ void RenderHeatmapLayer::transition(const TransitionParameters& parameters) {
void RenderHeatmapLayer::evaluate(const PropertyEvaluationParameters& parameters) {
evaluated = unevaluated.evaluate(parameters);
- passes = ((evaluated.get<style::HeatmapRadius>() > 0)
- && (evaluated.get<style::HeatmapColor>().a > 0)
- && (evaluated.get<style::HeatmapOpacity>() > 0))
- ? RenderPass::Translucent : RenderPass::None;
+ passes = (evaluated.get<style::HeatmapOpacity>() > 0)
+ ? (RenderPass::Translucent | RenderPass::Pass3D)
+ : RenderPass::None;
}
bool RenderHeatmapLayer::hasTransition() const {
@@ -51,37 +50,38 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
return;
}
- for (const RenderTile& tile : renderTiles) {
- assert(dynamic_cast<HeatmapBucket*>(tile.tile.getBucket(*baseImpl)));
- HeatmapBucket& bucket = *reinterpret_cast<HeatmapBucket*>(tile.tile.getBucket(*baseImpl));
-
- parameters.programs.heatmap.get(evaluated).draw(
- parameters.context,
- gl::Triangles(),
- parameters.depthModeForSublayer(0, gl::DepthMode::ReadOnly),
- parameters.mapMode != MapMode::Continuous
- ? parameters.stencilModeForClipping(tile.clip)
- : gl::StencilMode::disabled(),
- parameters.colorModeForRenderPass(),
- HeatmapProgram::UniformValues {
- uniforms::u_matrix::Value{
- tile.translatedMatrix(std::array<float, 2>{{0, 0}},
- TranslateAnchorType::Map,
- parameters.state)
+ if (parameters.pass == RenderPass::Translucent) {
+ for (const RenderTile& tile : renderTiles) {
+ assert(dynamic_cast<HeatmapBucket*>(tile.tile.getBucket(*baseImpl)));
+ HeatmapBucket& bucket = *reinterpret_cast<HeatmapBucket*>(tile.tile.getBucket(*baseImpl));
+
+ // parameters.context.clear(Color{ 1.0f, 0.0f, 0.0f, 1.0f }, {}, {});
+
+ parameters.programs.heatmap.get(evaluated).draw(
+ parameters.context,
+ gl::Triangles(),
+ parameters.depthModeForSublayer(0, gl::DepthMode::ReadOnly),
+ parameters.mapMode != MapMode::Continuous
+ ? parameters.stencilModeForClipping(tile.clip)
+ : gl::StencilMode::disabled(),
+ parameters.colorModeForRenderPass(),
+ HeatmapProgram::UniformValues {
+ uniforms::u_matrix::Value{
+ tile.translatedMatrix(std::array<float, 2>{{0, 0}},
+ TranslateAnchorType::Map,
+ parameters.state)
+ },
+ uniforms::heatmap::u_extrude_scale::Value{ tile.id.pixelsToTileUnits(1, parameters.state.getZoom()) }
},
- uniforms::u_extrude_scale::Value{ std::array<float, 2> {{
- tile.id.pixelsToTileUnits(1, parameters.state.getZoom()),
- tile.id.pixelsToTileUnits(1, parameters.state.getZoom())
- }}}
- },
- *bucket.vertexBuffer,
- *bucket.indexBuffer,
- bucket.segments,
- bucket.paintPropertyBinders.at(getID()),
- evaluated,
- parameters.state.getZoom(),
- getID()
- );
+ *bucket.vertexBuffer,
+ *bucket.indexBuffer,
+ bucket.segments,
+ bucket.paintPropertyBinders.at(getID()),
+ evaluated,
+ parameters.state.getZoom(),
+ getID()
+ );
+ }
}
}
diff --git a/src/mbgl/style/conversion/layer.cpp b/src/mbgl/style/conversion/layer.cpp
index 0ca582f8dc..6b678b843a 100644
--- a/src/mbgl/style/conversion/layer.cpp
+++ b/src/mbgl/style/conversion/layer.cpp
@@ -9,6 +9,7 @@
#include <mbgl/style/layers/line_layer.hpp>
#include <mbgl/style/layers/raster_layer.hpp>
#include <mbgl/style/layers/symbol_layer.hpp>
+#include <mbgl/style/layers/heatmap_layer.hpp>
namespace mbgl {
namespace style {
@@ -140,6 +141,8 @@ optional<std::unique_ptr<Layer>> Converter<std::unique_ptr<Layer>>::operator()(c
converted = convertVectorLayer<LineLayer>(*id, value, error);
} else if (*type == "circle") {
converted = convertVectorLayer<CircleLayer>(*id, value, error);
+ } else if (*type == "heatmap") {
+ converted = convertVectorLayer<HeatmapLayer>(*id, value, error);
} else if (*type == "symbol") {
converted = convertVectorLayer<SymbolLayer>(*id, value, error);
} else if (*type == "raster") {