summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2018-10-25 17:30:59 +0300
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2018-11-19 14:06:21 +0200
commita7274f66d06b061effe57b2aeff254b4f94ba248 (patch)
tree7d4fcb187c848b8b064b65db7790e471de458145 /src
parentf6ad5f378e9a0741b7d3c293cb91466ba2770e36 (diff)
downloadqtlocation-mapboxgl-a7274f66d06b061effe57b2aeff254b4f94ba248.tar.gz
[core] Move layer specific color ramp updates behind common update() method
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/renderer/layers/render_heatmap_layer.cpp4
-rw-r--r--src/mbgl/renderer/layers/render_heatmap_layer.hpp6
-rw-r--r--src/mbgl/renderer/layers/render_line_layer.cpp4
-rw-r--r--src/mbgl/renderer/layers/render_line_layer.hpp3
-rw-r--r--src/mbgl/renderer/render_layer.cpp4
-rw-r--r--src/mbgl/renderer/render_layer.hpp7
-rw-r--r--src/mbgl/renderer/renderer_impl.cpp10
7 files changed, 26 insertions, 12 deletions
diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.cpp b/src/mbgl/renderer/layers/render_heatmap_layer.cpp
index 62330bcab7..4e5e890358 100644
--- a/src/mbgl/renderer/layers/render_heatmap_layer.cpp
+++ b/src/mbgl/renderer/layers/render_heatmap_layer.cpp
@@ -185,6 +185,10 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
}
}
+void RenderHeatmapLayer::update() {
+ updateColorRamp();
+}
+
void RenderHeatmapLayer::updateColorRamp() {
auto colorValue = unevaluated.get<HeatmapColor>().getValue();
if (colorValue.isUndefined()) {
diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.hpp b/src/mbgl/renderer/layers/render_heatmap_layer.hpp
index 6f8163ebf1..9aca8bdc93 100644
--- a/src/mbgl/renderer/layers/render_heatmap_layer.hpp
+++ b/src/mbgl/renderer/layers/render_heatmap_layer.hpp
@@ -18,6 +18,7 @@ public:
bool hasTransition() const override;
bool hasCrossfade() const override;
void render(PaintParameters&, RenderSource*) override;
+ void update() final;
bool queryIntersectsFeature(
const GeometryCoordinates&,
@@ -27,8 +28,6 @@ public:
const float,
const mat4&) const override;
- void updateColorRamp();
-
std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<const RenderLayer*>&) const override;
// Paint properties
@@ -40,6 +39,9 @@ public:
PremultipliedImage colorRamp;
optional<OffscreenTexture> renderTexture;
optional<gl::Texture> colorRampTexture;
+
+private:
+ void updateColorRamp();
};
template <>
diff --git a/src/mbgl/renderer/layers/render_line_layer.cpp b/src/mbgl/renderer/layers/render_line_layer.cpp
index 2811a1ffdd..1edd69237e 100644
--- a/src/mbgl/renderer/layers/render_line_layer.cpp
+++ b/src/mbgl/renderer/layers/render_line_layer.cpp
@@ -294,4 +294,8 @@ float RenderLineLayer::getLineWidth(const GeometryTileFeature& feature, const fl
}
+void RenderLineLayer::update() {
+ updateColorRamp();
+}
+
} // namespace mbgl
diff --git a/src/mbgl/renderer/layers/render_line_layer.hpp b/src/mbgl/renderer/layers/render_line_layer.hpp
index d7786ded34..cd657dfe16 100644
--- a/src/mbgl/renderer/layers/render_line_layer.hpp
+++ b/src/mbgl/renderer/layers/render_line_layer.hpp
@@ -32,6 +32,7 @@ public:
bool hasTransition() const override;
bool hasCrossfade() const override;
void render(PaintParameters&, RenderSource*) override;
+ void update() final;
RenderLinePaintProperties::PossiblyEvaluated paintProperties() const;
@@ -43,7 +44,6 @@ public:
const float,
const mat4&) const override;
- void updateColorRamp();
std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<const RenderLayer*>&) const override;
std::unique_ptr<Layout> createLayout(const BucketParameters&,
@@ -59,6 +59,7 @@ public:
private:
float getLineWidth(const GeometryTileFeature&, const float) const;
+ void updateColorRamp();
CrossfadeParameters crossfade;
PremultipliedImage colorRamp;
optional<gl::Texture> colorRampTexture;
diff --git a/src/mbgl/renderer/render_layer.cpp b/src/mbgl/renderer/render_layer.cpp
index 652dad0472..71c7c54834 100644
--- a/src/mbgl/renderer/render_layer.cpp
+++ b/src/mbgl/renderer/render_layer.cpp
@@ -86,6 +86,10 @@ void RenderLayer::sortRenderTiles(const TransformState&) {
std::sort(renderTiles.begin(), renderTiles.end(), [](const auto& a, const auto& b) { return a.get().id < b.get().id; });
}
+void RenderLayer::update() {
+ // no-op
+}
+
RenderLayer::RenderTiles RenderLayer::filterRenderTiles(RenderTiles tiles, FilterFunctionPtr filterFn) const {
assert(filterFn != nullptr);
RenderTiles filtered;
diff --git a/src/mbgl/renderer/render_layer.hpp b/src/mbgl/renderer/render_layer.hpp
index 04753fc674..dc7c58adeb 100644
--- a/src/mbgl/renderer/render_layer.hpp
+++ b/src/mbgl/renderer/render_layer.hpp
@@ -95,7 +95,14 @@ public:
void setImpl(Immutable<style::Layer::Impl>);
virtual void markContextDestroyed();
+
+ // TODO: Figure out how to remove this or whether layers other than
+ // RenderHeatmapLayer and RenderLineLayer need paint property updates,
+ // similar to color ramp. Temporarily moved to the base.
+ virtual void update();
+
friend std::string layoutKey(const RenderLayer&);
+
protected:
// Checks whether the current hardware can render this layer. If it can't, we'll show a warning
// in the console to inform the developer.
diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp
index 46ee0ca973..4c25104e43 100644
--- a/src/mbgl/renderer/renderer_impl.cpp
+++ b/src/mbgl/renderer/renderer_impl.cpp
@@ -15,7 +15,6 @@
#include <mbgl/renderer/layers/render_custom_layer.hpp>
#include <mbgl/renderer/layers/render_fill_extrusion_layer.hpp>
#include <mbgl/renderer/layers/render_fill_layer.hpp>
-#include <mbgl/renderer/layers/render_heatmap_layer.hpp>
#include <mbgl/renderer/layers/render_hillshade_layer.hpp>
#include <mbgl/renderer/style_diff.hpp>
#include <mbgl/renderer/query.hpp>
@@ -186,14 +185,7 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
if (layerAdded || layerChanged) {
layer.transition(transitionParameters);
-
- if (layer.is<RenderHeatmapLayer>()) {
- layer.as<RenderHeatmapLayer>()->updateColorRamp();
- }
-
- if (layer.is<RenderLineLayer>()) {
- layer.as<RenderLineLayer>()->updateColorRamp();
- }
+ layer.update();
}
if (layerAdded || layerChanged || zoomChanged || layer.hasTransition() || layer.hasCrossfade()) {