diff options
Diffstat (limited to 'src/mbgl/renderer/line_bucket.cpp')
-rw-r--r-- | src/mbgl/renderer/line_bucket.cpp | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/src/mbgl/renderer/line_bucket.cpp b/src/mbgl/renderer/line_bucket.cpp index 6921b364d8..50a70c0fd4 100644 --- a/src/mbgl/renderer/line_bucket.cpp +++ b/src/mbgl/renderer/line_bucket.cpp @@ -1,6 +1,8 @@ #include <mbgl/renderer/line_bucket.hpp> -#include <mbgl/style/layers/line_layer.hpp> #include <mbgl/renderer/painter.hpp> +#include <mbgl/style/layers/line_layer.hpp> +#include <mbgl/style/bucket_parameters.hpp> +#include <mbgl/style/layers/line_layer_impl.hpp> #include <mbgl/util/math.hpp> #include <mbgl/util/constants.hpp> @@ -10,19 +12,29 @@ namespace mbgl { using namespace style; -LineBucket::LineBucket(uint32_t overscaling_) : overscaling(overscaling_) { -} - -LineBucket::~LineBucket() { - // Do not remove. header file only contains forward definitions to unique pointers. +LineBucket::LineBucket(const BucketParameters& parameters, + const std::vector<const Layer*>& layers, + const style::LineLayoutProperties& layout_) + : layout(layout_.evaluate(PropertyEvaluationParameters(parameters.tileID.overscaledZ))), + overscaling(parameters.tileID.overscaleFactor()) { + for (const auto& layer : layers) { + paintPropertyBinders.emplace(layer->getID(), + LineProgram::PaintPropertyBinders( + layer->as<LineLayer>()->impl->paint.evaluated, + parameters.tileID.overscaledZ)); + } } -void LineBucket::addGeometry(const GeometryCollection& geometryCollection) { +void LineBucket::addFeature(const GeometryTileFeature& feature, + const GeometryCollection& geometryCollection) { for (auto& line : geometryCollection) { addGeometry(line); } -} + for (auto& pair : paintPropertyBinders) { + pair.second.populateVertexVectors(feature, vertices.vertexSize()); + } +} /* * Sharp corners cause dashed lines to tilt because the distance along the line @@ -383,7 +395,7 @@ void LineBucket::addCurrentVertex(const GeometryCoordinate& currentCoordinate, Point<double> extrude = normal; if (endLeft) extrude = extrude - (util::perp(normal) * endLeft); - vertices.emplace_back(LineAttributes::vertex(currentCoordinate, extrude, { round, false }, endLeft, distance * LINE_DISTANCE_SCALE)); + vertices.emplace_back(LineProgram::layoutVertex(currentCoordinate, extrude, { round, false }, endLeft, distance * LINE_DISTANCE_SCALE)); e3 = vertices.vertexSize() - 1 - startVertex; if (e1 >= 0 && e2 >= 0) { triangleStore.emplace_back(e1, e2, e3); @@ -394,7 +406,7 @@ void LineBucket::addCurrentVertex(const GeometryCoordinate& currentCoordinate, extrude = normal * -1.0; if (endRight) extrude = extrude - (util::perp(normal) * endRight); - vertices.emplace_back(LineAttributes::vertex(currentCoordinate, extrude, { round, true }, -endRight, distance * LINE_DISTANCE_SCALE)); + vertices.emplace_back(LineProgram::layoutVertex(currentCoordinate, extrude, { round, true }, -endRight, distance * LINE_DISTANCE_SCALE)); e3 = vertices.vertexSize() - 1 - startVertex; if (e1 >= 0 && e2 >= 0) { triangleStore.emplace_back(e1, e2, e3); @@ -419,7 +431,7 @@ void LineBucket::addPieSliceVertex(const GeometryCoordinate& currentVertex, std::size_t startVertex, std::vector<TriangleElement>& triangleStore) { Point<double> flippedExtrude = extrude * (lineTurnsLeft ? -1.0 : 1.0); - vertices.emplace_back(LineAttributes::vertex(currentVertex, flippedExtrude, { false, lineTurnsLeft }, 0, distance * LINE_DISTANCE_SCALE)); + vertices.emplace_back(LineProgram::layoutVertex(currentVertex, flippedExtrude, { false, lineTurnsLeft }, 0, distance * LINE_DISTANCE_SCALE)); e3 = vertices.vertexSize() - 1 - startVertex; if (e1 >= 0 && e2 >= 0) { triangleStore.emplace_back(e1, e2, e3); @@ -436,7 +448,10 @@ void LineBucket::upload(gl::Context& context) { vertexBuffer = context.createVertexBuffer(std::move(vertices)); indexBuffer = context.createIndexBuffer(std::move(triangles)); - // From now on, we're only going to render during the translucent pass. + for (auto& pair : paintPropertyBinders) { + pair.second.upload(context); + } + uploaded = true; } |