summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-04-11 17:07:14 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-04-11 17:41:06 +0300
commit06bc2ea3c4c8232279b4398e8902199812f60f02 (patch)
treeaddd47c898bb5afdb4265cea9537024bd2bffec4
parent099e320b5b3081b29490c420b579eda921aaed82 (diff)
downloadqtlocation-mapboxgl-06bc2ea3c4c8232279b4398e8902199812f60f02.tar.gz
[core] Render layers use synchronized buckets and paint propertiesupstream/mikhail_sync_buckets_and_paint_properties
Actual for layers rendering the geometry tile data: line, fill, fill-extrusion, heatmap, circle, symbol (was updated in previous commits).
-rw-r--r--include/mbgl/style/layer_properties.hpp5
-rw-r--r--src/mbgl/renderer/layers/render_background_layer.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_circle_layer.cpp13
-rw-r--r--src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp42
-rw-r--r--src/mbgl/renderer/layers/render_fill_layer.cpp30
-rw-r--r--src/mbgl/renderer/layers/render_heatmap_layer.cpp11
-rw-r--r--src/mbgl/renderer/layers/render_line_layer.cpp14
-rw-r--r--src/mbgl/tile/tile.hpp1
8 files changed, 69 insertions, 49 deletions
diff --git a/include/mbgl/style/layer_properties.hpp b/include/mbgl/style/layer_properties.hpp
index 89d599dfbc..301a048e50 100644
--- a/include/mbgl/style/layer_properties.hpp
+++ b/include/mbgl/style/layer_properties.hpp
@@ -25,5 +25,10 @@ inline const auto& getEvaluated(const Immutable<LayerProperties>& properties) {
return static_cast<const Derived&>(*properties).evaluated;
}
+template <class Derived>
+inline const auto& getCrossfade(const Immutable<LayerProperties>& properties) {
+ return static_cast<const Derived&>(*properties).crossfade;
+}
+
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/renderer/layers/render_background_layer.cpp b/src/mbgl/renderer/layers/render_background_layer.cpp
index d5ba8c879f..3eb9bc2a30 100644
--- a/src/mbgl/renderer/layers/render_background_layer.cpp
+++ b/src/mbgl/renderer/layers/render_background_layer.cpp
@@ -45,7 +45,7 @@ bool RenderBackgroundLayer::hasTransition() const {
}
bool RenderBackgroundLayer::hasCrossfade() const {
- return static_cast<const BackgroundLayerProperties&>(*evaluatedProperties).crossfade.t != 1;
+ return getCrossfade<BackgroundLayerProperties>(evaluatedProperties).t != 1;
}
void RenderBackgroundLayer::render(PaintParameters& parameters, RenderSource*) {
diff --git a/src/mbgl/renderer/layers/render_circle_layer.cpp b/src/mbgl/renderer/layers/render_circle_layer.cpp
index 9df20cf874..a0531afaed 100644
--- a/src/mbgl/renderer/layers/render_circle_layer.cpp
+++ b/src/mbgl/renderer/layers/render_circle_layer.cpp
@@ -56,17 +56,16 @@ void RenderCircleLayer::render(PaintParameters& parameters, RenderSource*) {
if (parameters.pass == RenderPass::Opaque) {
return;
}
- const auto& evaluated = static_cast<const CircleLayerProperties&>(*evaluatedProperties).evaluated;
- const bool scaleWithMap = evaluated.get<CirclePitchScale>() == CirclePitchScaleType::Map;
- const bool pitchWithMap = evaluated.get<CirclePitchAlignment>() == AlignmentType::Map;
for (const RenderTile& tile : renderTiles) {
- auto bucket_ = tile.tile.getBucket<CircleBucket>(*baseImpl);
- if (!bucket_) {
+ const LayerRenderData* renderData = tile.tile.getLayerRenderData(*baseImpl);
+ if (!renderData) {
continue;
}
- CircleBucket& bucket = *bucket_;
-
+ auto& bucket = static_cast<CircleBucket&>(*renderData->bucket);
+ const auto& evaluated = getEvaluated<CircleLayerProperties>(renderData->layerProperties);
+ const bool scaleWithMap = evaluated.get<CirclePitchScale>() == CirclePitchScaleType::Map;
+ const bool pitchWithMap = evaluated.get<CirclePitchAlignment>() == AlignmentType::Map;
const auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID());
auto& programInstance = parameters.programs.getCircleLayerPrograms().circle;
diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
index a313f53f1c..c8fa8765de 100644
--- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
+++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
@@ -52,15 +52,13 @@ bool RenderFillExtrusionLayer::hasTransition() const {
}
bool RenderFillExtrusionLayer::hasCrossfade() const {
- return static_cast<const FillExtrusionLayerProperties&>(*evaluatedProperties).crossfade.t != 1;
+ return getCrossfade<FillExtrusionLayerProperties>(evaluatedProperties).t != 1;
}
void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource*) {
if (parameters.pass == RenderPass::Opaque) {
return;
}
- const auto& evaluated = static_cast<const FillExtrusionLayerProperties&>(*evaluatedProperties).evaluated;
- const auto& crossfade = static_cast<const FillExtrusionLayerProperties&>(*evaluatedProperties).crossfade;
if (parameters.pass == RenderPass::Pass3D) {
const auto& size = parameters.staticData.backendSize;
@@ -78,22 +76,27 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource*
"fill extrusion",
{ *renderTexture, Color{ 0.0f, 0.0f, 0.0f, 0.0f }, depthClearValue, {} });
- auto draw = [&](auto& programInstance, const auto& tileBucket, auto&& uniformValues,
+ auto draw = [&](auto& programInstance,
+ const auto& evaluated_,
+ const auto& crossfade_,
+ const auto& tileBucket,
+ auto&& uniformValues,
const optional<ImagePosition>& patternPositionA,
- const optional<ImagePosition>& patternPositionB, auto&& textureBindings) {
+ const optional<ImagePosition>& patternPositionB,
+ auto&& textureBindings) {
const auto& paintPropertyBinders = tileBucket.paintPropertyBinders.at(getID());
- paintPropertyBinders.setPatternParameters(patternPositionA, patternPositionB, crossfade);
+ paintPropertyBinders.setPatternParameters(patternPositionA, patternPositionB, crossfade_);
const auto allUniformValues = programInstance.computeAllUniformValues(
std::move(uniformValues),
paintPropertyBinders,
- evaluated,
+ evaluated_,
parameters.state.getZoom()
);
const auto allAttributeBindings = programInstance.computeAllAttributeBindings(
*tileBucket.vertexBuffer,
paintPropertyBinders,
- evaluated
+ evaluated_
);
checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings));
@@ -116,14 +119,17 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource*
if (unevaluated.get<FillExtrusionPattern>().isUndefined()) {
for (const RenderTile& tile : renderTiles) {
- auto bucket_ = tile.tile.getBucket<FillExtrusionBucket>(*baseImpl);
- if (!bucket_) {
+ const LayerRenderData* renderData = tile.tile.getLayerRenderData(*baseImpl);
+ if (!renderData) {
continue;
}
- FillExtrusionBucket& bucket = *bucket_;
-
+ auto& bucket = static_cast<FillExtrusionBucket&>(*renderData->bucket);
+ const auto& evaluated = getEvaluated<FillExtrusionLayerProperties>(renderData->layerProperties);
+ const auto& crossfade = getCrossfade<FillExtrusionLayerProperties>(renderData->layerProperties);
draw(
parameters.programs.getFillExtrusionLayerPrograms().fillExtrusion,
+ evaluated,
+ crossfade,
bucket,
FillExtrusionProgram::layoutUniformValues(
tile.translatedClipMatrix(evaluated.get<FillExtrusionTranslate>(),
@@ -139,18 +145,23 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource*
}
} else {
for (const RenderTile& tile : renderTiles) {
- auto bucket_ = tile.tile.getBucket<FillExtrusionBucket>(*baseImpl);
- if (!bucket_) {
+ const LayerRenderData* renderData = tile.tile.getLayerRenderData(*baseImpl);
+ if (!renderData) {
continue;
}
+ auto& bucket = static_cast<FillExtrusionBucket&>(*renderData->bucket);
+ const auto& evaluated = getEvaluated<FillExtrusionLayerProperties>(renderData->layerProperties);
+ const auto& crossfade = getCrossfade<FillExtrusionLayerProperties>(renderData->layerProperties);
+
const auto fillPatternValue = evaluated.get<FillExtrusionPattern>().constantOr(mbgl::Faded<std::basic_string<char> >{"", ""});
auto& geometryTile = static_cast<GeometryTile&>(tile.tile);
optional<ImagePosition> patternPosA = geometryTile.getPattern(fillPatternValue.from);
optional<ImagePosition> patternPosB = geometryTile.getPattern(fillPatternValue.to);
- FillExtrusionBucket& bucket = *bucket_;
draw(
parameters.programs.getFillExtrusionLayerPrograms().fillExtrusionPattern,
+ evaluated,
+ crossfade,
bucket,
FillExtrusionPatternProgram::layoutUniformValues(
tile.translatedClipMatrix(evaluated.get<FillExtrusionTranslate>(),
@@ -175,6 +186,7 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource*
} else if (parameters.pass == RenderPass::Translucent) {
const auto& size = parameters.staticData.backendSize;
+ const auto& evaluated = static_cast<const FillExtrusionLayerProperties&>(*evaluatedProperties).evaluated;
mat4 viewportMat;
matrix::ortho(viewportMat, 0, size.width, size.height, 0, 0, 1);
diff --git a/src/mbgl/renderer/layers/render_fill_layer.cpp b/src/mbgl/renderer/layers/render_fill_layer.cpp
index 5b0f020290..85ae12b9d9 100644
--- a/src/mbgl/renderer/layers/render_fill_layer.cpp
+++ b/src/mbgl/renderer/layers/render_fill_layer.cpp
@@ -68,19 +68,18 @@ bool RenderFillLayer::hasTransition() const {
}
bool RenderFillLayer::hasCrossfade() const {
- return static_cast<const FillLayerProperties&>(*evaluatedProperties).crossfade.t != 1;
+ return getCrossfade<FillLayerProperties>(evaluatedProperties).t != 1;
}
void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) {
- const auto& evaluated = static_cast<const FillLayerProperties&>(*evaluatedProperties).evaluated;
- const auto& crossfade = static_cast<const FillLayerProperties&>(*evaluatedProperties).crossfade;
if (unevaluated.get<FillPattern>().isUndefined()) {
for (const RenderTile& tile : renderTiles) {
- auto bucket_ = tile.tile.getBucket<FillBucket>(*baseImpl);
- if (!bucket_) {
+ const LayerRenderData* renderData = tile.tile.getLayerRenderData(*baseImpl);
+ if (!renderData) {
continue;
}
- FillBucket& bucket = *bucket_;
+ auto& bucket = static_cast<FillBucket&>(*renderData->bucket);
+ const auto& evaluated = getEvaluated<FillLayerProperties>(renderData->layerProperties);
auto draw = [&] (auto& programInstance,
const auto& drawMode,
@@ -157,18 +156,21 @@ void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) {
if (parameters.pass != RenderPass::Translucent) {
return;
}
- const auto fillPatternValue = evaluated.get<FillPattern>().constantOr(Faded<std::basic_string<char>>{"", ""});
+
for (const RenderTile& tile : renderTiles) {
+ const LayerRenderData* renderData = tile.tile.getLayerRenderData(*baseImpl);
+ if (!renderData) {
+ continue;
+ }
+ auto& bucket = static_cast<FillBucket&>(*renderData->bucket);
+ const auto& evaluated = getEvaluated<FillLayerProperties>(renderData->layerProperties);
+ const auto& crossfade = getCrossfade<FillLayerProperties>(renderData->layerProperties);
+
+ const auto& fillPatternValue = evaluated.get<FillPattern>().constantOr(Faded<std::basic_string<char>>{"", ""});
auto& geometryTile = static_cast<GeometryTile&>(tile.tile);
optional<ImagePosition> patternPosA = geometryTile.getPattern(fillPatternValue.from);
optional<ImagePosition> patternPosB = geometryTile.getPattern(fillPatternValue.to);
- auto bucket_ = tile.tile.getBucket<FillBucket>(*baseImpl);
- if (!bucket_) {
- continue;
- }
- FillBucket& bucket = *bucket_;
-
auto draw = [&] (auto& programInstance,
const auto& drawMode,
const auto& depthMode,
@@ -249,7 +251,7 @@ bool RenderFillLayer::queryIntersectsFeature(
const TransformState& transformState,
const float pixelsToTileUnits,
const mat4&) const {
- const auto& evaluated = static_cast<const FillLayerProperties&>(*evaluatedProperties).evaluated;
+ const auto& evaluated = getEvaluated<FillLayerProperties>(evaluatedProperties);
auto translatedQueryGeometry = FeatureIndex::translateQueryGeometry(
queryGeometry,
evaluated.get<style::FillTranslate>(),
diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.cpp b/src/mbgl/renderer/layers/render_heatmap_layer.cpp
index 83a989195b..1f3c179acc 100644
--- a/src/mbgl/renderer/layers/render_heatmap_layer.cpp
+++ b/src/mbgl/renderer/layers/render_heatmap_layer.cpp
@@ -59,7 +59,7 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
if (parameters.pass == RenderPass::Opaque) {
return;
}
- const auto& evaluated = static_cast<const HeatmapLayerProperties&>(*evaluatedProperties).evaluated;
+
if (parameters.pass == RenderPass::Pass3D) {
const auto& viewportSize = parameters.staticData.backendSize;
const auto size = Size{viewportSize.width / 4, viewportSize.height / 4};
@@ -89,11 +89,12 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
"heatmap texture", { *renderTexture, Color{ 0.0f, 0.0f, 0.0f, 1.0f }, {}, {} });
for (const RenderTile& tile : renderTiles) {
- auto bucket_ = tile.tile.getBucket<HeatmapBucket>(*baseImpl);
- if (!bucket_) {
+ const LayerRenderData* renderData = tile.tile.getLayerRenderData(*baseImpl);
+ if (!renderData) {
continue;
}
- HeatmapBucket& bucket = *bucket_;
+ auto& bucket = static_cast<HeatmapBucket&>(*renderData->bucket);
+ const auto& evaluated = getEvaluated<HeatmapLayerProperties>(renderData->layerProperties);
const auto extrudeScale = tile.id.pixelsToTileUnits(1, parameters.state.getZoom());
@@ -155,7 +156,7 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
HeatmapTextureProgram::LayoutUniformValues{
uniforms::matrix::Value( viewportMat ),
uniforms::world::Value( size ),
- uniforms::opacity::Value( evaluated.get<HeatmapOpacity>() )
+ uniforms::opacity::Value( getEvaluated<HeatmapLayerProperties>(evaluatedProperties).get<HeatmapOpacity>() )
},
paintAttributeData,
properties,
diff --git a/src/mbgl/renderer/layers/render_line_layer.cpp b/src/mbgl/renderer/layers/render_line_layer.cpp
index 2a7468ca1f..8fbe799f17 100644
--- a/src/mbgl/renderer/layers/render_line_layer.cpp
+++ b/src/mbgl/renderer/layers/render_line_layer.cpp
@@ -54,22 +54,22 @@ bool RenderLineLayer::hasTransition() const {
}
bool RenderLineLayer::hasCrossfade() const {
- return static_cast<const LineLayerProperties&>(*evaluatedProperties).crossfade.t != 1;
+ return getCrossfade<LineLayerProperties>(evaluatedProperties).t != 1;
}
void RenderLineLayer::render(PaintParameters& parameters, RenderSource*) {
if (parameters.pass == RenderPass::Opaque) {
return;
}
- const auto& evaluated = static_cast<const LineLayerProperties&>(*evaluatedProperties).evaluated;
- const auto& crossfade = static_cast<const LineLayerProperties&>(*evaluatedProperties).crossfade;
for (const RenderTile& tile : renderTiles) {
- auto bucket_ = tile.tile.getBucket<LineBucket>(*baseImpl);
- if (!bucket_) {
+ const LayerRenderData* renderData = tile.tile.getLayerRenderData(*baseImpl);
+ if (!renderData) {
continue;
}
- LineBucket& bucket = *bucket_;
+ auto& bucket = static_cast<LineBucket&>(*renderData->bucket);
+ const auto& evaluated = getEvaluated<LineLayerProperties>(renderData->layerProperties);
+ const auto& crossfade = getCrossfade<LineLayerProperties>(renderData->layerProperties);
auto draw = [&](auto& programInstance,
auto&& uniformValues,
@@ -134,7 +134,7 @@ void RenderLineLayer::render(PaintParameters& parameters, RenderSource*) {
});
} else if (!unevaluated.get<LinePattern>().isUndefined()) {
- const auto linePatternValue = evaluated.get<LinePattern>().constantOr(Faded<std::basic_string<char>>{ "", ""});
+ const auto& linePatternValue = evaluated.get<LinePattern>().constantOr(Faded<std::basic_string<char>>{ "", ""});
auto& geometryTile = static_cast<GeometryTile&>(tile.tile);
const Size texsize = geometryTile.iconAtlasTexture->size;
diff --git a/src/mbgl/tile/tile.hpp b/src/mbgl/tile/tile.hpp
index 651bafe277..c9b1af6beb 100644
--- a/src/mbgl/tile/tile.hpp
+++ b/src/mbgl/tile/tile.hpp
@@ -58,6 +58,7 @@ public:
virtual void upload(gfx::Context&) = 0;
virtual Bucket* getBucket(const style::Layer::Impl&) const = 0;
virtual const LayerRenderData* getLayerRenderData(const style::Layer::Impl&) const {
+ assert(false);
return nullptr;
}
// Updates the contained layer render data with the given properties.