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

Commit

Permalink
[core] shader program must always match bucket in render symbol layer
Browse files Browse the repository at this point in the history
Before this change, `RenderSymbolLayer` with updated style was trying to render
symbols using the previous bucket (with paint property binders that matched a previous program).
  • Loading branch information
pozdnyakov committed Jan 3, 2019
1 parent d3bb518 commit f2817a6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/mbgl/renderer/buckets/symbol_bucket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ namespace mbgl {
using namespace style;

SymbolBucket::SymbolBucket(style::SymbolLayoutProperties::PossiblyEvaluated layout_,
const std::map<std::string, std::pair<
std::map<std::string, std::pair<
style::IconPaintProperties::PossiblyEvaluated,
style::TextPaintProperties::PossiblyEvaluated>>& layerPaintProperties,
style::TextPaintProperties::PossiblyEvaluated>> layerPaintProperties,
const style::PropertyValue<float>& textSize,
const style::PropertyValue<float>& iconSize,
float zoom,
Expand All @@ -27,10 +27,11 @@ SymbolBucket::SymbolBucket(style::SymbolLayoutProperties::PossiblyEvaluated layo
sortFeaturesByY(sortFeaturesByY_),
bucketLeaderID(std::move(bucketName_)),
symbolInstances(std::move(symbolInstances_)),
paintProperties(std::move(layerPaintProperties)),
textSizeBinder(SymbolSizeBinder::create(zoom, textSize, TextSize::defaultValue())),
iconSizeBinder(SymbolSizeBinder::create(zoom, iconSize, IconSize::defaultValue())) {

for (const auto& pair : layerPaintProperties) {
for (const auto& pair : paintProperties) {
paintPropertyBinders.emplace(
std::piecewise_construct,
std::forward_as_tuple(pair.first),
Expand Down
6 changes: 5 additions & 1 deletion 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 : public Bucket {
public:
SymbolBucket(style::SymbolLayoutProperties::PossiblyEvaluated,
const std::map<std::string, std::pair<style::IconPaintProperties::PossiblyEvaluated, style::TextPaintProperties::PossiblyEvaluated>>&,
std::map<std::string, std::pair<style::IconPaintProperties::PossiblyEvaluated, style::TextPaintProperties::PossiblyEvaluated>>,
const style::PropertyValue<float>& textSize,
const style::PropertyValue<float>& iconSize,
float zoom,
Expand Down Expand Up @@ -76,6 +76,10 @@ class SymbolBucket : public Bucket {

std::vector<SymbolInstance> symbolInstances;

std::map<std::string, std::pair<
style::IconPaintProperties::PossiblyEvaluated,
style::TextPaintProperties::PossiblyEvaluated>> paintProperties;

std::map<std::string, std::pair<
SymbolIconProgram::PaintPropertyBinders,
SymbolSDFTextProgram::PaintPropertyBinders>> paintPropertyBinders;
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/renderer/layers/render_symbol_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {

if (bucket.hasIconData()) {
auto values = iconPropertyValues(layout);
auto paintPropertyValues = iconPaintProperties();
const auto& paintPropertyValues = bucket.paintProperties.at(getID()).first;

const bool alongLine = layout.get<SymbolPlacement>() != SymbolPlacementType::Point &&
layout.get<IconRotationAlignment>() == AlignmentType::Map;
Expand Down Expand Up @@ -214,7 +214,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
parameters.context.bindTexture(*geometryTile.glyphAtlasTexture, 0, gl::TextureFilter::Linear);

auto values = textPropertyValues(layout);
auto paintPropertyValues = textPaintProperties();
const auto& paintPropertyValues = bucket.paintProperties.at(getID()).second;

const bool alongLine = layout.get<SymbolPlacement>() != SymbolPlacementType::Point &&
layout.get<TextRotationAlignment>() == AlignmentType::Map;
Expand Down

0 comments on commit f2817a6

Please sign in to comment.