summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-07-10 12:31:46 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-07-12 14:55:02 -0700
commit86ee821c6e8e6e68a984c65492523fdf94425ea7 (patch)
tree85d1cc46b9157e5aad18fa7c8def12ee0599f9a6
parent2691fe165d06e0cc015b28a52815e1b024472a97 (diff)
downloadqtlocation-mapboxgl-86ee821c6e8e6e68a984c65492523fdf94425ea7.tar.gz
[core] No need for optional in map of VertexArrays
-rw-r--r--src/mbgl/programs/program.hpp8
-rw-r--r--src/mbgl/programs/segment.hpp3
-rw-r--r--src/mbgl/programs/symbol_program.hpp8
3 files changed, 9 insertions, 10 deletions
diff --git a/src/mbgl/programs/program.hpp b/src/mbgl/programs/program.hpp
index 71d7569f53..bcdb270b9c 100644
--- a/src/mbgl/programs/program.hpp
+++ b/src/mbgl/programs/program.hpp
@@ -67,10 +67,10 @@ public:
.concat(paintPropertyBinders.attributeBindings(currentProperties));
for (auto& segment : segments) {
- optional<gl::VertexArray>& vertexArray = segment.vertexArrays[layerID];
+ auto vertexArrayIt = segment.vertexArrays.find(layerID);
- if (!vertexArray) {
- vertexArray = context.createVertexArray();
+ if (vertexArrayIt == segment.vertexArrays.end()) {
+ vertexArrayIt = segment.vertexArrays.emplace(layerID, context.createVertexArray()).first;
}
program.draw(
@@ -80,7 +80,7 @@ public:
std::move(stencilMode),
std::move(colorMode),
allUniformValues,
- *vertexArray,
+ vertexArrayIt->second,
Attributes::offsetBindings(allAttributeBindings, segment.vertexOffset),
indexBuffer,
segment.indexOffset,
diff --git a/src/mbgl/programs/segment.hpp b/src/mbgl/programs/segment.hpp
index ceb6b1536c..f729683ac9 100644
--- a/src/mbgl/programs/segment.hpp
+++ b/src/mbgl/programs/segment.hpp
@@ -2,7 +2,6 @@
#include <mbgl/gl/context.hpp>
#include <mbgl/gl/vertex_array.hpp>
-#include <mbgl/util/optional.hpp>
#include <cstddef>
#include <vector>
@@ -35,7 +34,7 @@ public:
// data-driven paint properties
// * when two fill layers have the same layout properties, but one
// uses fill-color and the other uses fill-pattern
- mutable std::map<std::string, optional<gl::VertexArray>> vertexArrays;
+ mutable std::map<std::string, gl::VertexArray> vertexArrays;
};
template <class Attributes>
diff --git a/src/mbgl/programs/symbol_program.hpp b/src/mbgl/programs/symbol_program.hpp
index ee4855cf8f..a7abf94f56 100644
--- a/src/mbgl/programs/symbol_program.hpp
+++ b/src/mbgl/programs/symbol_program.hpp
@@ -326,10 +326,10 @@ public:
.concat(paintPropertyBinders.attributeBindings(currentProperties));
for (auto& segment : segments) {
- optional<gl::VertexArray>& vertexArray = segment.vertexArrays[layerID];
+ auto vertexArrayIt = segment.vertexArrays.find(layerID);
- if (!vertexArray) {
- vertexArray = context.createVertexArray();
+ if (vertexArrayIt == segment.vertexArrays.end()) {
+ vertexArrayIt = segment.vertexArrays.emplace(layerID, context.createVertexArray()).first;
}
program.draw(
@@ -339,7 +339,7 @@ public:
std::move(stencilMode),
std::move(colorMode),
allUniformValues,
- *vertexArray,
+ vertexArrayIt->second,
Attributes::offsetBindings(allAttributeBindings, segment.vertexOffset),
indexBuffer,
segment.indexOffset,