diff options
author | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-05-17 07:11:43 +0300 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-05-20 01:19:04 -0700 |
commit | 521ac5c9938fa9a8c14823cd421ed0a13cf8ff40 (patch) | |
tree | b19e2407e4fe78ecd0d5b65108db94b88d7ff208 | |
parent | 9fe5256ce7121e28572239757df63a7c20144be5 (diff) | |
download | qtlocation-mapboxgl-521ac5c9938fa9a8c14823cd421ed0a13cf8ff40.tar.gz |
[core] Check if pattern dependencies or pattern positions are missing
Add check for optional pattern dependencies and don't bind empty vertex
buffers if pattern positions are missing.
-rw-r--r-- | src/mbgl/renderer/paint_property_binder.hpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/mbgl/renderer/paint_property_binder.hpp b/src/mbgl/renderer/paint_property_binder.hpp index 5cd75645f4..63d821f964 100644 --- a/src/mbgl/renderer/paint_property_binder.hpp +++ b/src/mbgl/renderer/paint_property_binder.hpp @@ -324,7 +324,7 @@ public: void populateVertexVector(const GeometryTileFeature&, std::size_t length, const ImagePositions& patternPositions, const optional<PatternDependency>& patternDependencies, const style::expression::Value&) override { - if (patternDependencies->mid.empty()) { + if (!patternDependencies || patternDependencies->mid.empty()) { // Unlike other propperties with expressions that evaluate to null, the default value for `*-pattern` properties is an empty // string and will not have a valid entry in patternPositions. We still need to populate the attribute buffers to avoid crashes // when we try to draw the layer because we don't know at draw time if all features were evaluated to valid pattern dependencies. @@ -354,19 +354,29 @@ public: } void upload(gfx::UploadPass& uploadPass) override { - patternToVertexBuffer = uploadPass.createVertexBuffer(std::move(patternToVertexVector)); - zoomInVertexBuffer = uploadPass.createVertexBuffer(std::move(zoomInVertexVector)); - zoomOutVertexBuffer = uploadPass.createVertexBuffer(std::move(zoomOutVertexVector)); + if (!patternToVertexVector.empty()) { + assert(!zoomInVertexVector.empty()); + assert(!zoomOutVertexVector.empty()); + patternToVertexBuffer = uploadPass.createVertexBuffer(std::move(patternToVertexVector)); + zoomInVertexBuffer = uploadPass.createVertexBuffer(std::move(zoomInVertexVector)); + zoomOutVertexBuffer = uploadPass.createVertexBuffer(std::move(zoomOutVertexVector)); + } } std::tuple<optional<gfx::AttributeBinding>, optional<gfx::AttributeBinding>> attributeBinding(const PossiblyEvaluatedPropertyValue<Faded<T>>& currentValue) const override { if (currentValue.isConstant()) { return {}; } else { - return std::tuple<optional<gfx::AttributeBinding>, optional<gfx::AttributeBinding>>{ - gfx::attributeBinding(*patternToVertexBuffer), - gfx::attributeBinding(crossfade.fromScale == 2 ? *zoomInVertexBuffer : *zoomOutVertexBuffer) - }; + if (patternToVertexBuffer) { + assert(zoomInVertexBuffer); + assert(zoomOutVertexBuffer); + return std::tuple<optional<gfx::AttributeBinding>, optional<gfx::AttributeBinding>>{ + gfx::attributeBinding(*patternToVertexBuffer), + gfx::attributeBinding(crossfade.fromScale == 2 ? *zoomInVertexBuffer : *zoomOutVertexBuffer) + }; + } + + return std::tuple<optional<gfx::AttributeBinding>, optional<gfx::AttributeBinding>>{{}, {}}; } } |