[core] Use style::LayerProperties in render layers, buckets and layouts.
This commit is contained in:
@@ -8,7 +8,7 @@ class CircleLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
const style::LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<const RenderLayer*>&) noexcept final;
|
||||
std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<Immutable<style::LayerProperties>>&) noexcept final;
|
||||
std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
|
||||
};
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ class FillExtrusionLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
const style::LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<Layout> createLayout(const LayoutParameters&, std::unique_ptr<GeometryTileLayer>, const std::vector<const RenderLayer*>&) noexcept final;
|
||||
std::unique_ptr<Layout> createLayout(const LayoutParameters&, std::unique_ptr<GeometryTileLayer>, const std::vector<Immutable<style::LayerProperties>>&) noexcept final;
|
||||
std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
|
||||
};
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ class FillLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
const style::LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<Layout> createLayout(const LayoutParameters&, std::unique_ptr<GeometryTileLayer>, const std::vector<const RenderLayer*>&) noexcept final;
|
||||
std::unique_ptr<Layout> createLayout(const LayoutParameters&, std::unique_ptr<GeometryTileLayer>, const std::vector<Immutable<style::LayerProperties>>&) noexcept final;
|
||||
std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
|
||||
};
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ class HeatmapLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
const style::LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<const RenderLayer*>&) noexcept final;
|
||||
std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<Immutable<style::LayerProperties>>&) noexcept final;
|
||||
std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
|
||||
};
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
namespace style {
|
||||
class LayerProperties;
|
||||
} // namespace style
|
||||
class Bucket;
|
||||
class BucketParameters;
|
||||
class GeometryTileLayer;
|
||||
@@ -28,9 +31,9 @@ public:
|
||||
/// Returns a new RenderLayer instance.
|
||||
virtual std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept = 0;
|
||||
/// Returns a new Bucket instance on success call; returns `nullptr` otherwise.
|
||||
virtual std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<const RenderLayer*>&) noexcept;
|
||||
virtual std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<Immutable<style::LayerProperties>>&) noexcept;
|
||||
/// Returns a new Layout instance on success call; returns `nullptr` otherwise.
|
||||
virtual std::unique_ptr<Layout> createLayout(const LayoutParameters&, std::unique_ptr<GeometryTileLayer>, const std::vector<const RenderLayer*>&) noexcept;
|
||||
virtual std::unique_ptr<Layout> createLayout(const LayoutParameters&, std::unique_ptr<GeometryTileLayer>, const std::vector<Immutable<style::LayerProperties>>&) noexcept;
|
||||
|
||||
protected:
|
||||
optional<std::string> getSource(const style::conversion::Convertible& value) const noexcept;
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
#include <vector>
|
||||
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
class LayerProperties;
|
||||
} // namespace style
|
||||
class GeometryTileLayer;
|
||||
class LayerFactory;
|
||||
class RenderLayer;
|
||||
@@ -37,9 +40,10 @@ public:
|
||||
/// Returns a new RenderLayer instance on success call; returns `nullptr` otherwise.
|
||||
std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept;
|
||||
/// Returns a new Bucket instance on success call; returns `nullptr` otherwise.
|
||||
std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<const RenderLayer*>&) noexcept;
|
||||
std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<Immutable<style::LayerProperties>>&) noexcept;
|
||||
/// Returns a new Layout instance on success call; returns `nullptr` otherwise.
|
||||
std::unique_ptr<Layout> createLayout(const LayoutParameters&, std::unique_ptr<GeometryTileLayer>, const std::vector<const RenderLayer*>&) noexcept;
|
||||
std::unique_ptr<Layout> createLayout(const LayoutParameters&, std::unique_ptr<GeometryTileLayer>,
|
||||
const std::vector<Immutable<style::LayerProperties>>&) noexcept;
|
||||
|
||||
/**
|
||||
* @brief a build-time flag to enable/disable annotations in mapbox-gl-native core.
|
||||
|
||||
@@ -10,7 +10,7 @@ protected:
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<Layout> createLayout(const LayoutParameters& parameters,
|
||||
std::unique_ptr<GeometryTileLayer> tileLayer,
|
||||
const std::vector<const RenderLayer*>& group) noexcept final;
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) noexcept final;
|
||||
std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ protected:
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
|
||||
std::unique_ptr<Layout> createLayout(const LayoutParameters& parameters,
|
||||
std::unique_ptr<GeometryTileLayer> tileLayer,
|
||||
const std::vector<const RenderLayer*>& group) noexcept final;
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) noexcept final;
|
||||
std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ std::unique_ptr<style::Layer> CircleLayerFactory::createLayer(const std::string&
|
||||
return layer;
|
||||
}
|
||||
|
||||
std::unique_ptr<Bucket> CircleLayerFactory::createBucket(const BucketParameters& parameters, const std::vector<const RenderLayer*>& layers) noexcept {
|
||||
std::unique_ptr<Bucket> CircleLayerFactory::createBucket(const BucketParameters& parameters, const std::vector<Immutable<style::LayerProperties>>& layers) noexcept {
|
||||
return std::make_unique<CircleBucket>(parameters, layers);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,10 @@ std::unique_ptr<style::Layer> FillExtrusionLayerFactory::createLayer(const std::
|
||||
|
||||
std::unique_ptr<Layout> FillExtrusionLayerFactory::createLayout(const LayoutParameters& parameters,
|
||||
std::unique_ptr<GeometryTileLayer> layer,
|
||||
const std::vector<const RenderLayer*>& group) noexcept {
|
||||
return std::make_unique<PatternLayout<FillExtrusionBucket>>(parameters.bucketParameters, group, std::move(layer), parameters.imageDependencies);
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) noexcept {
|
||||
using namespace style;
|
||||
using LayoutType = PatternLayout<FillExtrusionBucket, FillExtrusionLayerProperties, FillExtrusionPattern, FillExtrusionPaintProperties::PossiblyEvaluated>;
|
||||
return std::make_unique<LayoutType>(parameters.bucketParameters, group, std::move(layer), parameters.imageDependencies);
|
||||
}
|
||||
|
||||
std::unique_ptr<RenderLayer> FillExtrusionLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
|
||||
|
||||
@@ -27,8 +27,10 @@ std::unique_ptr<style::Layer> FillLayerFactory::createLayer(const std::string& i
|
||||
std::unique_ptr<Layout>
|
||||
FillLayerFactory::createLayout(const LayoutParameters& parameters,
|
||||
std::unique_ptr<GeometryTileLayer> layer,
|
||||
const std::vector<const RenderLayer*>& group) noexcept {
|
||||
return std::make_unique<PatternLayout<FillBucket>>(parameters.bucketParameters, group, std::move(layer), parameters.imageDependencies);
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) noexcept {
|
||||
using namespace style;
|
||||
using LayoutType = PatternLayout<FillBucket, FillLayerProperties, FillPattern, FillPaintProperties::PossiblyEvaluated>;
|
||||
return std::make_unique<LayoutType>(parameters.bucketParameters, group, std::move(layer), parameters.imageDependencies);
|
||||
}
|
||||
|
||||
std::unique_ptr<RenderLayer> FillLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
|
||||
|
||||
@@ -24,7 +24,7 @@ std::unique_ptr<style::Layer> HeatmapLayerFactory::createLayer(const std::string
|
||||
return layer;
|
||||
}
|
||||
|
||||
std::unique_ptr<Bucket> HeatmapLayerFactory::createBucket(const BucketParameters& parameters, const std::vector<const RenderLayer*>& layers) noexcept {
|
||||
std::unique_ptr<Bucket> HeatmapLayerFactory::createBucket(const BucketParameters& parameters, const std::vector<Immutable<style::LayerProperties>>& layers) noexcept {
|
||||
return std::make_unique<HeatmapBucket>(parameters, layers);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,12 +25,14 @@ optional<std::string> LayerFactory::getSource(const style::conversion::Convertib
|
||||
return source;
|
||||
}
|
||||
|
||||
std::unique_ptr<Bucket> LayerFactory::createBucket(const BucketParameters&, const std::vector<const RenderLayer*>&) noexcept {
|
||||
std::unique_ptr<Bucket> LayerFactory::createBucket(const BucketParameters&, const std::vector<Immutable<style::LayerProperties>>&) noexcept {
|
||||
assert(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<Layout> LayerFactory::createLayout(const LayoutParameters&, std::unique_ptr<GeometryTileLayer>, const std::vector<const RenderLayer*>&) noexcept {
|
||||
std::unique_ptr<Layout> LayerFactory::createLayout(const LayoutParameters&,
|
||||
std::unique_ptr<GeometryTileLayer>,
|
||||
const std::vector<Immutable<style::LayerProperties>>&) noexcept {
|
||||
assert(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@ std::unique_ptr<style::Layer> LayerManager::createLayer(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<Bucket> LayerManager::createBucket(const BucketParameters& parameters, const std::vector<const RenderLayer*>& layers) noexcept {
|
||||
std::unique_ptr<Bucket> LayerManager::createBucket(const BucketParameters& parameters,
|
||||
const std::vector<Immutable<style::LayerProperties>>& layers) noexcept {
|
||||
assert(!layers.empty());
|
||||
assert(parameters.layerType->layout == style::LayerTypeInfo::Layout::NotRequired);
|
||||
LayerFactory* factory = getFactory(parameters.layerType);
|
||||
@@ -35,7 +36,7 @@ std::unique_ptr<Bucket> LayerManager::createBucket(const BucketParameters& param
|
||||
|
||||
std::unique_ptr<Layout> LayerManager::createLayout(const LayoutParameters& parameters,
|
||||
std::unique_ptr<GeometryTileLayer> tileLayer,
|
||||
const std::vector<const RenderLayer*>& layers) noexcept {
|
||||
const std::vector<Immutable<style::LayerProperties>>& layers) noexcept {
|
||||
assert(!layers.empty());
|
||||
assert(parameters.bucketParameters.layerType->layout == style::LayerTypeInfo::Layout::Required);
|
||||
LayerFactory* factory = getFactory(parameters.bucketParameters.layerType);
|
||||
|
||||
@@ -26,8 +26,10 @@ std::unique_ptr<style::Layer> LineLayerFactory::createLayer(const std::string& i
|
||||
|
||||
std::unique_ptr<Layout> LineLayerFactory::createLayout(const LayoutParameters& parameters,
|
||||
std::unique_ptr<GeometryTileLayer> layer,
|
||||
const std::vector<const RenderLayer*>& group) noexcept {
|
||||
return std::make_unique<PatternLayout<LineBucket>>(parameters.bucketParameters, group, std::move(layer), parameters.imageDependencies);
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) noexcept {
|
||||
using namespace style;
|
||||
using LayoutType = PatternLayout<LineBucket, LineLayerProperties, LinePattern, LinePaintProperties::PossiblyEvaluated, LineLayoutProperties::PossiblyEvaluated>;
|
||||
return std::make_unique<LayoutType>(parameters.bucketParameters, group, std::move(layer), parameters.imageDependencies);
|
||||
}
|
||||
|
||||
std::unique_ptr<RenderLayer> LineLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
|
||||
|
||||
@@ -26,7 +26,7 @@ std::unique_ptr<style::Layer> SymbolLayerFactory::createLayer(const std::string&
|
||||
|
||||
std::unique_ptr<Layout> SymbolLayerFactory::createLayout(const LayoutParameters& parameters,
|
||||
std::unique_ptr<GeometryTileLayer> tileLayer,
|
||||
const std::vector<const RenderLayer*>& group) noexcept {
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) noexcept {
|
||||
return std::make_unique<SymbolLayout>(parameters.bucketParameters,
|
||||
group,
|
||||
std::move(tileLayer),
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <mbgl/renderer/bucket_parameters.hpp>
|
||||
#include <mbgl/geometry/feature_index.hpp>
|
||||
#include <mbgl/renderer/render_layer.hpp>
|
||||
#include <mbgl/style/layer_properties.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -22,31 +23,32 @@ public:
|
||||
PatternLayerMap patterns;
|
||||
};
|
||||
|
||||
template <class B>
|
||||
template <class BucketType,
|
||||
class LayerPropertiesType,
|
||||
class PatternPropertyType,
|
||||
class PossiblyEvaluatedPaintPropertiesType,
|
||||
class PossiblyEvaluatedLayoutPropertiesType = typename style::Properties<>::PossiblyEvaluated>
|
||||
class PatternLayout : public Layout {
|
||||
public:
|
||||
PatternLayout(const BucketParameters& parameters,
|
||||
const std::vector<const RenderLayer*>& layers,
|
||||
const std::vector<Immutable<style::LayerProperties>>& group,
|
||||
std::unique_ptr<GeometryTileLayer> sourceLayer_,
|
||||
ImageDependencies& patternDependencies)
|
||||
: Layout(),
|
||||
bucketLeaderID(layers.at(0)->getID()),
|
||||
sourceLayer(std::move(sourceLayer_)),
|
||||
: sourceLayer(std::move(sourceLayer_)),
|
||||
zoom(parameters.tileID.overscaledZ),
|
||||
overscaling(parameters.tileID.overscaleFactor()),
|
||||
hasPattern(false) {
|
||||
assert(!group.empty());
|
||||
auto leaderLayerProperties = staticImmutableCast<LayerPropertiesType>(group.front());
|
||||
layout = leaderLayerProperties->layerImpl().layout.evaluate(PropertyEvaluationParameters(zoom));
|
||||
sourceLayerID = leaderLayerProperties->layerImpl().sourceLayer;
|
||||
bucketLeaderID = leaderLayerProperties->layerImpl().id;
|
||||
|
||||
using PatternLayer = typename B::RenderLayerType;
|
||||
const auto renderLayer = static_cast<const PatternLayer*>(layers.at(0));
|
||||
const typename PatternLayer::StyleLayerImpl& leader = renderLayer->impl();
|
||||
layout = leader.layout.evaluate(PropertyEvaluationParameters(zoom));
|
||||
sourceLayerID = leader.sourceLayer;
|
||||
groupID = renderLayer->getID();
|
||||
|
||||
for (const auto& layer : layers) {
|
||||
const typename B::PossiblyEvaluatedPaintProperties evaluatedProps = static_cast<const PatternLayer*>(layer)->evaluated;
|
||||
const auto patternProperty = evaluatedProps.template get<typename PatternLayer::PatternProperty>();
|
||||
const auto constantPattern = patternProperty.constantOr({ "", "" });
|
||||
for (const auto& layerProperties : group) {
|
||||
const std::string& layerId = layerProperties->baseImpl->id;
|
||||
const auto evaluatedProps = static_cast<const LayerPropertiesType&>(*layerProperties).evaluated;
|
||||
const auto patternProperty = evaluatedProps.template get<PatternPropertyType>();
|
||||
const auto constantPattern = patternProperty.constantOr(Faded<std::basic_string<char> >{ "", ""});
|
||||
// determine if layer group has any layers that use *-pattern property and add
|
||||
// constant pattern dependencies.
|
||||
if (!patternProperty.isConstant()) {
|
||||
@@ -56,33 +58,34 @@ public:
|
||||
patternDependencies.emplace(constantPattern.to, ImageType::Pattern);
|
||||
patternDependencies.emplace(constantPattern.from, ImageType::Pattern);
|
||||
}
|
||||
layerPaintProperties.emplace(layer->getID(), std::move(evaluatedProps));
|
||||
layerPaintProperties.emplace(layerId, std::move(evaluatedProps));
|
||||
}
|
||||
|
||||
const size_t featureCount = sourceLayer->featureCount();
|
||||
for (size_t i = 0; i < featureCount; ++i) {
|
||||
auto feature = sourceLayer->getFeature(i);
|
||||
if (!leader.filter(style::expression::EvaluationContext { this->zoom, feature.get() }))
|
||||
if (!leaderLayerProperties->layerImpl().filter(style::expression::EvaluationContext { this->zoom, feature.get() }))
|
||||
continue;
|
||||
|
||||
PatternLayerMap patternDependencyMap;
|
||||
if (hasPattern) {
|
||||
for (const auto& layer : layers) {
|
||||
const auto it = layerPaintProperties.find(layer->getID());
|
||||
for (const auto& layerProperties : group) {
|
||||
const std::string& layerId = layerProperties->baseImpl->id;
|
||||
const auto it = layerPaintProperties.find(layerId);
|
||||
if (it != layerPaintProperties.end()) {
|
||||
const auto paint = it->second;
|
||||
const auto patternProperty = paint.template get<typename PatternLayer::PatternProperty>();
|
||||
const auto patternProperty = paint.template get<PatternPropertyType>();
|
||||
if (!patternProperty.isConstant()) {
|
||||
// For layers with non-data-constant pattern properties, evaluate their expression and add
|
||||
// the patterns to the dependency vector
|
||||
const auto min = patternProperty.evaluate(*feature, zoom - 1, PatternLayer::PatternProperty::defaultValue());
|
||||
const auto mid = patternProperty.evaluate(*feature, zoom, PatternLayer::PatternProperty::defaultValue());
|
||||
const auto max = patternProperty.evaluate(*feature, zoom + 1, PatternLayer::PatternProperty::defaultValue());
|
||||
const auto min = patternProperty.evaluate(*feature, zoom - 1, PatternPropertyType::defaultValue());
|
||||
const auto mid = patternProperty.evaluate(*feature, zoom, PatternPropertyType::defaultValue());
|
||||
const auto max = patternProperty.evaluate(*feature, zoom + 1, PatternPropertyType::defaultValue());
|
||||
|
||||
patternDependencies.emplace(min.to, ImageType::Pattern);
|
||||
patternDependencies.emplace(mid.to, ImageType::Pattern);
|
||||
patternDependencies.emplace(max.to, ImageType::Pattern);
|
||||
patternDependencyMap.emplace(layer->getID(), PatternDependency {min.to, mid.to, max.to});
|
||||
patternDependencyMap.emplace(layerId, PatternDependency {min.to, mid.to, max.to});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -99,15 +102,15 @@ public:
|
||||
}
|
||||
|
||||
void createBucket(const ImagePositions& patternPositions, std::unique_ptr<FeatureIndex>& featureIndex, std::unordered_map<std::string, std::shared_ptr<Bucket>>& buckets, const bool, const bool) override {
|
||||
auto bucket = std::make_shared<B>(layout, layerPaintProperties, zoom, overscaling);
|
||||
auto bucket = std::make_shared<BucketType>(layout, layerPaintProperties, zoom, overscaling);
|
||||
for (auto & patternFeature : features) {
|
||||
const auto i = patternFeature.i;
|
||||
std::unique_ptr<GeometryTileFeature> feature = std::move(patternFeature.feature);
|
||||
PatternLayerMap patterns = patternFeature.patterns;
|
||||
const PatternLayerMap& patterns = patternFeature.patterns;
|
||||
GeometryCollection geometries = feature->getGeometries();
|
||||
|
||||
bucket->addFeature(*feature, geometries, patternPositions, patterns);
|
||||
featureIndex->insert(geometries, i, sourceLayerID, groupID);
|
||||
featureIndex->insert(geometries, i, sourceLayerID, bucketLeaderID);
|
||||
}
|
||||
if (bucket->hasData()) {
|
||||
for (const auto& pair : layerPaintProperties) {
|
||||
@@ -116,19 +119,18 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
std::map<std::string, typename B::PossiblyEvaluatedPaintProperties> layerPaintProperties;
|
||||
const std::string bucketLeaderID;
|
||||
std::map<std::string, PossiblyEvaluatedPaintPropertiesType> layerPaintProperties;
|
||||
std::string bucketLeaderID;
|
||||
|
||||
|
||||
private:
|
||||
const std::unique_ptr<GeometryTileLayer> sourceLayer;
|
||||
std::vector<PatternFeature> features;
|
||||
typename B::PossiblyEvaluatedLayoutProperties layout;
|
||||
PossiblyEvaluatedLayoutPropertiesType layout;
|
||||
|
||||
const float zoom;
|
||||
const uint32_t overscaling;
|
||||
std::string sourceLayerID;
|
||||
std::string groupID;
|
||||
bool hasPattern;
|
||||
};
|
||||
|
||||
|
||||
@@ -40,16 +40,18 @@ expression::Value sectionOptionsToValue(const SectionOptions& options) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
inline const SymbolLayerProperties& toSymbolLayerProperties(const Immutable<LayerProperties>& layer) {
|
||||
return static_cast<const SymbolLayerProperties&>(*layer);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
SymbolLayout::SymbolLayout(const BucketParameters& parameters,
|
||||
const std::vector<const RenderLayer*>& layers,
|
||||
const std::vector<Immutable<style::LayerProperties>>& layers,
|
||||
std::unique_ptr<GeometryTileLayer> sourceLayer_,
|
||||
ImageDependencies& imageDependencies,
|
||||
GlyphDependencies& glyphDependencies)
|
||||
: Layout(),
|
||||
bucketLeaderID(layers.at(0)->getID()),
|
||||
: bucketLeaderID(layers.front()->baseImpl->id),
|
||||
sourceLayer(std::move(sourceLayer_)),
|
||||
overscaling(parameters.tileID.overscaleFactor()),
|
||||
zoom(parameters.tileID.overscaledZ),
|
||||
@@ -57,11 +59,11 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters,
|
||||
pixelRatio(parameters.pixelRatio),
|
||||
tileSize(util::tileSize * overscaling),
|
||||
tilePixelRatio(float(util::EXTENT) / tileSize),
|
||||
textSize(toRenderSymbolLayer(layers.at(0))->impl().layout.get<TextSize>()),
|
||||
iconSize(toRenderSymbolLayer(layers.at(0))->impl().layout.get<IconSize>())
|
||||
textSize(toSymbolLayerProperties(layers.at(0)).layerImpl().layout.get<TextSize>()),
|
||||
iconSize(toSymbolLayerProperties(layers.at(0)).layerImpl().layout.get<IconSize>())
|
||||
{
|
||||
|
||||
const SymbolLayer::Impl& leader = toRenderSymbolLayer(layers.at(0))->impl();
|
||||
const SymbolLayer::Impl& leader = toSymbolLayerProperties(layers.at(0)).layerImpl();
|
||||
|
||||
layout = leader.layout.evaluate(PropertyEvaluationParameters(zoom));
|
||||
|
||||
@@ -104,7 +106,7 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters,
|
||||
layout.get<TextIgnorePlacement>() || layout.get<IconIgnorePlacement>());
|
||||
|
||||
for (const auto& layer : layers) {
|
||||
layerPaintProperties.emplace(layer->getID(), toRenderSymbolLayer(layer)->evaluated);
|
||||
layerPaintProperties.emplace(layer->baseImpl->id, toSymbolLayerProperties(layer).evaluated);
|
||||
}
|
||||
|
||||
// Determine glyph dependencies
|
||||
|
||||
@@ -16,7 +16,6 @@ namespace mbgl {
|
||||
|
||||
class BucketParameters;
|
||||
class Anchor;
|
||||
class RenderLayer;
|
||||
class PlacedSymbol;
|
||||
|
||||
namespace style {
|
||||
@@ -26,7 +25,7 @@ class Filter;
|
||||
class SymbolLayout final : public Layout {
|
||||
public:
|
||||
SymbolLayout(const BucketParameters&,
|
||||
const std::vector<const RenderLayer*>&,
|
||||
const std::vector<Immutable<style::LayerProperties>>&,
|
||||
std::unique_ptr<GeometryTileLayer>,
|
||||
ImageDependencies&,
|
||||
GlyphDependencies&);
|
||||
|
||||
@@ -31,9 +31,6 @@ public:
|
||||
const ImagePositions&,
|
||||
const PatternLayerMap&) {};
|
||||
|
||||
virtual void populateFeatureBuffers(const ImagePositions&) {};
|
||||
virtual void addPatternDependencies(const std::vector<const RenderLayer*>&, ImageDependencies&) {};
|
||||
|
||||
// As long as this bucket has a Prepare render pass, this function is getting called. Typically,
|
||||
// this only happens once when the bucket is being rendered for the first time.
|
||||
virtual void upload(gfx::Context&) = 0;
|
||||
|
||||
@@ -10,14 +10,14 @@ namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
CircleBucket::CircleBucket(const BucketParameters& parameters, const std::vector<const RenderLayer*>& layers)
|
||||
CircleBucket::CircleBucket(const BucketParameters& parameters, const std::vector<Immutable<style::LayerProperties>>& layers)
|
||||
: mode(parameters.mode) {
|
||||
for (const auto& layer : layers) {
|
||||
paintPropertyBinders.emplace(
|
||||
std::piecewise_construct,
|
||||
std::forward_as_tuple(layer->getID()),
|
||||
std::forward_as_tuple(layer->baseImpl->id),
|
||||
std::forward_as_tuple(
|
||||
toRenderCircleLayer(layer)->evaluated,
|
||||
getEvaluated<CircleLayerProperties>(layer),
|
||||
parameters.tileID.overscaledZ));
|
||||
}
|
||||
}
|
||||
@@ -99,20 +99,20 @@ void CircleBucket::addFeature(const GeometryTileFeature& feature,
|
||||
}
|
||||
|
||||
template <class Property>
|
||||
static float get(const RenderCircleLayer& layer, const std::map<std::string, CircleProgram::Binders>& paintPropertyBinders) {
|
||||
auto it = paintPropertyBinders.find(layer.getID());
|
||||
static float get(const CirclePaintProperties::PossiblyEvaluated& evaluated, const std::string& id, const std::map<std::string, CircleProgram::Binders>& paintPropertyBinders) {
|
||||
auto it = paintPropertyBinders.find(id);
|
||||
if (it == paintPropertyBinders.end() || !it->second.statistics<Property>().max()) {
|
||||
return layer.evaluated.get<Property>().constantOr(Property::defaultValue());
|
||||
return evaluated.get<Property>().constantOr(Property::defaultValue());
|
||||
} else {
|
||||
return *it->second.statistics<Property>().max();
|
||||
}
|
||||
}
|
||||
|
||||
float CircleBucket::getQueryRadius(const RenderLayer& layer) const {
|
||||
const RenderCircleLayer* circleLayer = toRenderCircleLayer(&layer);
|
||||
float radius = get<CircleRadius>(*circleLayer, paintPropertyBinders);
|
||||
float stroke = get<CircleStrokeWidth>(*circleLayer, paintPropertyBinders);
|
||||
auto translate = circleLayer->evaluated.get<CircleTranslate>();
|
||||
const auto& evaluated = getEvaluated<CircleLayerProperties>(layer.evaluatedProperties);
|
||||
float radius = get<CircleRadius>(evaluated, layer.getID(), paintPropertyBinders);
|
||||
float stroke = get<CircleStrokeWidth>(evaluated, layer.getID(), paintPropertyBinders);
|
||||
auto translate = evaluated.get<CircleTranslate>();
|
||||
return radius + stroke + util::length(translate[0], translate[1]);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class BucketParameters;
|
||||
|
||||
class CircleBucket final : public Bucket {
|
||||
public:
|
||||
CircleBucket(const BucketParameters&, const std::vector<const RenderLayer*>&);
|
||||
CircleBucket(const BucketParameters&, const std::vector<Immutable<style::LayerProperties>>&);
|
||||
~CircleBucket() override;
|
||||
|
||||
void addFeature(const GeometryTileFeature&,
|
||||
|
||||
@@ -141,10 +141,9 @@ bool FillBucket::supportsLayer(const style::Layer::Impl& impl) const {
|
||||
return style::FillLayer::Impl::staticTypeInfo() == impl.getTypeInfo();
|
||||
}
|
||||
|
||||
|
||||
float FillBucket::getQueryRadius(const RenderLayer& layer) const {
|
||||
const RenderFillLayer* fillLayer = toRenderFillLayer(&layer);
|
||||
const std::array<float, 2>& translate = fillLayer->evaluated.get<FillTranslate>();
|
||||
const auto& evaluated = getEvaluated<FillLayerProperties>(layer.evaluatedProperties);
|
||||
const std::array<float, 2>& translate = evaluated.get<FillTranslate>();
|
||||
return util::length(translate[0], translate[1]);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,6 @@ class RenderFillLayer;
|
||||
class FillBucket final : public Bucket {
|
||||
public:
|
||||
~FillBucket() override;
|
||||
// These aliases are used by the PatternLayout template
|
||||
using RenderLayerType = RenderFillLayer;
|
||||
using PossiblyEvaluatedPaintProperties = style::FillPaintProperties::PossiblyEvaluated;
|
||||
using PossiblyEvaluatedLayoutProperties = style::Properties<>::PossiblyEvaluated;
|
||||
|
||||
|
||||
@@ -185,8 +185,8 @@ bool FillExtrusionBucket::supportsLayer(const style::Layer::Impl& impl) const {
|
||||
}
|
||||
|
||||
float FillExtrusionBucket::getQueryRadius(const RenderLayer& layer) const {
|
||||
const RenderFillExtrusionLayer* fillExtrusionLayer = toRenderFillExtrusionLayer(&layer);
|
||||
const std::array<float, 2>& translate = fillExtrusionLayer->evaluated.get<FillExtrusionTranslate>();
|
||||
const auto& evaluated = getEvaluated<FillExtrusionLayerProperties>(layer.evaluatedProperties);
|
||||
const std::array<float, 2>& translate = evaluated.get<FillExtrusionTranslate>();
|
||||
return util::length(translate[0], translate[1]);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@ class RenderFillExtrusionLayer;
|
||||
class FillExtrusionBucket final : public Bucket {
|
||||
public:
|
||||
~FillExtrusionBucket() override;
|
||||
// These aliases are used by the PatternLayout template
|
||||
using RenderLayerType = RenderFillExtrusionLayer;
|
||||
using PossiblyEvaluatedPaintProperties = style::FillExtrusionPaintProperties::PossiblyEvaluated;
|
||||
using PossiblyEvaluatedLayoutProperties = style::Properties<>::PossiblyEvaluated;
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@ namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
HeatmapBucket::HeatmapBucket(const BucketParameters& parameters, const std::vector<const RenderLayer*>& layers)
|
||||
HeatmapBucket::HeatmapBucket(const BucketParameters& parameters, const std::vector<Immutable<style::LayerProperties>>& layers)
|
||||
: mode(parameters.mode) {
|
||||
for (const auto& layer : layers) {
|
||||
paintPropertyBinders.emplace(
|
||||
std::piecewise_construct,
|
||||
std::forward_as_tuple(layer->getID()),
|
||||
std::forward_as_tuple(layer->baseImpl->id),
|
||||
std::forward_as_tuple(
|
||||
toRenderHeatmapLayer(layer)->evaluated,
|
||||
getEvaluated<HeatmapLayerProperties>(layer),
|
||||
parameters.tileID.overscaledZ));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class BucketParameters;
|
||||
|
||||
class HeatmapBucket final : public Bucket {
|
||||
public:
|
||||
HeatmapBucket(const BucketParameters&, const std::vector<const RenderLayer*>&);
|
||||
HeatmapBucket(const BucketParameters&, const std::vector<Immutable<style::LayerProperties>>&);
|
||||
~HeatmapBucket() override;
|
||||
|
||||
void addFeature(const GeometryTileFeature&,
|
||||
|
||||
@@ -11,10 +11,10 @@ namespace mbgl {
|
||||
using namespace style;
|
||||
|
||||
LineBucket::LineBucket(const style::LineLayoutProperties::PossiblyEvaluated layout_,
|
||||
std::map<std::string, style::LinePaintProperties::PossiblyEvaluated> layerPaintProperties,
|
||||
const std::map<std::string, style::LinePaintProperties::PossiblyEvaluated>& layerPaintProperties,
|
||||
const float zoom_,
|
||||
const uint32_t overscaling_)
|
||||
: layout(layout_),
|
||||
: layout(std::move(layout_)),
|
||||
zoom(zoom_),
|
||||
overscaling(overscaling_) {
|
||||
|
||||
@@ -528,31 +528,26 @@ bool LineBucket::supportsLayer(const style::Layer::Impl& impl) const {
|
||||
}
|
||||
|
||||
template <class Property>
|
||||
static float get(const RenderLineLayer& layer, const std::map<std::string, LineProgram::Binders>& paintPropertyBinders) {
|
||||
auto it = paintPropertyBinders.find(layer.getID());
|
||||
static float get(const LinePaintProperties::PossiblyEvaluated& evaluated, const std::string& id, const std::map<std::string, LineProgram::Binders>& paintPropertyBinders) {
|
||||
auto it = paintPropertyBinders.find(id);
|
||||
if (it == paintPropertyBinders.end() || !it->second.statistics<Property>().max()) {
|
||||
return layer.evaluated.get<Property>().constantOr(Property::defaultValue());
|
||||
return evaluated.get<Property>().constantOr(Property::defaultValue());
|
||||
} else {
|
||||
return *it->second.statistics<Property>().max();
|
||||
}
|
||||
}
|
||||
|
||||
float LineBucket::getLineWidth(const RenderLineLayer& layer) const {
|
||||
float lineWidth = get<LineWidth>(layer, paintPropertyBinders);
|
||||
float gapWidth = get<LineGapWidth>(layer, paintPropertyBinders);
|
||||
|
||||
if (gapWidth) {
|
||||
return gapWidth + 2 * lineWidth;
|
||||
} else {
|
||||
return lineWidth;
|
||||
}
|
||||
}
|
||||
|
||||
float LineBucket::getQueryRadius(const RenderLayer& layer) const {
|
||||
const RenderLineLayer* lineLayer = toRenderLineLayer(&layer);
|
||||
const std::array<float, 2>& translate = lineLayer->evaluated.get<LineTranslate>();
|
||||
float offset = get<LineOffset>(*lineLayer, paintPropertyBinders);
|
||||
return getLineWidth(*lineLayer) / 2.0 + std::abs(offset) + util::length(translate[0], translate[1]);
|
||||
const auto& evaluated = getEvaluated<LineLayerProperties>(layer.evaluatedProperties);
|
||||
const std::array<float, 2>& translate = evaluated.get<LineTranslate>();
|
||||
float offset = get<LineOffset>(evaluated, layer.getID(), paintPropertyBinders);
|
||||
float lineWidth = get<LineWidth>(evaluated, layer.getID(), paintPropertyBinders);
|
||||
float gapWidth = get<LineGapWidth>(evaluated, layer.getID(), paintPropertyBinders);
|
||||
if (gapWidth) {
|
||||
lineWidth = gapWidth + 2 * lineWidth;
|
||||
}
|
||||
|
||||
return lineWidth / 2.0f + std::abs(offset) + util::length(translate[0], translate[1]);
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -17,14 +17,11 @@ class RenderLineLayer;
|
||||
|
||||
class LineBucket final : public Bucket {
|
||||
public:
|
||||
|
||||
// These aliases are used by the PatternLayout template
|
||||
using RenderLayerType = RenderLineLayer;
|
||||
using PossiblyEvaluatedPaintProperties = style::LinePaintProperties::PossiblyEvaluated;
|
||||
using PossiblyEvaluatedLayoutProperties = style::LineLayoutProperties::PossiblyEvaluated;
|
||||
|
||||
LineBucket(const PossiblyEvaluatedLayoutProperties layout,
|
||||
std::map<std::string, PossiblyEvaluatedPaintProperties> layerPaintProperties,
|
||||
const std::map<std::string, PossiblyEvaluatedPaintProperties>& layerPaintProperties,
|
||||
const float zoom,
|
||||
const uint32_t overscaling);
|
||||
~LineBucket() override;
|
||||
@@ -77,8 +74,6 @@ private:
|
||||
|
||||
const float zoom;
|
||||
const uint32_t overscaling;
|
||||
|
||||
float getLineWidth(const RenderLineLayer& layer) const;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#include <mbgl/renderer/group_by_layout.hpp>
|
||||
#include <mbgl/renderer/render_layer.hpp>
|
||||
#include <mbgl/style/layer_impl.hpp>
|
||||
#include <mbgl/style/conversion/stringify.hpp>
|
||||
#include <mbgl/util/rapidjson.hpp>
|
||||
|
||||
@@ -11,38 +9,24 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
std::string layoutKey(const RenderLayer& layer) {
|
||||
std::string layoutKey(const style::Layer::Impl& impl) {
|
||||
using namespace style::conversion;
|
||||
|
||||
rapidjson::StringBuffer s;
|
||||
rapidjson::Writer<rapidjson::StringBuffer> writer(s);
|
||||
|
||||
writer.StartArray();
|
||||
writer.Uint64(reinterpret_cast<uint64_t>(layer.baseImpl->getTypeInfo()));
|
||||
writer.String(layer.baseImpl->source);
|
||||
writer.String(layer.baseImpl->sourceLayer);
|
||||
writer.Double(layer.baseImpl->minZoom);
|
||||
writer.Double(layer.baseImpl->maxZoom);
|
||||
writer.Uint(static_cast<uint32_t>(layer.baseImpl->visibility));
|
||||
stringify(writer, layer.baseImpl->filter);
|
||||
layer.baseImpl->stringifyLayout(writer);
|
||||
writer.Uint64(reinterpret_cast<uint64_t>(impl.getTypeInfo()));
|
||||
writer.String(impl.source);
|
||||
writer.String(impl.sourceLayer);
|
||||
writer.Double(impl.minZoom);
|
||||
writer.Double(impl.maxZoom);
|
||||
writer.Uint(static_cast<uint32_t>(impl.visibility));
|
||||
stringify(writer, impl.filter);
|
||||
impl.stringifyLayout(writer);
|
||||
writer.EndArray();
|
||||
|
||||
return s.GetString();
|
||||
}
|
||||
|
||||
std::vector<std::vector<const RenderLayer*>> groupByLayout(const std::vector<std::unique_ptr<RenderLayer>>& layers) {
|
||||
std::unordered_map<std::string, std::vector<const RenderLayer*>> map;
|
||||
for (auto& layer : layers) {
|
||||
map[layoutKey(*layer)].push_back(layer.get());
|
||||
}
|
||||
|
||||
std::vector<std::vector<const RenderLayer*>> result;
|
||||
for (auto& pair : map) {
|
||||
result.push_back(pair.second);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/style/layer_impl.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class RenderLayer;
|
||||
|
||||
std::vector<std::vector<const RenderLayer*>> groupByLayout(const std::vector<std::unique_ptr<RenderLayer>>&);
|
||||
std::string layoutKey(const style::Layer::Impl& impl);
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -14,25 +14,30 @@ namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
RenderBackgroundLayer::RenderBackgroundLayer(Immutable<style::BackgroundLayer::Impl> _impl)
|
||||
: RenderLayer(std::move(_impl)),
|
||||
unevaluated(impl().paint.untransitioned()) {
|
||||
inline const BackgroundLayer::Impl& impl(const Immutable<style::Layer::Impl>& impl) {
|
||||
return static_cast<const style::BackgroundLayer::Impl&>(*impl);
|
||||
}
|
||||
|
||||
const style::BackgroundLayer::Impl& RenderBackgroundLayer::impl() const {
|
||||
return static_cast<const style::BackgroundLayer::Impl&>(*baseImpl);
|
||||
RenderBackgroundLayer::RenderBackgroundLayer(Immutable<style::BackgroundLayer::Impl> _impl)
|
||||
: RenderLayer(makeMutable<BackgroundLayerProperties>(std::move(_impl))),
|
||||
unevaluated(impl(baseImpl).paint.untransitioned()) {
|
||||
}
|
||||
|
||||
RenderBackgroundLayer::~RenderBackgroundLayer() = default;
|
||||
|
||||
void RenderBackgroundLayer::transition(const TransitionParameters ¶meters) {
|
||||
unevaluated = impl().paint.transitioned(parameters, std::move(unevaluated));
|
||||
unevaluated = impl(baseImpl).paint.transitioned(parameters, std::move(unevaluated));
|
||||
}
|
||||
|
||||
void RenderBackgroundLayer::evaluate(const PropertyEvaluationParameters ¶meters) {
|
||||
evaluated = unevaluated.evaluate(parameters);
|
||||
crossfade = parameters.getCrossfadeParameters();
|
||||
auto properties = makeMutable<BackgroundLayerProperties>(
|
||||
staticImmutableCast<BackgroundLayer::Impl>(baseImpl),
|
||||
parameters.getCrossfadeParameters(),
|
||||
unevaluated.evaluate(parameters));
|
||||
|
||||
passes = evaluated.get<style::BackgroundOpacity>() > 0 ? RenderPass::Translucent
|
||||
: RenderPass::None;
|
||||
passes = properties->evaluated.get<style::BackgroundOpacity>() > 0 ? RenderPass::Translucent
|
||||
: RenderPass::None;
|
||||
evaluatedProperties = std::move(properties);
|
||||
}
|
||||
|
||||
bool RenderBackgroundLayer::hasTransition() const {
|
||||
@@ -40,7 +45,7 @@ bool RenderBackgroundLayer::hasTransition() const {
|
||||
}
|
||||
|
||||
bool RenderBackgroundLayer::hasCrossfade() const {
|
||||
return crossfade.t != 1;
|
||||
return static_cast<const BackgroundLayerProperties&>(*evaluatedProperties).crossfade.t != 1;
|
||||
}
|
||||
|
||||
void RenderBackgroundLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
@@ -81,7 +86,8 @@ void RenderBackgroundLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
getID()
|
||||
);
|
||||
};
|
||||
|
||||
const auto& evaluated = static_cast<const BackgroundLayerProperties&>(*evaluatedProperties).evaluated;
|
||||
const auto& crossfade = static_cast<const BackgroundLayerProperties&>(*evaluatedProperties).crossfade;
|
||||
if (!evaluated.get<BackgroundPattern>().to.empty()) {
|
||||
optional<ImagePosition> imagePosA = parameters.imageManager.getPattern(evaluated.get<BackgroundPattern>().from);
|
||||
optional<ImagePosition> imagePosB = parameters.imageManager.getPattern(evaluated.get<BackgroundPattern>().to);
|
||||
@@ -123,6 +129,7 @@ void RenderBackgroundLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
}
|
||||
|
||||
optional<Color> RenderBackgroundLayer::getSolidBackground() const {
|
||||
const auto& evaluated = static_cast<const BackgroundLayerProperties&>(*evaluatedProperties).evaluated;
|
||||
if (!evaluated.get<BackgroundPattern>().from.empty()) {
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
@@ -6,25 +6,21 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class RenderBackgroundLayer: public RenderLayer {
|
||||
class RenderBackgroundLayer final : public RenderLayer {
|
||||
public:
|
||||
RenderBackgroundLayer(Immutable<style::BackgroundLayer::Impl>);
|
||||
~RenderBackgroundLayer() final = default;
|
||||
explicit RenderBackgroundLayer(Immutable<style::BackgroundLayer::Impl>);
|
||||
~RenderBackgroundLayer() override;
|
||||
|
||||
private:
|
||||
void transition(const TransitionParameters&) override;
|
||||
void evaluate(const PropertyEvaluationParameters&) override;
|
||||
bool hasTransition() const override;
|
||||
bool hasCrossfade() const override;
|
||||
optional<Color> getSolidBackground() const final;
|
||||
optional<Color> getSolidBackground() const override;
|
||||
void render(PaintParameters&, RenderSource*) override;
|
||||
|
||||
// Paint properties
|
||||
style::BackgroundPaintProperties::Unevaluated unevaluated;
|
||||
style::BackgroundPaintProperties::PossiblyEvaluated evaluated;
|
||||
|
||||
const style::BackgroundLayer::Impl& impl() const;
|
||||
private:
|
||||
CrossfadeParameters crossfade;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -15,21 +15,24 @@ namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
RenderCircleLayer::RenderCircleLayer(Immutable<style::CircleLayer::Impl> _impl)
|
||||
: RenderLayer(std::move(_impl)),
|
||||
unevaluated(impl().paint.untransitioned()) {
|
||||
inline const style::CircleLayer::Impl& impl(const Immutable<style::Layer::Impl>& impl) {
|
||||
return static_cast<const style::CircleLayer::Impl&>(*impl);
|
||||
}
|
||||
|
||||
const style::CircleLayer::Impl& RenderCircleLayer::impl() const {
|
||||
return static_cast<const style::CircleLayer::Impl&>(*baseImpl);
|
||||
RenderCircleLayer::RenderCircleLayer(Immutable<style::CircleLayer::Impl> _impl)
|
||||
: RenderLayer(makeMutable<CircleLayerProperties>(std::move(_impl))),
|
||||
unevaluated(impl(baseImpl).paint.untransitioned()) {
|
||||
}
|
||||
|
||||
void RenderCircleLayer::transition(const TransitionParameters& parameters) {
|
||||
unevaluated = impl().paint.transitioned(parameters, std::move(unevaluated));
|
||||
unevaluated = impl(baseImpl).paint.transitioned(parameters, std::move(unevaluated));
|
||||
}
|
||||
|
||||
void RenderCircleLayer::evaluate(const PropertyEvaluationParameters& parameters) {
|
||||
evaluated = unevaluated.evaluate(parameters);
|
||||
auto properties = makeMutable<CircleLayerProperties>(
|
||||
staticImmutableCast<CircleLayer::Impl>(baseImpl),
|
||||
unevaluated.evaluate(parameters));
|
||||
const auto& evaluated = properties->evaluated;
|
||||
|
||||
passes = ((evaluated.get<style::CircleRadius>().constantOr(1) > 0 ||
|
||||
evaluated.get<style::CircleStrokeWidth>().constantOr(1) > 0)
|
||||
@@ -38,6 +41,7 @@ void RenderCircleLayer::evaluate(const PropertyEvaluationParameters& parameters)
|
||||
&& (evaluated.get<style::CircleOpacity>().constantOr(1) > 0 ||
|
||||
evaluated.get<style::CircleStrokeOpacity>().constantOr(1) > 0))
|
||||
? RenderPass::Translucent : RenderPass::None;
|
||||
evaluatedProperties = std::move(properties);
|
||||
}
|
||||
|
||||
bool RenderCircleLayer::hasTransition() const {
|
||||
@@ -52,7 +56,7 @@ void RenderCircleLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
if (parameters.pass == RenderPass::Opaque) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& evaluated = static_cast<const CircleLayerProperties&>(*evaluatedProperties).evaluated;
|
||||
const bool scaleWithMap = evaluated.get<CirclePitchScale>() == CirclePitchScaleType::Map;
|
||||
const bool pitchWithMap = evaluated.get<CirclePitchAlignment>() == AlignmentType::Map;
|
||||
|
||||
@@ -139,7 +143,7 @@ bool RenderCircleLayer::queryIntersectsFeature(
|
||||
const TransformState& transformState,
|
||||
const float pixelsToTileUnits,
|
||||
const mat4& posMatrix) const {
|
||||
|
||||
const auto& evaluated = static_cast<const CircleLayerProperties&>(*evaluatedProperties).evaluated;
|
||||
// Translate query geometry
|
||||
const GeometryCoordinates& translatedQueryGeometry = FeatureIndex::translateQueryGeometry(
|
||||
queryGeometry,
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class RenderCircleLayer: public RenderLayer {
|
||||
class RenderCircleLayer final : public RenderLayer {
|
||||
public:
|
||||
RenderCircleLayer(Immutable<style::CircleLayer::Impl>);
|
||||
explicit RenderCircleLayer(Immutable<style::CircleLayer::Impl>);
|
||||
~RenderCircleLayer() final = default;
|
||||
|
||||
private:
|
||||
void transition(const TransitionParameters&) override;
|
||||
void evaluate(const PropertyEvaluationParameters&) override;
|
||||
bool hasTransition() const override;
|
||||
@@ -27,13 +28,6 @@ public:
|
||||
|
||||
// Paint properties
|
||||
style::CirclePaintProperties::Unevaluated unevaluated;
|
||||
style::CirclePaintProperties::PossiblyEvaluated evaluated;
|
||||
|
||||
const style::CircleLayer::Impl& impl() const;
|
||||
};
|
||||
|
||||
inline const RenderCircleLayer* toRenderCircleLayer(const RenderLayer* layer) {
|
||||
return static_cast<const RenderCircleLayer*>(layer);
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -14,8 +14,13 @@ namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
inline const CustomLayer::Impl& impl(const Immutable<style::Layer::Impl>& impl) {
|
||||
return static_cast<const CustomLayer::Impl&>(*impl);
|
||||
}
|
||||
|
||||
RenderCustomLayer::RenderCustomLayer(Immutable<style::CustomLayer::Impl> _impl)
|
||||
: RenderLayer(std::move(_impl)), host(impl().host) {
|
||||
: RenderLayer(makeMutable<CustomLayerProperties>(std::move(_impl))),
|
||||
host(impl(baseImpl).host) {
|
||||
assert(gfx::BackendScope::exists());
|
||||
MBGL_CHECK_ERROR(host->initialize());
|
||||
}
|
||||
@@ -29,12 +34,9 @@ RenderCustomLayer::~RenderCustomLayer() {
|
||||
}
|
||||
}
|
||||
|
||||
const CustomLayer::Impl& RenderCustomLayer::impl() const {
|
||||
return static_cast<const CustomLayer::Impl&>(*baseImpl);
|
||||
}
|
||||
|
||||
void RenderCustomLayer::evaluate(const PropertyEvaluationParameters&) {
|
||||
passes = RenderPass::Translucent;
|
||||
// It is fine to not update `evaluatedProperties`, as `baseImpl` should never be updated for this layer.
|
||||
}
|
||||
|
||||
bool RenderCustomLayer::hasTransition() const {
|
||||
@@ -49,12 +51,12 @@ void RenderCustomLayer::markContextDestroyed() {
|
||||
}
|
||||
|
||||
void RenderCustomLayer::render(PaintParameters& paintParameters, RenderSource*) {
|
||||
if (host != impl().host) {
|
||||
if (host != impl(baseImpl).host) {
|
||||
//If the context changed, deinitialize the previous one before initializing the new one.
|
||||
if (host && !contextDestroyed) {
|
||||
MBGL_CHECK_ERROR(host->deinitialize());
|
||||
}
|
||||
host = impl().host;
|
||||
host = impl(baseImpl).host;
|
||||
MBGL_CHECK_ERROR(host->initialize());
|
||||
}
|
||||
|
||||
|
||||
@@ -5,22 +5,20 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class RenderCustomLayer: public RenderLayer {
|
||||
class RenderCustomLayer final : public RenderLayer {
|
||||
public:
|
||||
RenderCustomLayer(Immutable<style::CustomLayer::Impl>);
|
||||
~RenderCustomLayer() final;
|
||||
explicit RenderCustomLayer(Immutable<style::CustomLayer::Impl>);
|
||||
~RenderCustomLayer() override;
|
||||
|
||||
void transition(const TransitionParameters&) final {}
|
||||
private:
|
||||
void transition(const TransitionParameters&) override {}
|
||||
void evaluate(const PropertyEvaluationParameters&) override;
|
||||
bool hasTransition() const override;
|
||||
bool hasCrossfade() const override;
|
||||
void markContextDestroyed() final;
|
||||
void markContextDestroyed() override;
|
||||
|
||||
void render(PaintParameters&, RenderSource*) final;
|
||||
void render(PaintParameters&, RenderSource*) override;
|
||||
|
||||
const style::CustomLayer::Impl& impl() const;
|
||||
|
||||
private:
|
||||
bool contextDestroyed = false;
|
||||
std::shared_ptr<style::CustomLayerHost> host;
|
||||
};
|
||||
|
||||
@@ -20,26 +20,31 @@ namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
RenderFillExtrusionLayer::RenderFillExtrusionLayer(Immutable<style::FillExtrusionLayer::Impl> _impl)
|
||||
: RenderLayer(std::move(_impl)),
|
||||
unevaluated(impl().paint.untransitioned()) {
|
||||
inline const FillExtrusionLayer::Impl& impl(const Immutable<style::Layer::Impl>& impl) {
|
||||
return static_cast<const FillExtrusionLayer::Impl&>(*impl);
|
||||
}
|
||||
|
||||
const style::FillExtrusionLayer::Impl& RenderFillExtrusionLayer::impl() const {
|
||||
return static_cast<const style::FillExtrusionLayer::Impl&>(*baseImpl);
|
||||
RenderFillExtrusionLayer::RenderFillExtrusionLayer(Immutable<style::FillExtrusionLayer::Impl> _impl)
|
||||
: RenderLayer(makeMutable<FillExtrusionLayerProperties>(std::move(_impl))),
|
||||
unevaluated(impl(baseImpl).paint.untransitioned()) {
|
||||
}
|
||||
|
||||
RenderFillExtrusionLayer::~RenderFillExtrusionLayer() = default;
|
||||
|
||||
void RenderFillExtrusionLayer::transition(const TransitionParameters& parameters) {
|
||||
unevaluated = impl().paint.transitioned(parameters, std::move(unevaluated));
|
||||
unevaluated = impl(baseImpl).paint.transitioned(parameters, std::move(unevaluated));
|
||||
}
|
||||
|
||||
void RenderFillExtrusionLayer::evaluate(const PropertyEvaluationParameters& parameters) {
|
||||
evaluated = unevaluated.evaluate(parameters);
|
||||
crossfade = parameters.getCrossfadeParameters();
|
||||
auto properties = makeMutable<FillExtrusionLayerProperties>(
|
||||
staticImmutableCast<FillExtrusionLayer::Impl>(baseImpl),
|
||||
parameters.getCrossfadeParameters(),
|
||||
unevaluated.evaluate(parameters));
|
||||
|
||||
passes = (evaluated.get<style::FillExtrusionOpacity>() > 0)
|
||||
passes = (properties->evaluated.get<style::FillExtrusionOpacity>() > 0)
|
||||
? (RenderPass::Translucent | RenderPass::Pass3D)
|
||||
: RenderPass::None;
|
||||
evaluatedProperties = std::move(properties);
|
||||
}
|
||||
|
||||
bool RenderFillExtrusionLayer::hasTransition() const {
|
||||
@@ -47,14 +52,15 @@ bool RenderFillExtrusionLayer::hasTransition() const {
|
||||
}
|
||||
|
||||
bool RenderFillExtrusionLayer::hasCrossfade() const {
|
||||
return crossfade.t != 1;
|
||||
return static_cast<const FillExtrusionLayerProperties&>(*evaluatedProperties).crossfade.t != 1;
|
||||
}
|
||||
|
||||
void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
if (parameters.pass == RenderPass::Opaque) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& evaluated = static_cast<const FillExtrusionLayerProperties&>(*evaluatedProperties).evaluated;
|
||||
const auto& crossfade = static_cast<const FillExtrusionLayerProperties&>(*evaluatedProperties).crossfade;
|
||||
if (parameters.pass == RenderPass::Pass3D) {
|
||||
const auto& size = parameters.staticData.backendSize;
|
||||
|
||||
@@ -222,7 +228,7 @@ bool RenderFillExtrusionLayer::queryIntersectsFeature(
|
||||
const TransformState& transformState,
|
||||
const float pixelsToTileUnits,
|
||||
const mat4&) const {
|
||||
|
||||
const auto& evaluated = static_cast<const FillExtrusionLayerProperties&>(*evaluatedProperties).evaluated;
|
||||
auto translatedQueryGeometry = FeatureIndex::translateQueryGeometry(
|
||||
queryGeometry,
|
||||
evaluated.get<style::FillExtrusionTranslate>(),
|
||||
|
||||
@@ -7,19 +7,12 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
template <class B>
|
||||
class PatternLayout;
|
||||
|
||||
class FillExtrusionBucket;
|
||||
|
||||
class RenderFillExtrusionLayer: public RenderLayer {
|
||||
class RenderFillExtrusionLayer final : public RenderLayer {
|
||||
public:
|
||||
using StyleLayerImpl = style::FillExtrusionLayer::Impl;
|
||||
using PatternProperty = style::FillExtrusionPattern;
|
||||
|
||||
RenderFillExtrusionLayer(Immutable<style::FillExtrusionLayer::Impl>);
|
||||
~RenderFillExtrusionLayer() final = default;
|
||||
explicit RenderFillExtrusionLayer(Immutable<style::FillExtrusionLayer::Impl>);
|
||||
~RenderFillExtrusionLayer() override;
|
||||
|
||||
private:
|
||||
void transition(const TransitionParameters&) override;
|
||||
void evaluate(const PropertyEvaluationParameters&) override;
|
||||
bool hasTransition() const override;
|
||||
@@ -36,17 +29,8 @@ public:
|
||||
|
||||
// Paint properties
|
||||
style::FillExtrusionPaintProperties::Unevaluated unevaluated;
|
||||
style::FillExtrusionPaintProperties::PossiblyEvaluated evaluated;
|
||||
|
||||
const style::FillExtrusionLayer::Impl& impl() const;
|
||||
|
||||
std::unique_ptr<gfx::OffscreenTexture> renderTexture;
|
||||
private:
|
||||
CrossfadeParameters crossfade;
|
||||
};
|
||||
|
||||
inline const RenderFillExtrusionLayer* toRenderFillExtrusionLayer(const RenderLayer* layer) {
|
||||
return static_cast<const RenderFillExtrusionLayer*>(layer);
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -20,22 +20,27 @@ namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
RenderFillLayer::RenderFillLayer(Immutable<style::FillLayer::Impl> _impl)
|
||||
: RenderLayer(std::move(_impl)),
|
||||
unevaluated(impl().paint.untransitioned()) {
|
||||
inline const FillLayer::Impl& impl(const Immutable<style::Layer::Impl>& impl) {
|
||||
return static_cast<const FillLayer::Impl&>(*impl);
|
||||
}
|
||||
|
||||
const style::FillLayer::Impl& RenderFillLayer::impl() const {
|
||||
return static_cast<const style::FillLayer::Impl&>(*baseImpl);
|
||||
RenderFillLayer::RenderFillLayer(Immutable<style::FillLayer::Impl> _impl)
|
||||
: RenderLayer(makeMutable<FillLayerProperties>(std::move(_impl))),
|
||||
unevaluated(impl(baseImpl).paint.untransitioned()) {
|
||||
}
|
||||
|
||||
RenderFillLayer::~RenderFillLayer() = default;
|
||||
|
||||
void RenderFillLayer::transition(const TransitionParameters& parameters) {
|
||||
unevaluated = impl().paint.transitioned(parameters, std::move(unevaluated));
|
||||
unevaluated = impl(baseImpl).paint.transitioned(parameters, std::move(unevaluated));
|
||||
}
|
||||
|
||||
void RenderFillLayer::evaluate(const PropertyEvaluationParameters& parameters) {
|
||||
evaluated = unevaluated.evaluate(parameters);
|
||||
crossfade = parameters.getCrossfadeParameters();
|
||||
auto properties = makeMutable<FillLayerProperties>(
|
||||
staticImmutableCast<FillLayer::Impl>(baseImpl),
|
||||
parameters.getCrossfadeParameters(),
|
||||
unevaluated.evaluate(parameters));
|
||||
auto& evaluated = properties->evaluated;
|
||||
|
||||
if (unevaluated.get<style::FillOutlineColor>().isUndefined()) {
|
||||
evaluated.get<style::FillOutlineColor>() = evaluated.get<style::FillColor>();
|
||||
@@ -54,6 +59,8 @@ void RenderFillLayer::evaluate(const PropertyEvaluationParameters& parameters) {
|
||||
} else {
|
||||
passes |= RenderPass::Opaque;
|
||||
}
|
||||
|
||||
evaluatedProperties = std::move(properties);
|
||||
}
|
||||
|
||||
bool RenderFillLayer::hasTransition() const {
|
||||
@@ -61,10 +68,12 @@ bool RenderFillLayer::hasTransition() const {
|
||||
}
|
||||
|
||||
bool RenderFillLayer::hasCrossfade() const {
|
||||
return crossfade.t != 1;
|
||||
return static_cast<const FillLayerProperties&>(*evaluatedProperties).crossfade.t != 1;
|
||||
}
|
||||
|
||||
void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
const auto& evaluated = static_cast<const FillLayerProperties&>(*evaluatedProperties).evaluated;
|
||||
const auto& crossfade = static_cast<const FillLayerProperties&>(*evaluatedProperties).crossfade;
|
||||
if (unevaluated.get<FillPattern>().isUndefined()) {
|
||||
for (const RenderTile& tile : renderTiles) {
|
||||
auto bucket_ = tile.tile.getBucket<FillBucket>(*baseImpl);
|
||||
@@ -240,7 +249,7 @@ bool RenderFillLayer::queryIntersectsFeature(
|
||||
const TransformState& transformState,
|
||||
const float pixelsToTileUnits,
|
||||
const mat4&) const {
|
||||
|
||||
const auto& evaluated = static_cast<const FillLayerProperties&>(*evaluatedProperties).evaluated;
|
||||
auto translatedQueryGeometry = FeatureIndex::translateQueryGeometry(
|
||||
queryGeometry,
|
||||
evaluated.get<style::FillTranslate>(),
|
||||
|
||||
@@ -9,14 +9,12 @@ namespace mbgl {
|
||||
|
||||
class FillBucket;
|
||||
|
||||
class RenderFillLayer: public RenderLayer {
|
||||
class RenderFillLayer final : public RenderLayer {
|
||||
public:
|
||||
using StyleLayerImpl = style::FillLayer::Impl;
|
||||
using PatternProperty = style::FillPattern;
|
||||
|
||||
RenderFillLayer(Immutable<style::FillLayer::Impl>);
|
||||
~RenderFillLayer() final = default;
|
||||
explicit RenderFillLayer(Immutable<style::FillLayer::Impl>);
|
||||
~RenderFillLayer() override;
|
||||
|
||||
private:
|
||||
void transition(const TransitionParameters&) override;
|
||||
void evaluate(const PropertyEvaluationParameters&) override;
|
||||
bool hasTransition() const override;
|
||||
@@ -33,16 +31,6 @@ public:
|
||||
|
||||
// Paint properties
|
||||
style::FillPaintProperties::Unevaluated unevaluated;
|
||||
style::FillPaintProperties::PossiblyEvaluated evaluated;
|
||||
|
||||
const style::FillLayer::Impl& impl() const;
|
||||
private:
|
||||
CrossfadeParameters crossfade;
|
||||
|
||||
};
|
||||
|
||||
inline const RenderFillLayer* toRenderFillLayer(const RenderLayer* layer) {
|
||||
return static_cast<const RenderFillLayer*>(layer);
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -19,25 +19,31 @@ namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
RenderHeatmapLayer::RenderHeatmapLayer(Immutable<style::HeatmapLayer::Impl> _impl)
|
||||
: RenderLayer(std::move(_impl)),
|
||||
unevaluated(impl().paint.untransitioned()), colorRamp({256, 1}) {
|
||||
inline const HeatmapLayer::Impl& impl(const Immutable<Layer::Impl>& impl) {
|
||||
return static_cast<const HeatmapLayer::Impl&>(*impl);
|
||||
}
|
||||
|
||||
const style::HeatmapLayer::Impl& RenderHeatmapLayer::impl() const {
|
||||
return static_cast<const style::HeatmapLayer::Impl&>(*baseImpl);
|
||||
RenderHeatmapLayer::RenderHeatmapLayer(Immutable<HeatmapLayer::Impl> _impl)
|
||||
: RenderLayer(makeMutable<HeatmapLayerProperties>(std::move(_impl))),
|
||||
unevaluated(impl(baseImpl).paint.untransitioned()), colorRamp({256, 1}) {
|
||||
}
|
||||
|
||||
RenderHeatmapLayer::~RenderHeatmapLayer() = default;
|
||||
|
||||
void RenderHeatmapLayer::transition(const TransitionParameters& parameters) {
|
||||
unevaluated = impl().paint.transitioned(parameters, std::move(unevaluated));
|
||||
unevaluated = impl(baseImpl).paint.transitioned(parameters, std::move(unevaluated));
|
||||
}
|
||||
|
||||
void RenderHeatmapLayer::evaluate(const PropertyEvaluationParameters& parameters) {
|
||||
evaluated = unevaluated.evaluate(parameters);
|
||||
auto properties = makeMutable<HeatmapLayerProperties>(
|
||||
staticImmutableCast<HeatmapLayer::Impl>(baseImpl),
|
||||
unevaluated.evaluate(parameters));
|
||||
|
||||
passes = (evaluated.get<style::HeatmapOpacity>() > 0)
|
||||
passes = (properties->evaluated.get<style::HeatmapOpacity>() > 0)
|
||||
? (RenderPass::Translucent | RenderPass::Pass3D)
|
||||
: RenderPass::None;
|
||||
|
||||
evaluatedProperties = std::move(properties);
|
||||
}
|
||||
|
||||
bool RenderHeatmapLayer::hasTransition() const {
|
||||
@@ -52,7 +58,7 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
if (parameters.pass == RenderPass::Opaque) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& evaluated = static_cast<const HeatmapLayerProperties&>(*evaluatedProperties).evaluated;
|
||||
if (parameters.pass == RenderPass::Pass3D) {
|
||||
const auto& viewportSize = parameters.staticData.backendSize;
|
||||
const auto size = Size{viewportSize.width / 4, viewportSize.height / 4};
|
||||
|
||||
@@ -9,11 +9,12 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class RenderHeatmapLayer: public RenderLayer {
|
||||
class RenderHeatmapLayer final : public RenderLayer {
|
||||
public:
|
||||
RenderHeatmapLayer(Immutable<style::HeatmapLayer::Impl>);
|
||||
~RenderHeatmapLayer() final = default;
|
||||
explicit RenderHeatmapLayer(Immutable<style::HeatmapLayer::Impl>);
|
||||
~RenderHeatmapLayer() override;
|
||||
|
||||
private:
|
||||
void transition(const TransitionParameters&) override;
|
||||
void evaluate(const PropertyEvaluationParameters&) override;
|
||||
bool hasTransition() const override;
|
||||
@@ -31,20 +32,11 @@ public:
|
||||
|
||||
// Paint properties
|
||||
style::HeatmapPaintProperties::Unevaluated unevaluated;
|
||||
style::HeatmapPaintProperties::PossiblyEvaluated evaluated;
|
||||
|
||||
const style::HeatmapLayer::Impl& impl() const;
|
||||
|
||||
PremultipliedImage colorRamp;
|
||||
std::unique_ptr<gfx::OffscreenTexture> renderTexture;
|
||||
optional<gfx::Texture> colorRampTexture;
|
||||
|
||||
private:
|
||||
void updateColorRamp();
|
||||
};
|
||||
|
||||
inline const RenderHeatmapLayer* toRenderHeatmapLayer(const RenderLayer* layer) {
|
||||
return static_cast<const RenderHeatmapLayer*>(layer);
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -17,36 +17,44 @@
|
||||
namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
RenderHillshadeLayer::RenderHillshadeLayer(Immutable<style::HillshadeLayer::Impl> _impl)
|
||||
: RenderLayer(std::move(_impl)),
|
||||
unevaluated(impl().paint.untransitioned()) {
|
||||
|
||||
inline const HillshadeLayer::Impl& impl(const Immutable<style::Layer::Impl>& impl) {
|
||||
return static_cast<const HillshadeLayer::Impl&>(*impl);
|
||||
}
|
||||
|
||||
const style::HillshadeLayer::Impl& RenderHillshadeLayer::impl() const {
|
||||
return static_cast<const style::HillshadeLayer::Impl&>(*baseImpl);
|
||||
RenderHillshadeLayer::RenderHillshadeLayer(Immutable<style::HillshadeLayer::Impl> _impl)
|
||||
: RenderLayer(makeMutable<HillshadeLayerProperties>(std::move(_impl))),
|
||||
unevaluated(impl(baseImpl).paint.untransitioned()) {
|
||||
}
|
||||
|
||||
RenderHillshadeLayer::~RenderHillshadeLayer() = default;
|
||||
|
||||
const std::array<float, 2> RenderHillshadeLayer::getLatRange(const UnwrappedTileID& id) {
|
||||
const LatLng latlng0 = LatLng(id);
|
||||
const LatLng latlng1 = LatLng(UnwrappedTileID(id.canonical.z, id.canonical.x, id.canonical.y + 1));
|
||||
return {{ (float)latlng0.latitude(), (float)latlng1.latitude() }};
|
||||
}
|
||||
|
||||
const std::array<float, 2> RenderHillshadeLayer::getLight(const PaintParameters& parameters){
|
||||
const std::array<float, 2> RenderHillshadeLayer::getLight(const PaintParameters& parameters) {
|
||||
const auto& evaluated = static_cast<const HillshadeLayerProperties&>(*evaluatedProperties).evaluated;
|
||||
float azimuthal = evaluated.get<HillshadeIlluminationDirection>() * util::DEG2RAD;
|
||||
if (evaluated.get<HillshadeIlluminationAnchor>() == HillshadeIlluminationAnchorType::Viewport) azimuthal = azimuthal - parameters.state.getBearing();
|
||||
return {{evaluated.get<HillshadeExaggeration>(), azimuthal}};
|
||||
}
|
||||
|
||||
void RenderHillshadeLayer::transition(const TransitionParameters& parameters) {
|
||||
unevaluated = impl().paint.transitioned(parameters, std::move(unevaluated));
|
||||
unevaluated = impl(baseImpl).paint.transitioned(parameters, std::move(unevaluated));
|
||||
}
|
||||
|
||||
void RenderHillshadeLayer::evaluate(const PropertyEvaluationParameters& parameters) {
|
||||
evaluated = unevaluated.evaluate(parameters);
|
||||
passes = (evaluated.get<style::HillshadeExaggeration >() > 0)
|
||||
auto properties = makeMutable<HillshadeLayerProperties>(
|
||||
staticImmutableCast<HillshadeLayer::Impl>(baseImpl),
|
||||
unevaluated.evaluate(parameters));
|
||||
passes = (properties->evaluated.get<style::HillshadeExaggeration >() > 0)
|
||||
? (RenderPass::Translucent | RenderPass::Pass3D)
|
||||
: RenderPass::None;
|
||||
|
||||
evaluatedProperties = std::move(properties);
|
||||
}
|
||||
|
||||
bool RenderHillshadeLayer::hasTransition() const {
|
||||
@@ -60,7 +68,7 @@ bool RenderHillshadeLayer::hasCrossfade() const {
|
||||
void RenderHillshadeLayer::render(PaintParameters& parameters, RenderSource* src) {
|
||||
if (parameters.pass != RenderPass::Translucent && parameters.pass != RenderPass::Pass3D)
|
||||
return;
|
||||
|
||||
const auto& evaluated = static_cast<const HillshadeLayerProperties&>(*evaluatedProperties).evaluated;
|
||||
auto* demsrc = static_cast<RenderRasterDEMSource*>(src);
|
||||
const uint8_t TERRAIN_RGB_MAXZOOM = 15;
|
||||
const uint8_t maxzoom = demsrc != nullptr ? demsrc->getMaxZoom() : TERRAIN_RGB_MAXZOOM;
|
||||
|
||||
@@ -9,9 +9,10 @@ namespace mbgl {
|
||||
|
||||
class RenderHillshadeLayer: public RenderLayer {
|
||||
public:
|
||||
RenderHillshadeLayer(Immutable<style::HillshadeLayer::Impl>);
|
||||
~RenderHillshadeLayer() final = default;
|
||||
explicit RenderHillshadeLayer(Immutable<style::HillshadeLayer::Impl>);
|
||||
~RenderHillshadeLayer() override;
|
||||
|
||||
private:
|
||||
void transition(const TransitionParameters&) override;
|
||||
void evaluate(const PropertyEvaluationParameters&) override;
|
||||
bool hasTransition() const override;
|
||||
@@ -21,10 +22,7 @@ public:
|
||||
|
||||
// Paint properties
|
||||
style::HillshadePaintProperties::Unevaluated unevaluated;
|
||||
style::HillshadePaintProperties::PossiblyEvaluated evaluated;
|
||||
|
||||
const style::HillshadeLayer::Impl& impl() const;
|
||||
private:
|
||||
const std::array<float, 2> getLatRange(const UnwrappedTileID& id);
|
||||
const std::array<float, 2> getLight(const PaintParameters& parameters);
|
||||
};
|
||||
|
||||
@@ -18,28 +18,34 @@ namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
inline const LineLayer::Impl& impl(const Immutable<style::Layer::Impl>& impl) {
|
||||
return static_cast<const LineLayer::Impl&>(*impl);
|
||||
}
|
||||
|
||||
RenderLineLayer::RenderLineLayer(Immutable<style::LineLayer::Impl> _impl)
|
||||
: RenderLayer(std::move(_impl)),
|
||||
unevaluated(impl().paint.untransitioned()),
|
||||
: RenderLayer(makeMutable<LineLayerProperties>(std::move(_impl))),
|
||||
unevaluated(impl(baseImpl).paint.untransitioned()),
|
||||
colorRamp({256, 1}) {
|
||||
}
|
||||
|
||||
const style::LineLayer::Impl& RenderLineLayer::impl() const {
|
||||
return static_cast<const style::LineLayer::Impl&>(*baseImpl);
|
||||
}
|
||||
RenderLineLayer::~RenderLineLayer() = default;
|
||||
|
||||
void RenderLineLayer::transition(const TransitionParameters& parameters) {
|
||||
unevaluated = impl().paint.transitioned(parameters, std::move(unevaluated));
|
||||
unevaluated = impl(baseImpl).paint.transitioned(parameters, std::move(unevaluated));
|
||||
}
|
||||
|
||||
void RenderLineLayer::evaluate(const PropertyEvaluationParameters& parameters) {
|
||||
evaluated = unevaluated.evaluate(parameters);
|
||||
crossfade = parameters.getCrossfadeParameters();
|
||||
auto properties = makeMutable<LineLayerProperties>(
|
||||
staticImmutableCast<LineLayer::Impl>(baseImpl),
|
||||
parameters.getCrossfadeParameters(),
|
||||
unevaluated.evaluate(parameters));
|
||||
auto& evaluated = properties->evaluated;
|
||||
|
||||
passes = (evaluated.get<style::LineOpacity>().constantOr(1.0) > 0
|
||||
&& evaluated.get<style::LineColor>().constantOr(Color::black()).a > 0
|
||||
&& evaluated.get<style::LineWidth>().constantOr(1.0) > 0)
|
||||
? RenderPass::Translucent : RenderPass::None;
|
||||
evaluatedProperties = std::move(properties);
|
||||
}
|
||||
|
||||
bool RenderLineLayer::hasTransition() const {
|
||||
@@ -47,13 +53,15 @@ bool RenderLineLayer::hasTransition() const {
|
||||
}
|
||||
|
||||
bool RenderLineLayer::hasCrossfade() const {
|
||||
return crossfade.t != 1;
|
||||
return static_cast<const LineLayerProperties&>(*evaluatedProperties).crossfade.t != 1;
|
||||
}
|
||||
|
||||
void RenderLineLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
if (parameters.pass == RenderPass::Opaque) {
|
||||
return;
|
||||
}
|
||||
const auto& evaluated = static_cast<const LineLayerProperties&>(*evaluatedProperties).evaluated;
|
||||
const auto& crossfade = static_cast<const LineLayerProperties&>(*evaluatedProperties).crossfade;
|
||||
|
||||
for (const RenderTile& tile : renderTiles) {
|
||||
auto bucket_ = tile.tile.getBucket<LineBucket>(*baseImpl);
|
||||
@@ -213,7 +221,7 @@ bool RenderLineLayer::queryIntersectsFeature(
|
||||
const TransformState& transformState,
|
||||
const float pixelsToTileUnits,
|
||||
const mat4&) const {
|
||||
|
||||
const auto& evaluated = static_cast<const LineLayerProperties&>(*evaluatedProperties).evaluated;
|
||||
// Translate query geometry
|
||||
auto translatedQueryGeometry = FeatureIndex::translateQueryGeometry(
|
||||
queryGeometry,
|
||||
@@ -259,6 +267,7 @@ void RenderLineLayer::updateColorRamp() {
|
||||
}
|
||||
|
||||
float RenderLineLayer::getLineWidth(const GeometryTileFeature& feature, const float zoom) const {
|
||||
const auto& evaluated = static_cast<const LineLayerProperties&>(*evaluatedProperties).evaluated;
|
||||
float lineWidth = evaluated.get<style::LineWidth>()
|
||||
.evaluate(feature, zoom, style::LineWidth::defaultValue());
|
||||
float gapWidth = evaluated.get<style::LineGapWidth>()
|
||||
|
||||
@@ -10,20 +10,18 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class RenderLineLayer: public RenderLayer {
|
||||
class RenderLineLayer final : public RenderLayer {
|
||||
public:
|
||||
using StyleLayerImpl = style::LineLayer::Impl;
|
||||
using PatternProperty = style::LinePattern;
|
||||
|
||||
RenderLineLayer(Immutable<style::LineLayer::Impl>);
|
||||
~RenderLineLayer() final = default;
|
||||
explicit RenderLineLayer(Immutable<style::LineLayer::Impl>);
|
||||
~RenderLineLayer() override;
|
||||
|
||||
private:
|
||||
void transition(const TransitionParameters&) override;
|
||||
void evaluate(const PropertyEvaluationParameters&) override;
|
||||
bool hasTransition() const override;
|
||||
bool hasCrossfade() const override;
|
||||
void render(PaintParameters&, RenderSource*) override;
|
||||
void update() final;
|
||||
void update() override;
|
||||
|
||||
bool queryIntersectsFeature(
|
||||
const GeometryCoordinates&,
|
||||
@@ -35,20 +33,12 @@ public:
|
||||
|
||||
// Paint properties
|
||||
style::LinePaintProperties::Unevaluated unevaluated;
|
||||
style::LinePaintProperties::PossiblyEvaluated evaluated;
|
||||
|
||||
const style::LineLayer::Impl& impl() const;
|
||||
|
||||
private:
|
||||
float getLineWidth(const GeometryTileFeature&, const float) const;
|
||||
void updateColorRamp();
|
||||
CrossfadeParameters crossfade;
|
||||
|
||||
PremultipliedImage colorRamp;
|
||||
optional<gfx::Texture> colorRampTexture;
|
||||
};
|
||||
|
||||
inline const RenderLineLayer* toRenderLineLayer(const RenderLayer* layer) {
|
||||
return static_cast<const RenderLineLayer*>(layer);
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -14,23 +14,27 @@ namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
RenderRasterLayer::RenderRasterLayer(Immutable<style::RasterLayer::Impl> _impl)
|
||||
: RenderLayer(std::move(_impl)),
|
||||
unevaluated(impl().paint.untransitioned()) {
|
||||
inline const RasterLayer::Impl& impl(const Immutable<style::Layer::Impl>& impl) {
|
||||
return static_cast<const RasterLayer::Impl&>(*impl);
|
||||
}
|
||||
|
||||
const style::RasterLayer::Impl& RenderRasterLayer::impl() const {
|
||||
return static_cast<const style::RasterLayer::Impl&>(*baseImpl);
|
||||
RenderRasterLayer::RenderRasterLayer(Immutable<style::RasterLayer::Impl> _impl)
|
||||
: RenderLayer(makeMutable<RasterLayerProperties>(std::move(_impl))),
|
||||
unevaluated(impl(baseImpl).paint.untransitioned()) {
|
||||
}
|
||||
|
||||
RenderRasterLayer::~RenderRasterLayer() = default;
|
||||
|
||||
void RenderRasterLayer::transition(const TransitionParameters& parameters) {
|
||||
unevaluated = impl().paint.transitioned(parameters, std::move(unevaluated));
|
||||
unevaluated = impl(baseImpl).paint.transitioned(parameters, std::move(unevaluated));
|
||||
}
|
||||
|
||||
void RenderRasterLayer::evaluate(const PropertyEvaluationParameters& parameters) {
|
||||
evaluated = unevaluated.evaluate(parameters);
|
||||
|
||||
passes = evaluated.get<style::RasterOpacity>() > 0 ? RenderPass::Translucent : RenderPass::None;
|
||||
auto properties = makeMutable<RasterLayerProperties>(
|
||||
staticImmutableCast<RasterLayer::Impl>(baseImpl),
|
||||
unevaluated.evaluate(parameters));
|
||||
passes = properties->evaluated.get<style::RasterOpacity>() > 0 ? RenderPass::Translucent : RenderPass::None;
|
||||
evaluatedProperties = std::move(properties);
|
||||
}
|
||||
|
||||
bool RenderRasterLayer::hasTransition() const {
|
||||
@@ -72,7 +76,7 @@ static std::array<float, 3> spinWeights(float spin) {
|
||||
void RenderRasterLayer::render(PaintParameters& parameters, RenderSource* source) {
|
||||
if (parameters.pass != RenderPass::Translucent)
|
||||
return;
|
||||
|
||||
const auto& evaluated = static_cast<const RasterLayerProperties&>(*evaluatedProperties).evaluated;
|
||||
RasterProgram::Binders paintAttributeData{ evaluated, 0 };
|
||||
|
||||
auto draw = [&] (const mat4& matrix,
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class RenderRasterLayer: public RenderLayer {
|
||||
class RenderRasterLayer final : public RenderLayer {
|
||||
public:
|
||||
RenderRasterLayer(Immutable<style::RasterLayer::Impl>);
|
||||
~RenderRasterLayer() final = default;
|
||||
explicit RenderRasterLayer(Immutable<style::RasterLayer::Impl>);
|
||||
~RenderRasterLayer() override;
|
||||
|
||||
private:
|
||||
void transition(const TransitionParameters&) override;
|
||||
void evaluate(const PropertyEvaluationParameters&) override;
|
||||
bool hasTransition() const override;
|
||||
@@ -20,9 +21,6 @@ public:
|
||||
|
||||
// Paint properties
|
||||
style::RasterPaintProperties::Unevaluated unevaluated;
|
||||
style::RasterPaintProperties::PossiblyEvaluated evaluated;
|
||||
|
||||
const style::RasterLayer::Impl& impl() const;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -306,24 +306,29 @@ void drawText(const DrawFn& draw,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
inline const SymbolLayer::Impl& impl(const Immutable<style::Layer::Impl>& impl) {
|
||||
return static_cast<const SymbolLayer::Impl&>(*impl);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
RenderSymbolLayer::RenderSymbolLayer(Immutable<style::SymbolLayer::Impl> _impl)
|
||||
: RenderLayer(std::move(_impl)),
|
||||
unevaluated(impl().paint.untransitioned()) {
|
||||
: RenderLayer(makeMutable<SymbolLayerProperties>(std::move(_impl))),
|
||||
unevaluated(impl(baseImpl).paint.untransitioned()) {
|
||||
}
|
||||
|
||||
const style::SymbolLayer::Impl& RenderSymbolLayer::impl() const {
|
||||
return static_cast<const style::SymbolLayer::Impl&>(*baseImpl);
|
||||
}
|
||||
RenderSymbolLayer::~RenderSymbolLayer() = default;
|
||||
|
||||
void RenderSymbolLayer::transition(const TransitionParameters& parameters) {
|
||||
unevaluated = impl().paint.transitioned(parameters, std::move(unevaluated));
|
||||
unevaluated = impl(baseImpl).paint.transitioned(parameters, std::move(unevaluated));
|
||||
}
|
||||
|
||||
void RenderSymbolLayer::evaluate(const PropertyEvaluationParameters& parameters) {
|
||||
evaluated = unevaluated.evaluate(parameters);
|
||||
|
||||
auto properties = makeMutable<SymbolLayerProperties>(
|
||||
staticImmutableCast<SymbolLayer::Impl>(baseImpl),
|
||||
unevaluated.evaluate(parameters));
|
||||
const auto& evaluated = properties->evaluated;
|
||||
auto hasIconOpacity = evaluated.get<style::IconColor>().constantOr(Color::black()).a > 0 ||
|
||||
evaluated.get<style::IconHaloColor>().constantOr(Color::black()).a > 0;
|
||||
auto hasTextOpacity = evaluated.get<style::TextColor>().constantOr(Color::black()).a > 0 ||
|
||||
@@ -332,6 +337,7 @@ void RenderSymbolLayer::evaluate(const PropertyEvaluationParameters& parameters)
|
||||
passes = ((evaluated.get<style::IconOpacity>().constantOr(1) > 0 && hasIconOpacity && iconSize > 0)
|
||||
|| (evaluated.get<style::TextOpacity>().constantOr(1) > 0 && hasTextOpacity && textSize > 0))
|
||||
? RenderPass::Translucent : RenderPass::None;
|
||||
evaluatedProperties = std::move(properties);
|
||||
}
|
||||
|
||||
bool RenderSymbolLayer::hasTransition() const {
|
||||
@@ -363,7 +369,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
return;
|
||||
}
|
||||
|
||||
const bool sortFeaturesByKey = !impl().layout.get<SymbolSortKey>().isUndefined();
|
||||
const bool sortFeaturesByKey = !impl(baseImpl).layout.get<SymbolSortKey>().isUndefined();
|
||||
std::set<RenderableSegment> renderableSegments;
|
||||
|
||||
const auto draw = [¶meters, this] (auto& programInstance,
|
||||
@@ -598,6 +604,7 @@ void RenderSymbolLayer::setRenderTiles(RenderTiles tiles, const TransformState&
|
||||
|
||||
void RenderSymbolLayer::updateBucketPaintProperties(Bucket* bucket) const {
|
||||
assert(bucket->supportsLayer(*baseImpl));
|
||||
const auto& evaluated = static_cast<const SymbolLayerProperties&>(*evaluatedProperties).evaluated;
|
||||
static_cast<SymbolBucket*>(bucket)->updatePaintProperties(getID(), evaluated);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,15 +53,15 @@ public:
|
||||
|
||||
} // namespace style
|
||||
|
||||
class BucketParameters;
|
||||
class SymbolLayout;
|
||||
class GeometryTileLayer;
|
||||
|
||||
class RenderSymbolLayer final: public RenderLayer, public RenderLayerSymbolInterface {
|
||||
public:
|
||||
RenderSymbolLayer(Immutable<style::SymbolLayer::Impl>);
|
||||
~RenderSymbolLayer() final = default;
|
||||
explicit RenderSymbolLayer(Immutable<style::SymbolLayer::Impl>);
|
||||
~RenderSymbolLayer() override;
|
||||
|
||||
static style::IconPaintProperties::PossiblyEvaluated iconPaintProperties(const style::SymbolPaintProperties::PossiblyEvaluated&);
|
||||
static style::TextPaintProperties::PossiblyEvaluated textPaintProperties(const style::SymbolPaintProperties::PossiblyEvaluated&);
|
||||
|
||||
private:
|
||||
void transition(const TransitionParameters&) override;
|
||||
void evaluate(const PropertyEvaluationParameters&) override;
|
||||
bool hasTransition() const override;
|
||||
@@ -69,30 +69,20 @@ public:
|
||||
void render(PaintParameters&, RenderSource*) override;
|
||||
void setRenderTiles(RenderTiles, const TransformState&) override;
|
||||
|
||||
static style::IconPaintProperties::PossiblyEvaluated iconPaintProperties(const style::SymbolPaintProperties::PossiblyEvaluated&);
|
||||
static style::TextPaintProperties::PossiblyEvaluated textPaintProperties(const style::SymbolPaintProperties::PossiblyEvaluated&);
|
||||
|
||||
// RenderLayerSymbolInterface overrides
|
||||
const RenderLayerSymbolInterface* getSymbolInterface() const final;
|
||||
const std::string& layerID() const final;
|
||||
const std::vector<std::reference_wrapper<RenderTile>>& getRenderTiles() const final;
|
||||
SymbolBucket* getSymbolBucket(const RenderTile&) const final;
|
||||
const RenderLayerSymbolInterface* getSymbolInterface() const override;
|
||||
const std::string& layerID() const override;
|
||||
const std::vector<std::reference_wrapper<RenderTile>>& getRenderTiles() const override;
|
||||
SymbolBucket* getSymbolBucket(const RenderTile&) const override;
|
||||
|
||||
// Paint properties
|
||||
style::SymbolPaintProperties::Unevaluated unevaluated;
|
||||
style::SymbolPaintProperties::PossiblyEvaluated evaluated;
|
||||
|
||||
float iconSize = 1.0f;
|
||||
float textSize = 16.0f;
|
||||
|
||||
const style::SymbolLayer::Impl& impl() const;
|
||||
|
||||
protected:
|
||||
void updateBucketPaintProperties(Bucket*) const final;
|
||||
};
|
||||
|
||||
inline const RenderSymbolLayer* toRenderSymbolLayer(const RenderLayer* layer) {
|
||||
return static_cast<const RenderSymbolLayer*>(layer);
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -10,8 +10,9 @@ namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
RenderLayer::RenderLayer(Immutable<style::Layer::Impl> baseImpl_)
|
||||
: baseImpl(std::move(baseImpl_)) {
|
||||
RenderLayer::RenderLayer(Immutable<style::LayerProperties> properties)
|
||||
: evaluatedProperties(std::move(properties)),
|
||||
baseImpl(evaluatedProperties->baseImpl) {
|
||||
}
|
||||
|
||||
void RenderLayer::setImpl(Immutable<style::Layer::Impl> impl) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <mbgl/layout/layout.hpp>
|
||||
#include <mbgl/renderer/render_pass.hpp>
|
||||
#include <mbgl/style/layer_impl.hpp>
|
||||
#include <mbgl/style/layer_properties.hpp>
|
||||
#include <mbgl/tile/geometry_tile_data.hpp>
|
||||
#include <mbgl/util/mat4.hpp>
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
namespace mbgl {
|
||||
|
||||
class Bucket;
|
||||
class BucketParameters;
|
||||
class TransitionParameters;
|
||||
class PropertyEvaluationParameters;
|
||||
class PaintParameters;
|
||||
@@ -22,7 +21,7 @@ class TransformState;
|
||||
|
||||
class RenderLayer {
|
||||
protected:
|
||||
RenderLayer(Immutable<style::Layer::Impl>);
|
||||
RenderLayer(Immutable<style::LayerProperties>);
|
||||
|
||||
public:
|
||||
virtual ~RenderLayer() = default;
|
||||
@@ -31,6 +30,7 @@ public:
|
||||
virtual void transition(const TransitionParameters&) = 0;
|
||||
|
||||
// Fully evaluate possibly-transitioning paint properties based on a zoom level.
|
||||
// Updates the contained `evaluatedProperties` member.
|
||||
virtual void evaluate(const PropertyEvaluationParameters&) = 0;
|
||||
|
||||
// Returns true if any paint properties have active transitions.
|
||||
@@ -65,6 +65,8 @@ public:
|
||||
using RenderTiles = std::vector<std::reference_wrapper<RenderTile>>;
|
||||
virtual void setRenderTiles(RenderTiles, const TransformState&);
|
||||
|
||||
// Latest evaluated properties.
|
||||
Immutable<style::LayerProperties> evaluatedProperties;
|
||||
// Private implementation
|
||||
Immutable<style::Layer::Impl> baseImpl;
|
||||
void setImpl(Immutable<style::Layer::Impl>);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/style/layer_impl.hpp>
|
||||
#include <mbgl/style/layer_properties.hpp>
|
||||
#include <mbgl/style/layers/custom_layer.hpp>
|
||||
|
||||
#include <memory>
|
||||
@@ -24,5 +25,11 @@ public:
|
||||
DECLARE_LAYER_TYPE_INFO;
|
||||
};
|
||||
|
||||
class CustomLayerProperties final : public LayerProperties {
|
||||
public:
|
||||
explicit CustomLayerProperties(Immutable<CustomLayer::Impl> impl)
|
||||
: LayerProperties(std::move(impl)) {}
|
||||
};
|
||||
|
||||
} // namespace style
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -312,22 +312,23 @@ void GeometryTileWorker::requestNewImages(const ImageDependencies& imageDependen
|
||||
}
|
||||
}
|
||||
|
||||
static std::vector<std::unique_ptr<RenderLayer>> toRenderLayers(const std::vector<Immutable<style::Layer::Impl>>& layers, float zoom) {
|
||||
std::vector<std::unique_ptr<RenderLayer>> renderLayers;
|
||||
renderLayers.reserve(layers.size());
|
||||
static std::vector<Immutable<style::LayerProperties>> toEvaluatedProperties(const std::vector<Immutable<style::Layer::Impl>>& layers, float zoom) {
|
||||
std::vector<Immutable<style::LayerProperties>> result;
|
||||
result.reserve(layers.size());
|
||||
for (auto& layer : layers) {
|
||||
renderLayers.push_back(LayerManager::get()->createRenderLayer(layer));
|
||||
auto renderLayer = LayerManager::get()->createRenderLayer(layer);
|
||||
|
||||
renderLayers.back()->transition(TransitionParameters {
|
||||
renderLayer->transition(TransitionParameters {
|
||||
Clock::time_point::max(),
|
||||
TransitionOptions()
|
||||
});
|
||||
|
||||
renderLayers.back()->evaluate(PropertyEvaluationParameters {
|
||||
renderLayer->evaluate(PropertyEvaluationParameters {
|
||||
zoom
|
||||
});
|
||||
result.push_back(renderLayer->evaluatedProperties);
|
||||
}
|
||||
return renderLayers;
|
||||
return result;
|
||||
}
|
||||
|
||||
void GeometryTileWorker::parse() {
|
||||
@@ -348,10 +349,14 @@ void GeometryTileWorker::parse() {
|
||||
ImageDependencies imageDependencies;
|
||||
|
||||
// Create render layers and group by layout
|
||||
std::vector<std::unique_ptr<RenderLayer>> renderLayers = toRenderLayers(*layers, id.overscaledZ);
|
||||
std::vector<std::vector<const RenderLayer*>> groups = groupByLayout(renderLayers);
|
||||
std::vector<Immutable<style::LayerProperties>> evaluatedProperties = toEvaluatedProperties(*layers, id.overscaledZ);
|
||||
std::unordered_map<std::string, std::vector<Immutable<style::LayerProperties>>> groupMap;
|
||||
for (auto layer : evaluatedProperties) {
|
||||
groupMap[layoutKey(*layer->baseImpl)].push_back(std::move(layer));
|
||||
}
|
||||
|
||||
for (auto& group : groups) {
|
||||
for (auto& pair : groupMap) {
|
||||
const auto& group = pair.second;
|
||||
if (obsolete) {
|
||||
return;
|
||||
}
|
||||
@@ -360,35 +365,35 @@ void GeometryTileWorker::parse() {
|
||||
continue; // Tile has no data.
|
||||
}
|
||||
|
||||
const RenderLayer& leader = *group.at(0);
|
||||
BucketParameters parameters { id, mode, pixelRatio, leader.baseImpl->getTypeInfo() };
|
||||
const style::Layer::Impl& leaderImpl = *(group.at(0)->baseImpl);
|
||||
BucketParameters parameters { id, mode, pixelRatio, leaderImpl.getTypeInfo() };
|
||||
|
||||
auto geometryLayer = (*data)->getLayer(leader.baseImpl->sourceLayer);
|
||||
auto geometryLayer = (*data)->getLayer(leaderImpl.sourceLayer);
|
||||
if (!geometryLayer) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::vector<std::string> layerIDs;
|
||||
std::vector<std::string> layerIDs(group.size());
|
||||
for (const auto& layer : group) {
|
||||
layerIDs.push_back(layer->getID());
|
||||
layerIDs.push_back(layer->baseImpl->id);
|
||||
}
|
||||
|
||||
featureIndex->setBucketLayerIDs(leader.getID(), layerIDs);
|
||||
featureIndex->setBucketLayerIDs(leaderImpl.id, layerIDs);
|
||||
|
||||
// Symbol layers and layers that support pattern properties have an extra step at layout time to figure out what images/glyphs
|
||||
// are needed to render the layer. They use the intermediate Layout data structure to accomplish this,
|
||||
// and either immediately create a bucket if no images/glyphs are used, or the Layout is stored until
|
||||
// the images/glyphs are available to add the features to the buckets.
|
||||
if (leader.baseImpl->getTypeInfo()->layout == LayerTypeInfo::Layout::Required) {
|
||||
auto layout = LayerManager::get()->createLayout({parameters, glyphDependencies, imageDependencies}, std::move(geometryLayer), group);
|
||||
if (leaderImpl.getTypeInfo()->layout == LayerTypeInfo::Layout::Required) {
|
||||
std::unique_ptr<Layout> layout = LayerManager::get()->createLayout({parameters, glyphDependencies, imageDependencies}, std::move(geometryLayer), group);
|
||||
if (layout->hasDependencies()) {
|
||||
layouts.push_back(std::move(layout));
|
||||
} else {
|
||||
layout->createBucket({}, featureIndex, buckets, firstLoad, showCollisionBoxes);
|
||||
}
|
||||
} else {
|
||||
const Filter& filter = leader.baseImpl->filter;
|
||||
const std::string& sourceLayerID = leader.baseImpl->sourceLayer;
|
||||
const Filter& filter = leaderImpl.filter;
|
||||
const std::string& sourceLayerID = leaderImpl.sourceLayer;
|
||||
std::shared_ptr<Bucket> bucket = LayerManager::get()->createBucket(parameters, group);
|
||||
|
||||
for (std::size_t i = 0; !obsolete && i < geometryLayer->featureCount(); i++) {
|
||||
@@ -399,7 +404,7 @@ void GeometryTileWorker::parse() {
|
||||
|
||||
GeometryCollection geometries = feature->getGeometries();
|
||||
bucket->addFeature(*feature, geometries, {}, PatternLayerMap ());
|
||||
featureIndex->insert(geometries, i, sourceLayerID, leader.getID());
|
||||
featureIndex->insert(geometries, i, sourceLayerID, leaderImpl.id);
|
||||
}
|
||||
|
||||
if (!bucket->hasData()) {
|
||||
@@ -407,7 +412,7 @@ void GeometryTileWorker::parse() {
|
||||
}
|
||||
|
||||
for (const auto& layer : group) {
|
||||
buckets.emplace(layer->getID(), bucket);
|
||||
buckets.emplace(layer->baseImpl->id, bucket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,6 @@ class GeometryTile;
|
||||
class GeometryTileData;
|
||||
class Layout;
|
||||
|
||||
template <class B>
|
||||
class PatternLayout;
|
||||
|
||||
namespace style {
|
||||
class Layer;
|
||||
} // namespace style
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
#include <mbgl/test/util.hpp>
|
||||
|
||||
#include <mbgl/layermanager/layer_manager.hpp>
|
||||
#include <mbgl/renderer/group_by_layout.hpp>
|
||||
#include <mbgl/renderer/render_layer.hpp>
|
||||
#include <mbgl/style/layers/background_layer.hpp>
|
||||
#include <mbgl/style/layers/circle_layer.hpp>
|
||||
#include <mbgl/style/layers/line_layer.hpp>
|
||||
#include <mbgl/style/expression/dsl.hpp>
|
||||
|
||||
using namespace mbgl;
|
||||
using namespace mbgl::style;
|
||||
using namespace mbgl::style::expression;
|
||||
|
||||
static std::vector<std::unique_ptr<RenderLayer>> toRenderLayers(const std::vector<std::unique_ptr<Layer>>& layers) {
|
||||
std::vector<std::unique_ptr<RenderLayer>> result;
|
||||
result.reserve(layers.size());
|
||||
for (auto& layer : layers) {
|
||||
result.push_back(LayerManager::get()->createRenderLayer(layer->baseImpl));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
TEST(GroupByLayout, Related) {
|
||||
std::vector<std::unique_ptr<Layer>> layers;
|
||||
layers.push_back(std::make_unique<LineLayer>("a", "source"));
|
||||
layers.push_back(std::make_unique<LineLayer>("b", "source"));
|
||||
auto result = groupByLayout(toRenderLayers(layers));
|
||||
ASSERT_EQ(1u, result.size());
|
||||
ASSERT_EQ(2u, result[0].size());
|
||||
}
|
||||
|
||||
TEST(GroupByLayout, UnrelatedType) {
|
||||
std::vector<std::unique_ptr<Layer>> layers;
|
||||
layers.push_back(std::make_unique<BackgroundLayer>("background"));
|
||||
layers.push_back(std::make_unique<CircleLayer>("circle", "source"));
|
||||
auto result = groupByLayout(toRenderLayers(layers));
|
||||
ASSERT_EQ(2u, result.size());
|
||||
}
|
||||
|
||||
TEST(GroupByLayout, UnrelatedFilter) {
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
std::vector<std::unique_ptr<Layer>> layers;
|
||||
auto lineLayer = std::make_unique<LineLayer>("a", "source");
|
||||
lineLayer->setFilter(Filter(get("property")));
|
||||
layers.push_back(std::move(lineLayer));
|
||||
layers.push_back(std::make_unique<LineLayer>("b", "source"));
|
||||
auto result = groupByLayout(toRenderLayers(layers));
|
||||
ASSERT_EQ(2u, result.size());
|
||||
}
|
||||
|
||||
TEST(GroupByLayout, UnrelatedLayout) {
|
||||
std::vector<std::unique_ptr<Layer>> layers;
|
||||
auto lineLayer = std::make_unique<LineLayer>("a", "source");
|
||||
lineLayer->setLineCap(LineCapType::Square);
|
||||
layers.push_back(std::move(lineLayer));
|
||||
layers.push_back(std::make_unique<LineLayer>("b", "source"));
|
||||
auto result = groupByLayout(toRenderLayers(layers));
|
||||
ASSERT_EQ(2u, result.size());
|
||||
}
|
||||
@@ -28,7 +28,6 @@
|
||||
"test/programs/binary_program.test.cpp",
|
||||
"test/programs/symbol_program.test.cpp",
|
||||
"test/renderer/backend_scope.test.cpp",
|
||||
"test/renderer/group_by_layout.test.cpp",
|
||||
"test/renderer/image_manager.test.cpp",
|
||||
"test/sprite/sprite_loader.test.cpp",
|
||||
"test/sprite/sprite_parser.test.cpp",
|
||||
|
||||
Reference in New Issue
Block a user