[core] No need for optional in map of VertexArrays

This commit is contained in:
John Firebaugh
2017-07-10 12:31:46 -07:00
parent cf83f117f0
commit 902d9442da
3 changed files with 9 additions and 10 deletions

View File

@@ -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,

View File

@@ -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>

View File

@@ -371,10 +371,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(
@@ -384,7 +384,7 @@ public:
std::move(stencilMode),
std::move(colorMode),
allUniformValues,
*vertexArray,
vertexArrayIt->second,
Attributes::offsetBindings(allAttributeBindings, segment.vertexOffset),
indexBuffer,
segment.indexOffset,