Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] No need for optional in map of VertexArrays
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Jul 11, 2017
1 parent b587e7b commit a28be5a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/mbgl/programs/program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ class Program {
.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(
Expand All @@ -80,7 +80,7 @@ class Program {
std::move(stencilMode),
std::move(colorMode),
allUniformValues,
*vertexArray,
vertexArrayIt->second,
Attributes::offsetBindings(allAttributeBindings, segment.vertexOffset),
indexBuffer,
segment.indexOffset,
Expand Down
3 changes: 1 addition & 2 deletions src/mbgl/programs/segment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <mbgl/gl/context.hpp>
#include <mbgl/gl/vertex_array.hpp>
#include <mbgl/util/optional.hpp>

#include <cstddef>
#include <vector>
Expand Down Expand Up @@ -35,7 +34,7 @@ class Segment {
// 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>
Expand Down
8 changes: 4 additions & 4 deletions src/mbgl/programs/symbol_program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,10 @@ class SymbolProgram {
.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(
Expand All @@ -337,7 +337,7 @@ class SymbolProgram {
std::move(stencilMode),
std::move(colorMode),
allUniformValues,
*vertexArray,
vertexArrayIt->second,
Attributes::offsetBindings(allAttributeBindings, segment.vertexOffset),
indexBuffer,
segment.indexOffset,
Expand Down

0 comments on commit a28be5a

Please sign in to comment.