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

[core] SymbolBucket: use single map for paint properties data #13724

Merged
merged 1 commit into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/mbgl/layout/symbol_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,9 @@ void SymbolLayout::createBucket(const ImagePositions&, std::unique_ptr<FeatureIn
}
}

for (auto& pair : bucket->paintPropertyBinders) {
pair.second.first.populateVertexVectors(feature, bucket->icon.vertices.vertexSize(), {}, {});
pair.second.second.populateVertexVectors(feature, bucket->text.vertices.vertexSize(), {}, {});
for (auto& pair : bucket->paintProperties) {
pair.second.iconBinders.populateVertexVectors(feature, bucket->icon.vertices.vertexSize(), {}, {});
pair.second.textBinders.populateVertexVectors(feature, bucket->text.vertices.vertexSize(), {}, {});
}
}

Expand Down
22 changes: 11 additions & 11 deletions src/mbgl/renderer/buckets/symbol_bucket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace mbgl {
using namespace style;

SymbolBucket::SymbolBucket(style::SymbolLayoutProperties::PossiblyEvaluated layout_,
std::map<std::string, style::SymbolPaintProperties::PossiblyEvaluated> paintProperties_,
const std::map<std::string, style::SymbolPaintProperties::PossiblyEvaluated>& paintProperties_,
const style::PropertyValue<float>& textSize,
const style::PropertyValue<float>& iconSize,
float zoom,
Expand All @@ -24,18 +24,18 @@ SymbolBucket::SymbolBucket(style::SymbolLayoutProperties::PossiblyEvaluated layo
sortFeaturesByY(sortFeaturesByY_),
bucketLeaderID(std::move(bucketName_)),
symbolInstances(std::move(symbolInstances_)),
paintProperties(std::move(paintProperties_)),
textSizeBinder(SymbolSizeBinder::create(zoom, textSize, TextSize::defaultValue())),
iconSizeBinder(SymbolSizeBinder::create(zoom, iconSize, IconSize::defaultValue())) {

for (const auto& pair : paintProperties) {
paintPropertyBinders.emplace(
for (const auto& pair : paintProperties_) {
paintProperties.emplace(
std::piecewise_construct,
std::forward_as_tuple(pair.first),
std::forward_as_tuple(
std::piecewise_construct,
std::forward_as_tuple(RenderSymbolLayer::iconPaintProperties(pair.second), zoom),
std::forward_as_tuple(RenderSymbolLayer::textPaintProperties(pair.second), zoom)));
std::forward_as_tuple(PaintProperties {
pair.second,
{ RenderSymbolLayer::iconPaintProperties(pair.second), zoom },
{ RenderSymbolLayer::textPaintProperties(pair.second), zoom }
}));
}
}

Expand Down Expand Up @@ -110,9 +110,9 @@ void SymbolBucket::upload(gl::Context& context) {
}

if (!staticUploaded) {
for (auto& pair : paintPropertyBinders) {
pair.second.first.upload(context);
pair.second.second.upload(context);
for (auto& pair : paintProperties) {
pair.second.iconBinders.upload(context);
pair.second.textBinders.upload(context);
}
}

Expand Down
13 changes: 7 additions & 6 deletions src/mbgl/renderer/buckets/symbol_bucket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class PlacedSymbol {
class SymbolBucket final : public Bucket {
public:
SymbolBucket(style::SymbolLayoutProperties::PossiblyEvaluated,
std::map<std::string, style::SymbolPaintProperties::PossiblyEvaluated>,
const std::map<std::string, style::SymbolPaintProperties::PossiblyEvaluated>&,
const style::PropertyValue<float>& textSize,
const style::PropertyValue<float>& iconSize,
float zoom,
Expand Down Expand Up @@ -78,11 +78,12 @@ class SymbolBucket final : public Bucket {

std::vector<SymbolInstance> symbolInstances;

std::map<std::string, style::SymbolPaintProperties::PossiblyEvaluated> paintProperties;

std::map<std::string, std::pair<
SymbolIconProgram::PaintPropertyBinders,
SymbolSDFTextProgram::PaintPropertyBinders>> paintPropertyBinders;
struct PaintProperties {
style::SymbolPaintProperties::PossiblyEvaluated evaluated;
SymbolIconProgram::PaintPropertyBinders iconBinders;
SymbolSDFTextProgram::PaintPropertyBinders textBinders;
};
std::map<std::string, PaintProperties> paintProperties;

std::unique_ptr<SymbolSizeBinder> textSizeBinder;

Expand Down
16 changes: 9 additions & 7 deletions src/mbgl/renderer/layers/render_symbol_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
}
SymbolBucket& bucket = *bucket_;
assert(bucket.paintProperties.find(getID()) != bucket.paintProperties.end());
const auto& evaluated_ = bucket.paintProperties.at(getID());
const auto& bucketPaintProperties = bucket.paintProperties.at(getID());
const auto& evaluated_ = bucketPaintProperties.evaluated;
const auto& layout = bucket.layout;

auto draw = [&] (auto& program,
Expand Down Expand Up @@ -187,7 +188,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
bucket.icon,
bucket.iconSizeBinder,
values,
bucket.paintPropertyBinders.at(getID()).first,
bucketPaintProperties.iconBinders,
paintPropertyValues);
}

Expand All @@ -197,7 +198,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
bucket.icon,
bucket.iconSizeBinder,
values,
bucket.paintPropertyBinders.at(getID()).first,
bucketPaintProperties.iconBinders,
paintPropertyValues);
}
} else {
Expand All @@ -206,7 +207,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
bucket.icon,
bucket.iconSizeBinder,
values,
bucket.paintPropertyBinders.at(getID()).first,
bucketPaintProperties.iconBinders,
paintPropertyValues);
}
}
Expand Down Expand Up @@ -240,7 +241,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
bucket.text,
bucket.textSizeBinder,
values,
bucket.paintPropertyBinders.at(getID()).second,
bucketPaintProperties.textBinders,
paintPropertyValues);
}

Expand All @@ -250,7 +251,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
bucket.text,
bucket.textSizeBinder,
values,
bucket.paintPropertyBinders.at(getID()).second,
bucketPaintProperties.textBinders,
paintPropertyValues);
}
}
Expand Down Expand Up @@ -405,7 +406,8 @@ void RenderSymbolLayer::sortRenderTiles(const TransformState& state) {
}

void RenderSymbolLayer::updateBucketPaintProperties(Bucket* bucket) const {
static_cast<SymbolBucket*>(bucket)->paintProperties[getID()] = evaluated;
assert(bucket->supportsLayer(*baseImpl));
static_cast<SymbolBucket*>(bucket)->paintProperties.at(getID()).evaluated = evaluated;
}

} // namespace mbgl