#include #include #include #include #include #include #include namespace mbgl { RenderSymbolLayer::RenderSymbolLayer(Immutable _impl) : RenderLayer(style::LayerType::Symbol, _impl), unevaluated(impl().paint.untransitioned()) { } const style::SymbolLayer::Impl& RenderSymbolLayer::impl() const { return static_cast(*baseImpl); } std::unique_ptr RenderSymbolLayer::createBucket(const BucketParameters&, const std::vector&) const { assert(false); // Should be calling createLayout() instead. return nullptr; } std::unique_ptr RenderSymbolLayer::createLayout(const BucketParameters& parameters, const std::vector& group, std::unique_ptr layer, GlyphDependencies& glyphDependencies, ImageDependencies& imageDependencies) const { return std::make_unique(parameters, group, std::move(layer), imageDependencies, glyphDependencies); } void RenderSymbolLayer::transition(const TransitionParameters& parameters) { unevaluated = impl().paint.transitioned(parameters, std::move(unevaluated)); } void RenderSymbolLayer::evaluate(const PropertyEvaluationParameters& parameters) { evaluated = unevaluated.evaluate(parameters); auto hasIconOpacity = evaluated.get().constantOr(Color::black()).a > 0 || evaluated.get().constantOr(Color::black()).a > 0; auto hasTextOpacity = evaluated.get().constantOr(Color::black()).a > 0 || evaluated.get().constantOr(Color::black()).a > 0; passes = ((evaluated.get().constantOr(1) > 0 && hasIconOpacity && iconSize > 0) || (evaluated.get().constantOr(1) > 0 && hasTextOpacity && textSize > 0)) ? RenderPass::Translucent : RenderPass::None; } bool RenderSymbolLayer::hasTransition() const { return unevaluated.hasTransition(); } style::IconPaintProperties::PossiblyEvaluated RenderSymbolLayer::iconPaintProperties() const { return style::IconPaintProperties::PossiblyEvaluated { evaluated.get(), evaluated.get(), evaluated.get(), evaluated.get(), evaluated.get(), evaluated.get(), evaluated.get() }; } style::TextPaintProperties::PossiblyEvaluated RenderSymbolLayer::textPaintProperties() const { return style::TextPaintProperties::PossiblyEvaluated { evaluated.get(), evaluated.get(), evaluated.get(), evaluated.get(), evaluated.get(), evaluated.get(), evaluated.get() }; } style::SymbolPropertyValues RenderSymbolLayer::iconPropertyValues(const style::SymbolLayoutProperties::PossiblyEvaluated& layout_) const { return style::SymbolPropertyValues { layout_.get(), // icon-pitch-alignment is not yet implemented; inherit the rotation alignment layout_.get(), evaluated.get(), evaluated.get(), evaluated.get().constantOr(Color::black()).a > 0 && evaluated.get().constantOr(1), evaluated.get().constantOr(Color::black()).a > 0, 10.0f }; } style::SymbolPropertyValues RenderSymbolLayer::textPropertyValues(const style::SymbolLayoutProperties::PossiblyEvaluated& layout_) const { // We hide line labels with viewport alignment as they move into the distance // because the approximations we use for drawing their glyphs get progressively worse // The "1.5" here means we start hiding them when the distance from the label // to the camera is 50% greater than the distance from the center of the map // to the camera. Depending on viewport properties, you might expect this to filter // the top third of the screen at pitch 60, and do almost nothing at pitch 45 // "10" is effectively infinite at any pitch we support const bool limitMaxDistance = layout_.get() == style::SymbolPlacementType::Line && layout_.get() == style::AlignmentType::Map && layout_.get() == style::AlignmentType::Viewport; return style::SymbolPropertyValues { layout_.get(), layout_.get(), evaluated.get(), evaluated.get(), evaluated.get().constantOr(Color::black()).a > 0 && evaluated.get().constantOr(1), evaluated.get().constantOr(Color::black()).a > 0, limitMaxDistance ? 1.5f : 10.0f }; } } // namespace mbgl