summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2019-05-17 07:11:43 +0300
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2019-05-17 17:58:54 +0300
commit46d5f5e699388ebd46dcb36ab0d53c5466cb9729 (patch)
tree854db61d01f3b1fd671f7dd114b8fdab002ef6e1
parenta0467ca76de259f372cf9360ea403d07276e4008 (diff)
downloadqtlocation-mapboxgl-upstream/alexshalamov_fix_for_14518.tar.gz
[core] Check if pattern dependencies or pattern positions are missingupstream/alexshalamov_fix_for_14518
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.hpp26
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>>{{}, {}};
}
}