rename StyleBucket* => StyleLayout*

and remove a few unused variables

refs #881
This commit is contained in:
Konstantin Käfer
2015-02-17 18:09:34 -08:00
parent 89c0ff5f39
commit c07fa06994
26 changed files with 290 additions and 264 deletions

View File

@@ -7,7 +7,7 @@ using namespace mbgl;
RasterTileData::RasterTileData(Tile::ID const& id_, TexturePool& texturePool, const SourceInfo& source_, FileSource& fileSource_)
: TileData(id_, source_, fileSource_),
bucket(texturePool, properties) {
bucket(texturePool, layout) {
}
RasterTileData::~RasterTileData() {

View File

@@ -3,6 +3,7 @@
#include <mbgl/map/tile.hpp>
#include <mbgl/map/tile_data.hpp>
#include <mbgl/style/style_layout.hpp>
#include <mbgl/renderer/raster_bucket.hpp>
namespace mbgl {
@@ -24,7 +25,7 @@ public:
virtual bool hasData(StyleLayer const& layer_desc) const;
protected:
StyleBucketRaster properties;
StyleLayoutRaster layout;
RasterBucket bucket;
};

View File

@@ -190,7 +190,7 @@ TileData::State Source::addTile(Map& map, uv::worker& worker,
new_tile.data = std::make_shared<VectorTileData>(normalized_id, map.getMaxZoom(), style,
glyphAtlas, glyphStore,
spriteAtlas, sprite,
texturePool, info, fileSource);
info, fileSource);
} else if (info.type == SourceType::Raster) {
new_tile.data = std::make_shared<RasterTileData>(normalized_id, texturePool, info, fileSource);
} else {

View File

@@ -3,6 +3,7 @@
#include <mbgl/style/style.hpp>
#include <mbgl/style/style_layer.hpp>
#include <mbgl/style/style_layer_group.hpp>
#include <mbgl/style/style_layout.hpp>
#include <mbgl/renderer/fill_bucket.hpp>
#include <mbgl/renderer/line_bucket.hpp>
#include <mbgl/renderer/symbol_bucket.hpp>
@@ -33,8 +34,7 @@ TileParser::TileParser(const std::string &data, VectorTileData &tile_,
GlyphAtlas & glyphAtlas_,
GlyphStore & glyphStore_,
SpriteAtlas & spriteAtlas_,
const util::ptr<Sprite> &sprite_,
TexturePool& texturePool_)
const util::ptr<Sprite> &sprite_)
: vector_data(pbf((const uint8_t *)data.data(), data.size())),
tile(tile_),
style(style_),
@@ -42,7 +42,6 @@ TileParser::TileParser(const std::string &data, VectorTileData &tile_,
glyphStore(glyphStore_),
spriteAtlas(spriteAtlas_),
sprite(sprite_),
texturePool(texturePool_),
collision(util::make_unique<Collision>(tile.id.z, 4096, tile.source.tile_size, tile.depth)) {
assert(&tile != nullptr);
assert(style);
@@ -123,18 +122,25 @@ void applyLayoutProperty(PropertyKey key, const ClassProperties &classProperties
}
}
void parseLayoutProperties(StyleBucketFill &/*fill*/, const StyleBucket &/*bucket*/, const float /*z*/) {
std::unique_ptr<StyleLayoutFill> parseStyleLayoutFill(const StyleBucket &/*bucket*/, const float /*z*/) {
// no-op; Fill buckets don't currently have any applicable layout properties
auto fillPtr = util::make_unique<StyleLayoutFill>();
return fillPtr;
}
void parseLayoutProperties(StyleBucketLine &line, const StyleBucket &bucket_desc, const float z) {
std::unique_ptr<StyleLayoutLine> parseStyleLayoutLine(const StyleBucket &bucket_desc, const float z) {
auto linePtr = util::make_unique<StyleLayoutLine>();
auto &line = *linePtr;
applyLayoutProperty(PropertyKey::LineCap, bucket_desc.layout, line.cap, z);
applyLayoutProperty(PropertyKey::LineJoin, bucket_desc.layout, line.join, z);
applyLayoutProperty(PropertyKey::LineMiterLimit, bucket_desc.layout, line.miter_limit, z);
applyLayoutProperty(PropertyKey::LineRoundLimit, bucket_desc.layout, line.round_limit, z);
return linePtr;
}
void parseLayoutProperties(StyleBucketSymbol &symbol, const StyleBucket &bucket_desc, const float z) {
std::unique_ptr<StyleLayoutSymbol> parseStyleLayoutSymbol(const StyleBucket &bucket_desc, const float z) {
auto symbolPtr = util::make_unique<StyleLayoutSymbol>();
auto &symbol = *symbolPtr;
applyLayoutProperty(PropertyKey::SymbolPlacement, bucket_desc.layout, symbol.placement, z);
if (symbol.placement == PlacementType::Line) {
symbol.icon.rotation_alignment = RotationAlignmentType::Map;
@@ -172,6 +178,7 @@ void parseLayoutProperties(StyleBucketSymbol &symbol, const StyleBucket &bucket_
applyLayoutProperty(PropertyKey::TextTransform, bucket_desc.layout, symbol.text.transform, z);
applyLayoutProperty(PropertyKey::TextOffset, bucket_desc.layout, symbol.text.offset, z);
applyLayoutProperty(PropertyKey::TextAllowOverlap, bucket_desc.layout, symbol.text.allow_overlap, z);
return symbolPtr;
}
std::unique_ptr<Bucket> TileParser::createBucket(const StyleBucket &bucket_desc) {
@@ -225,8 +232,7 @@ void TileParser::addBucketGeometries(Bucket& bucket, const VectorTileLayer& laye
std::unique_ptr<Bucket> TileParser::createFillBucket(const VectorTileLayer &layer,
const StyleBucket &bucket_desc) {
auto fill = util::make_unique<StyleBucketFill>();
parseLayoutProperties(*fill, bucket_desc, tile.id.z);
auto fill = parseStyleLayoutFill(bucket_desc, tile.id.z);
auto bucket = util::make_unique<FillBucket>(std::move(fill),
tile.fillVertexBuffer,
tile.triangleElementsBuffer,
@@ -235,15 +241,9 @@ std::unique_ptr<Bucket> TileParser::createFillBucket(const VectorTileLayer &laye
return obsolete() ? nullptr : std::move(bucket);
}
std::unique_ptr<Bucket> TileParser::createRasterBucket(const StyleBucketRaster &raster) {
std::unique_ptr<RasterBucket> bucket = util::make_unique<RasterBucket>(texturePool, raster);
return obsolete() ? nullptr : std::move(bucket);
}
std::unique_ptr<Bucket> TileParser::createLineBucket(const VectorTileLayer &layer,
const StyleBucket &bucket_desc) {
auto line = util::make_unique<StyleBucketLine>();
parseLayoutProperties(*line, bucket_desc, tile.id.z);
auto line = parseStyleLayoutLine(bucket_desc, tile.id.z);
auto bucket = util::make_unique<LineBucket>(std::move(line),
tile.lineVertexBuffer,
tile.triangleElementsBuffer,
@@ -254,8 +254,7 @@ std::unique_ptr<Bucket> TileParser::createLineBucket(const VectorTileLayer &laye
std::unique_ptr<Bucket> TileParser::createSymbolBucket(const VectorTileLayer &layer,
const StyleBucket &bucket_desc) {
auto symbol = util::make_unique<StyleBucketSymbol>();
parseLayoutProperties(*symbol, bucket_desc, tile.id.z);
auto symbol = parseStyleLayoutSymbol(bucket_desc, tile.id.z);
auto bucket = util::make_unique<SymbolBucket>(std::move(symbol), *collision);
bucket->addFeatures(
layer, bucket_desc.filter, tile.id, spriteAtlas, *sprite, glyphAtlas, glyphStore);

View File

@@ -23,10 +23,10 @@ class SpriteAtlas;
class Sprite;
class Style;
class StyleBucket;
class StyleBucketFill;
class StyleBucketRaster;
class StyleBucketLine;
class StyleBucketSymbol;
class StyleLayoutFill;
class StyleLayoutRaster;
class StyleLayoutLine;
class StyleLayoutSymbol;
class StyleLayerGroup;
class VectorTileData;
class Collision;
@@ -40,8 +40,7 @@ public:
GlyphAtlas & glyphAtlas,
GlyphStore & glyphStore,
SpriteAtlas & spriteAtlas,
const util::ptr<Sprite> &sprite,
TexturePool& texturePool);
const util::ptr<Sprite> &sprite);
~TileParser();
public:
@@ -53,7 +52,6 @@ private:
std::unique_ptr<Bucket> createBucket(const StyleBucket &bucket_desc);
std::unique_ptr<Bucket> createFillBucket(const VectorTileLayer &layer, const StyleBucket &bucket_desc);
std::unique_ptr<Bucket> createRasterBucket(const StyleBucketRaster &raster);
std::unique_ptr<Bucket> createLineBucket(const VectorTileLayer& layer, const StyleBucket &bucket_desc);
std::unique_ptr<Bucket> createSymbolBucket(const VectorTileLayer& layer, const StyleBucket &bucket_desc);
@@ -69,7 +67,6 @@ private:
GlyphStore & glyphStore;
SpriteAtlas & spriteAtlas;
util::ptr<Sprite> sprite;
TexturePool& texturePool;
std::unique_ptr<Collision> collision;
};

View File

@@ -13,14 +13,12 @@ VectorTileData::VectorTileData(Tile::ID const& id_,
float mapMaxZoom, util::ptr<Style> style_,
GlyphAtlas& glyphAtlas_, GlyphStore& glyphStore_,
SpriteAtlas& spriteAtlas_, util::ptr<Sprite> sprite_,
TexturePool& texturePool_,
const SourceInfo& source_, FileSource &fileSource_)
: TileData(id_, source_, fileSource_),
glyphAtlas(glyphAtlas_),
glyphStore(glyphStore_),
spriteAtlas(spriteAtlas_),
sprite(sprite_),
texturePool(texturePool_),
style(style_),
depth(id.z >= source.max_zoom ? mapMaxZoom - id.z : 1) {
}
@@ -45,8 +43,7 @@ void VectorTileData::parse() {
// is going to be discarded afterwards.
TileParser parser(data, *this, style,
glyphAtlas, glyphStore,
spriteAtlas, sprite,
texturePool);
spriteAtlas, sprite);
// Clear the style so that we don't have a cycle in the shared_ptr references.
style.reset();

View File

@@ -24,7 +24,6 @@ class GlyphAtlas;
class GlyphStore;
class SpriteAtlas;
class Sprite;
class TexturePool;
class Style;
class VectorTileData : public TileData {
@@ -35,7 +34,6 @@ public:
float mapMaxZoom, util::ptr<Style>,
GlyphAtlas&, GlyphStore&,
SpriteAtlas&, util::ptr<Sprite>,
TexturePool&,
const SourceInfo&, FileSource &);
~VectorTileData();
@@ -62,7 +60,6 @@ protected:
GlyphStore& glyphStore;
SpriteAtlas& spriteAtlas;
util::ptr<Sprite> sprite;
TexturePool& texturePool;
util::ptr<Style> style;
public:

View File

@@ -5,6 +5,7 @@
#include <mbgl/renderer/painter.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/style/style_layout.hpp>
#include <mbgl/map/vector_tile.hpp>
#include <mbgl/util/std.hpp>
@@ -31,11 +32,11 @@ void FillBucket::free(void *, void *ptr) {
::free(ptr);
}
FillBucket::FillBucket(std::unique_ptr<const StyleBucketFill> layout_,
FillBucket::FillBucket(std::unique_ptr<const StyleLayoutFill> styleLayout_,
FillVertexBuffer &vertexBuffer_,
TriangleElementsBuffer &triangleElementsBuffer_,
LineElementsBuffer &lineElementsBuffer_)
: layout(std::move(layout_)),
: styleLayout(std::move(styleLayout_)),
allocator(new TESSalloc{
&alloc,
&realloc,
@@ -56,7 +57,7 @@ FillBucket::FillBucket(std::unique_ptr<const StyleBucketFill> layout_,
triangle_elements_start(triangleElementsBuffer_.index()),
line_elements_start(lineElementsBuffer.index()) {
assert(tesselator);
assert(layout);
assert(styleLayout);
}
FillBucket::~FillBucket() {

View File

@@ -19,6 +19,7 @@
namespace mbgl {
class Style;
class StyleLayoutFill;
class FillVertexBuffer;
class TriangleElementsBuffer;
class LineElementsBuffer;
@@ -38,7 +39,7 @@ class FillBucket : public Bucket {
typedef ElementGroup<1> line_group_type;
public:
FillBucket(std::unique_ptr<const StyleBucketFill> layout,
FillBucket(std::unique_ptr<const StyleLayoutFill> styleLayout,
FillVertexBuffer &vertexBuffer,
TriangleElementsBuffer &triangleElementsBuffer,
LineElementsBuffer &lineElementsBuffer);
@@ -55,7 +56,7 @@ public:
void drawVertices(OutlineShader& shader);
public:
const std::unique_ptr<const StyleBucketFill> layout;
const std::unique_ptr<const StyleLayoutFill> styleLayout;
private:
TESSalloc *allocator;

View File

@@ -4,6 +4,7 @@
#include <mbgl/renderer/painter.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/style/style_layout.hpp>
#include <mbgl/map/vector_tile.hpp>
#include <mbgl/util/math.hpp>
@@ -18,20 +19,25 @@ struct geometry_too_long_exception : std::exception {};
using namespace mbgl;
LineBucket::LineBucket(std::unique_ptr<const StyleBucketLine> layout_,
LineBucket::LineBucket(std::unique_ptr<const StyleLayoutLine> styleLayout_,
LineVertexBuffer &vertexBuffer_,
TriangleElementsBuffer &triangleElementsBuffer_,
PointElementsBuffer &pointElementsBuffer_)
: layout(std::move(layout_)),
: styleLayout(std::move(styleLayout_)),
vertexBuffer(vertexBuffer_),
triangleElementsBuffer(triangleElementsBuffer_),
pointElementsBuffer(pointElementsBuffer_),
vertex_start(vertexBuffer_.index()),
triangle_elements_start(triangleElementsBuffer_.index()),
point_elements_start(pointElementsBuffer_.index()) {
assert(layout);
assert(styleLayout);
}
LineBucket::~LineBucket() {
// Do not remove. header file only contains forward definitions to unique pointers.
}
void LineBucket::addGeometry(pbf& geom) {
std::vector<Coordinate> line;
Geometry::command cmd;
@@ -61,8 +67,7 @@ struct TriangleElement {
typedef uint16_t PointElement;
void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
assert(layout);
auto &properties = *layout;
auto &layout = *styleLayout;
// TODO: use roundLimit
// const float roundLimit = geometry.round_limit;
@@ -80,8 +85,8 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
return;
}
CapType beginCap = properties.cap;
CapType endCap = closed ? CapType::Butt : properties.cap;
CapType beginCap = layout.cap;
CapType endCap = closed ? CapType::Butt : layout.cap;
JoinType currentJoin = JoinType::Miter;
@@ -111,7 +116,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
if (currentVertex) prevVertex = currentVertex;
currentVertex = vertices[i];
currentJoin = properties.join;
currentJoin = layout.join;
if (prevVertex) distance += util::dist<double>(currentVertex, prevVertex);
@@ -164,7 +169,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
// Switch to miter joins if the angle is very low.
if (currentJoin != JoinType::Miter) {
if (std::fabs(joinAngularity) < 0.5 && roundness < properties.miter_limit) {
if (std::fabs(joinAngularity) < 0.5 && roundness < layout.miter_limit) {
currentJoin = JoinType::Miter;
}
}
@@ -213,14 +218,14 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
// The two normals are almost parallel.
joinNormal.x = -nextNormal.y;
joinNormal.y = nextNormal.x;
} else if (roundness > properties.miter_limit) {
} else if (roundness > layout.miter_limit) {
// If the miter grows too large, flip the direction to make a
// bevel join.
joinNormal.x = (prevNormal.x - nextNormal.x) / joinAngularity;
joinNormal.y = (prevNormal.y - nextNormal.y) / joinAngularity;
}
if (roundness > properties.miter_limit) {
if (roundness > layout.miter_limit) {
flip = -flip;
}

View File

@@ -6,12 +6,14 @@
#include <mbgl/geometry/elements_buffer.hpp>
#include <mbgl/geometry/line_buffer.hpp>
#include <mbgl/style/style_bucket.hpp>
#include <mbgl/util/vec.hpp>
#include <vector>
namespace mbgl {
class Style;
class StyleLayoutLine;
class LineVertexBuffer;
class TriangleElementsBuffer;
class LineShader;
@@ -25,10 +27,11 @@ class LineBucket : public Bucket {
typedef ElementGroup<1> point_group_type;
public:
LineBucket(std::unique_ptr<const StyleBucketLine> layout,
LineBucket(std::unique_ptr<const StyleLayoutLine> styleLayout,
LineVertexBuffer &vertexBuffer,
TriangleElementsBuffer &triangleElementsBuffer,
PointElementsBuffer &pointElementsBuffer);
~LineBucket();
virtual void render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix);
virtual bool hasData() const;
@@ -44,7 +47,7 @@ public:
void drawPoints(LinejoinShader& shader);
public:
const std::unique_ptr<const StyleBucketLine> layout;
const std::unique_ptr<const StyleLayoutLine> styleLayout;
private:
LineVertexBuffer& vertexBuffer;

View File

@@ -2,6 +2,7 @@
#include <mbgl/renderer/fill_bucket.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/style/style_layer.hpp>
#include <mbgl/style/style_layout.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/sprite.hpp>
#include <mbgl/geometry/sprite_atlas.hpp>

View File

@@ -2,6 +2,7 @@
#include <mbgl/renderer/line_bucket.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/style/style_layer.hpp>
#include <mbgl/style/style_layout.hpp>
#include <mbgl/map/sprite.hpp>
#include <mbgl/geometry/sprite_atlas.hpp>
#include <mbgl/geometry/line_atlas.hpp>
@@ -15,7 +16,7 @@ void Painter::renderLine(LineBucket& bucket, util::ptr<StyleLayer> layer_desc, c
if (!bucket.hasData()) return;
const auto &properties = layer_desc->getProperties<LineProperties>();
const auto &layout = *bucket.layout;
const auto &layout = *bucket.styleLayout;
// the distance over which the line edge fades out.
// Retina devices need a smaller distance to avoid aliasing.

View File

@@ -1,6 +1,7 @@
#include <mbgl/renderer/painter.hpp>
#include <mbgl/renderer/symbol_bucket.hpp>
#include <mbgl/style/style_layer.hpp>
#include <mbgl/style/style_layout.hpp>
#include <mbgl/geometry/glyph_atlas.hpp>
#include <mbgl/geometry/sprite_atlas.hpp>
#include <mbgl/map/map.hpp>
@@ -118,7 +119,7 @@ void Painter::renderSymbol(SymbolBucket &bucket, util::ptr<StyleLayer> layer_des
}
const auto &properties = layer_desc->getProperties<SymbolProperties>();
const auto &layout = *bucket.layout;
const auto &layout = *bucket.styleLayout;
MBGL_CHECK_ERROR(glDisable(GL_STENCIL_TEST));

View File

@@ -3,8 +3,8 @@
using namespace mbgl;
RasterBucket::RasterBucket(TexturePool& texturePool, const StyleBucketRaster& properties_)
: properties(properties_),
RasterBucket::RasterBucket(TexturePool& texturePool, const StyleLayoutRaster& layout_)
: layout(layout_),
raster(texturePool) {
}

View File

@@ -9,20 +9,21 @@
namespace mbgl {
class StyleLayoutRaster;
class RasterShader;
class StaticVertexBuffer;
class VertexArrayObject;
class RasterBucket : public Bucket {
public:
RasterBucket(TexturePool&, const StyleBucketRaster&);
RasterBucket(TexturePool&, const StyleLayoutRaster&);
virtual void render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix);
virtual bool hasData() const;
bool setImage(const std::string &data);
const StyleBucketRaster &properties;
const StyleLayoutRaster &layout;
void drawRaster(RasterShader& shader, StaticVertexBuffer &vertices, VertexArrayObject &array);

View File

@@ -1,3 +1,4 @@
#include <mbgl/style/style_layout.hpp>
#include <mbgl/renderer/symbol_bucket.hpp>
#include <mbgl/geometry/text_buffer.hpp>
#include <mbgl/geometry/icon_buffer.hpp>
@@ -20,9 +21,13 @@
namespace mbgl {
SymbolBucket::SymbolBucket(std::unique_ptr<const StyleBucketSymbol> layout_, Collision &collision_)
: layout(std::move(layout_)), collision(collision_) {
assert(layout);
SymbolBucket::SymbolBucket(std::unique_ptr<const StyleLayoutSymbol> styleLayout_, Collision &collision_)
: styleLayout(std::move(styleLayout_)), collision(collision_) {
assert(styleLayout);
}
SymbolBucket::~SymbolBucket() {
// Do not remove. header file only contains forward definitions to unique pointers.
}
void SymbolBucket::render(Painter &painter, util::ptr<StyleLayer> layer_desc,
@@ -46,9 +51,9 @@ std::vector<SymbolFeature> SymbolBucket::processFeatures(const VectorTileLayer &
const FilterExpression &filter,
GlyphStore &glyphStore,
const Sprite &sprite) {
auto &properties = *layout;
const bool has_text = properties.text.field.size();
const bool has_icon = properties.icon.image.size();
auto &layout = *styleLayout;
const bool has_text = layout.text.field.size();
const bool has_icon = layout.icon.image.size();
std::vector<SymbolFeature> features;
@@ -66,11 +71,11 @@ std::vector<SymbolFeature> SymbolBucket::processFeatures(const VectorTileLayer &
SymbolFeature ft;
if (has_text) {
std::string u8string = util::replaceTokens(properties.text.field, feature.properties);
std::string u8string = util::replaceTokens(layout.text.field, feature.properties);
if (properties.text.transform == TextTransformType::Uppercase) {
if (layout.text.transform == TextTransformType::Uppercase) {
u8string = platform::uppercase(u8string);
} else if (properties.text.transform == TextTransformType::Lowercase) {
} else if (layout.text.transform == TextTransformType::Lowercase) {
u8string = platform::lowercase(u8string);
}
@@ -85,7 +90,7 @@ std::vector<SymbolFeature> SymbolBucket::processFeatures(const VectorTileLayer &
}
if (has_icon) {
ft.sprite = util::replaceTokens(properties.icon.image, feature.properties);
ft.sprite = util::replaceTokens(layout.icon.image, feature.properties);
}
if (ft.label.length() || ft.sprite.length()) {
@@ -110,11 +115,11 @@ std::vector<SymbolFeature> SymbolBucket::processFeatures(const VectorTileLayer &
}
}
if (properties.placement == PlacementType::Line) {
if (layout.placement == PlacementType::Line) {
util::mergeLines(features);
}
glyphStore.waitForGlyphRanges(properties.text.font, ranges);
glyphStore.waitForGlyphRanges(layout.text.font, ranges);
sprite.waitUntilLoaded();
return features;
@@ -123,13 +128,13 @@ std::vector<SymbolFeature> SymbolBucket::processFeatures(const VectorTileLayer &
void SymbolBucket::addFeatures(const VectorTileLayer &layer, const FilterExpression &filter,
const Tile::ID &id, SpriteAtlas &spriteAtlas, Sprite &sprite,
GlyphAtlas & glyphAtlas, GlyphStore &glyphStore) {
auto &properties = *layout;
auto &layout = *styleLayout;
const std::vector<SymbolFeature> features = processFeatures(layer, filter, glyphStore, sprite);
float horizontalAlign = 0.5;
float verticalAlign = 0.5;
switch (properties.text.anchor) {
switch (layout.text.anchor) {
case TextAnchorType::Top:
case TextAnchorType::Bottom:
case TextAnchorType::Center:
@@ -146,7 +151,7 @@ void SymbolBucket::addFeatures(const VectorTileLayer &layer, const FilterExpress
break;
}
switch (properties.text.anchor) {
switch (layout.text.anchor) {
case TextAnchorType::Left:
case TextAnchorType::Right:
case TextAnchorType::Center:
@@ -164,10 +169,10 @@ void SymbolBucket::addFeatures(const VectorTileLayer &layer, const FilterExpress
}
float justify = 0.5;
if (properties.text.justify == TextJustifyType::Right) justify = 1;
else if (properties.text.justify == TextJustifyType::Left) justify = 0;
if (layout.text.justify == TextJustifyType::Right) justify = 1;
else if (layout.text.justify == TextJustifyType::Left) justify = 0;
const FontStack &fontStack = glyphStore.getFontStack(properties.text.font);
const FontStack &fontStack = glyphStore.getFontStack(layout.text.font);
for (const SymbolFeature &feature : features) {
if (!feature.geometry.size()) continue;
@@ -180,17 +185,17 @@ void SymbolBucket::addFeatures(const VectorTileLayer &layer, const FilterExpress
if (feature.label.length()) {
shaping = fontStack.getShaping(
/* string */ feature.label,
/* maxWidth: ems */ properties.text.max_width * 24,
/* lineHeight: ems */ properties.text.line_height * 24,
/* maxWidth: ems */ layout.text.max_width * 24,
/* lineHeight: ems */ layout.text.line_height * 24,
/* horizontalAlign */ horizontalAlign,
/* verticalAlign */ verticalAlign,
/* justify */ justify,
/* spacing: ems */ properties.text.letter_spacing * 24,
/* translate */ vec2<float>(properties.text.offset[0], properties.text.offset[1]));
/* spacing: ems */ layout.text.letter_spacing * 24,
/* translate */ vec2<float>(layout.text.offset[0], layout.text.offset[1]));
// Add the glyphs we need for this label to the glyph atlas.
if (shaping.size()) {
SymbolBucket::addGlyphsToAtlas(id.to_uint64(), properties.text.font, feature.label, fontStack,
SymbolBucket::addGlyphsToAtlas(id.to_uint64(), layout.text.font, feature.label, fontStack,
glyphAtlas, face);
}
}
@@ -223,25 +228,25 @@ const PlacementRange fullRange{{2 * M_PI, 0}};
void SymbolBucket::addFeature(const std::vector<Coordinate> &line, const Shaping &shaping,
const GlyphPositions &face, const Rect<uint16_t> &image) {
assert(line.size());
auto &properties = *layout;
auto &layout = *styleLayout;
const float minScale = 0.5f;
const float glyphSize = 24.0f;
const bool horizontalText =
properties.text.rotation_alignment == RotationAlignmentType::Viewport;
layout.text.rotation_alignment == RotationAlignmentType::Viewport;
const bool horizontalIcon =
properties.icon.rotation_alignment == RotationAlignmentType::Viewport;
const float fontScale = properties.text.max_size / glyphSize;
layout.icon.rotation_alignment == RotationAlignmentType::Viewport;
const float fontScale = layout.text.max_size / glyphSize;
const float textBoxScale = collision.tilePixelRatio * fontScale;
const float iconBoxScale = collision.tilePixelRatio * properties.icon.max_size;
const bool iconWithoutText = properties.text.optional || !shaping.size();
const bool textWithoutIcon = properties.icon.optional || !image;
const bool avoidEdges = properties.avoid_edges && properties.placement != PlacementType::Line;
const float iconBoxScale = collision.tilePixelRatio * layout.icon.max_size;
const bool iconWithoutText = layout.text.optional || !shaping.size();
const bool textWithoutIcon = layout.icon.optional || !image;
const bool avoidEdges = layout.avoid_edges && layout.placement != PlacementType::Line;
Anchors anchors;
if (properties.placement == PlacementType::Line) {
if (layout.placement == PlacementType::Line) {
float resampleOffset = 0;
if (shaping.size()) {
@@ -256,7 +261,7 @@ void SymbolBucket::addFeature(const std::vector<Coordinate> &line, const Shaping
}
// Line labels
anchors = resample(line, properties.min_distance, minScale, collision.maxPlacementScale,
anchors = resample(line, layout.min_distance, minScale, collision.maxPlacementScale,
collision.tilePixelRatio, resampleOffset);
// Sort anchors by segment so that we can start placement with the
@@ -284,9 +289,9 @@ void SymbolBucket::addFeature(const std::vector<Coordinate> &line, const Shaping
if (shaping.size()) {
glyphPlacement = Placement::getGlyphs(anchor, origin, shaping, face, textBoxScale,
horizontalText, line, properties);
horizontalText, line, layout);
glyphScale =
properties.text.allow_overlap
layout.text.allow_overlap
? glyphPlacement.minScale
: collision.getPlacementScale(glyphPlacement.boxes, glyphPlacement.minScale, avoidEdges);
if (!glyphScale && !iconWithoutText)
@@ -294,9 +299,9 @@ void SymbolBucket::addFeature(const std::vector<Coordinate> &line, const Shaping
}
if (image) {
iconPlacement = Placement::getIcon(anchor, image, iconBoxScale, line, properties);
iconPlacement = Placement::getIcon(anchor, image, iconBoxScale, line, layout);
iconScale =
properties.icon.allow_overlap
layout.icon.allow_overlap
? iconPlacement.minScale
: collision.getPlacementScale(iconPlacement.boxes, iconPlacement.minScale, avoidEdges);
if (!iconScale && !textWithoutIcon)
@@ -313,11 +318,11 @@ void SymbolBucket::addFeature(const std::vector<Coordinate> &line, const Shaping
// Get the rotation ranges it is safe to show the glyphs
PlacementRange glyphRange =
(!glyphScale || properties.text.allow_overlap)
(!glyphScale || layout.text.allow_overlap)
? fullRange
: collision.getPlacementRange(glyphPlacement.boxes, glyphScale, horizontalText);
PlacementRange iconRange =
(!iconScale || properties.icon.allow_overlap)
(!iconScale || layout.icon.allow_overlap)
? fullRange
: collision.getPlacementRange(iconPlacement.boxes, iconScale, horizontalIcon);
@@ -335,7 +340,7 @@ void SymbolBucket::addFeature(const std::vector<Coordinate> &line, const Shaping
// Insert final placement into collision tree and add glyphs/icons to buffers
if (glyphScale && std::isfinite(glyphScale)) {
if (!properties.text.ignore_placement) {
if (!layout.text.ignore_placement) {
collision.insert(glyphPlacement.boxes, anchor, glyphScale, glyphRange,
horizontalText);
}
@@ -343,7 +348,7 @@ void SymbolBucket::addFeature(const std::vector<Coordinate> &line, const Shaping
}
if (iconScale && std::isfinite(iconScale)) {
if (!properties.icon.ignore_placement) {
if (!layout.icon.ignore_placement) {
collision.insert(iconPlacement.boxes, anchor, iconScale, iconRange, horizontalIcon);
}
if (inside) addSymbols<IconBuffer, IconElementGroup>(icon, iconPlacement.shapes, iconScale, iconRange);

View File

@@ -18,6 +18,7 @@
namespace mbgl {
class Style;
class StyleLayoutSymbol;
class SDFShader;
class IconShader;
class DotShader;
@@ -54,7 +55,8 @@ class SymbolBucket : public Bucket {
typedef ElementGroup<2> IconElementGroup;
public:
SymbolBucket(std::unique_ptr<const StyleBucketSymbol> layout, Collision &collision);
SymbolBucket(std::unique_ptr<const StyleLayoutSymbol> styleLayout, Collision &collision);
~SymbolBucket();
virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix);
virtual bool hasData() const;
@@ -89,7 +91,7 @@ private:
const FontStack &fontStack, GlyphAtlas &glyphAtlas, GlyphPositions &face);
public:
const std::unique_ptr<const StyleBucketSymbol> layout;
const std::unique_ptr<const StyleLayoutSymbol> styleLayout;
bool sdfIcons = false;
private:

View File

@@ -1,6 +1,7 @@
#include <mbgl/style/property_fallback.hpp>
#include <mbgl/style/style_properties.hpp>
#include <mbgl/style/style_bucket.hpp>
#include <mbgl/style/style_layout.hpp>
namespace mbgl {
@@ -50,44 +51,44 @@ const std::map<PropertyKey, PropertyValue> PropertyFallbackValue::properties = {
{ PropertyKey::BackgroundOpacity, defaultStyleProperties<BackgroundProperties>().opacity },
{ PropertyKey::BackgroundColor, defaultStyleProperties<BackgroundProperties>().color },
{ PropertyKey::LineCap, defaultLayoutProperties<StyleBucketLine>().cap },
{ PropertyKey::LineJoin, defaultLayoutProperties<StyleBucketLine>().join },
{ PropertyKey::LineMiterLimit, defaultLayoutProperties<StyleBucketLine>().miter_limit },
{ PropertyKey::LineRoundLimit, defaultLayoutProperties<StyleBucketLine>().round_limit },
{ PropertyKey::LineCap, defaultStyleLayout<StyleLayoutLine>().cap },
{ PropertyKey::LineJoin, defaultStyleLayout<StyleLayoutLine>().join },
{ PropertyKey::LineMiterLimit, defaultStyleLayout<StyleLayoutLine>().miter_limit },
{ PropertyKey::LineRoundLimit, defaultStyleLayout<StyleLayoutLine>().round_limit },
{ PropertyKey::SymbolPlacement, defaultLayoutProperties<StyleBucketSymbol>().placement },
{ PropertyKey::SymbolMinDistance, defaultLayoutProperties<StyleBucketSymbol>().min_distance },
{ PropertyKey::SymbolAvoidEdges, defaultLayoutProperties<StyleBucketSymbol>().avoid_edges },
{ PropertyKey::SymbolPlacement, defaultStyleLayout<StyleLayoutSymbol>().placement },
{ PropertyKey::SymbolMinDistance, defaultStyleLayout<StyleLayoutSymbol>().min_distance },
{ PropertyKey::SymbolAvoidEdges, defaultStyleLayout<StyleLayoutSymbol>().avoid_edges },
{ PropertyKey::IconAllowOverlap, defaultLayoutProperties<StyleBucketSymbol>().icon.allow_overlap },
{ PropertyKey::IconIgnorePlacement, defaultLayoutProperties<StyleBucketSymbol>().icon.ignore_placement },
{ PropertyKey::IconOptional, defaultLayoutProperties<StyleBucketSymbol>().icon.optional },
{ PropertyKey::IconRotationAlignment, defaultLayoutProperties<StyleBucketSymbol>().icon.rotation_alignment },
{ PropertyKey::IconMaxSize, defaultLayoutProperties<StyleBucketSymbol>().icon.max_size },
{ PropertyKey::IconImage, defaultLayoutProperties<StyleBucketSymbol>().icon.image },
{ PropertyKey::IconRotate, defaultLayoutProperties<StyleBucketSymbol>().icon.rotate },
{ PropertyKey::IconPadding, defaultLayoutProperties<StyleBucketSymbol>().icon.padding },
{ PropertyKey::IconKeepUpright, defaultLayoutProperties<StyleBucketSymbol>().icon.keep_upright },
{ PropertyKey::IconOffset, defaultLayoutProperties<StyleBucketSymbol>().icon.offset },
{ PropertyKey::IconAllowOverlap, defaultStyleLayout<StyleLayoutSymbol>().icon.allow_overlap },
{ PropertyKey::IconIgnorePlacement, defaultStyleLayout<StyleLayoutSymbol>().icon.ignore_placement },
{ PropertyKey::IconOptional, defaultStyleLayout<StyleLayoutSymbol>().icon.optional },
{ PropertyKey::IconRotationAlignment, defaultStyleLayout<StyleLayoutSymbol>().icon.rotation_alignment },
{ PropertyKey::IconMaxSize, defaultStyleLayout<StyleLayoutSymbol>().icon.max_size },
{ PropertyKey::IconImage, defaultStyleLayout<StyleLayoutSymbol>().icon.image },
{ PropertyKey::IconRotate, defaultStyleLayout<StyleLayoutSymbol>().icon.rotate },
{ PropertyKey::IconPadding, defaultStyleLayout<StyleLayoutSymbol>().icon.padding },
{ PropertyKey::IconKeepUpright, defaultStyleLayout<StyleLayoutSymbol>().icon.keep_upright },
{ PropertyKey::IconOffset, defaultStyleLayout<StyleLayoutSymbol>().icon.offset },
{ PropertyKey::TextRotationAlignment, defaultLayoutProperties<StyleBucketSymbol>().text.rotation_alignment },
{ PropertyKey::TextField, defaultLayoutProperties<StyleBucketSymbol>().text.field },
{ PropertyKey::TextFont, defaultLayoutProperties<StyleBucketSymbol>().text.font },
{ PropertyKey::TextMaxSize, defaultLayoutProperties<StyleBucketSymbol>().text.max_size },
{ PropertyKey::TextMaxWidth, defaultLayoutProperties<StyleBucketSymbol>().text.max_width },
{ PropertyKey::TextLineHeight, defaultLayoutProperties<StyleBucketSymbol>().text.line_height },
{ PropertyKey::TextLetterSpacing, defaultLayoutProperties<StyleBucketSymbol>().text.letter_spacing },
{ PropertyKey::TextJustify, defaultLayoutProperties<StyleBucketSymbol>().text.justify },
{ PropertyKey::TextAnchor, defaultLayoutProperties<StyleBucketSymbol>().text.anchor },
{ PropertyKey::TextMaxAngle, defaultLayoutProperties<StyleBucketSymbol>().text.max_angle },
{ PropertyKey::TextRotate, defaultLayoutProperties<StyleBucketSymbol>().text.rotate },
{ PropertyKey::TextPadding, defaultLayoutProperties<StyleBucketSymbol>().text.padding },
{ PropertyKey::TextKeepUpright, defaultLayoutProperties<StyleBucketSymbol>().text.keep_upright },
{ PropertyKey::TextTransform, defaultLayoutProperties<StyleBucketSymbol>().text.transform },
{ PropertyKey::TextOffset, defaultLayoutProperties<StyleBucketSymbol>().text.offset },
{ PropertyKey::TextAllowOverlap, defaultLayoutProperties<StyleBucketSymbol>().text.allow_overlap },
{ PropertyKey::TextIgnorePlacement, defaultLayoutProperties<StyleBucketSymbol>().text.ignore_placement },
{ PropertyKey::TextOptional, defaultLayoutProperties<StyleBucketSymbol>().text.optional },
{ PropertyKey::TextRotationAlignment, defaultStyleLayout<StyleLayoutSymbol>().text.rotation_alignment },
{ PropertyKey::TextField, defaultStyleLayout<StyleLayoutSymbol>().text.field },
{ PropertyKey::TextFont, defaultStyleLayout<StyleLayoutSymbol>().text.font },
{ PropertyKey::TextMaxSize, defaultStyleLayout<StyleLayoutSymbol>().text.max_size },
{ PropertyKey::TextMaxWidth, defaultStyleLayout<StyleLayoutSymbol>().text.max_width },
{ PropertyKey::TextLineHeight, defaultStyleLayout<StyleLayoutSymbol>().text.line_height },
{ PropertyKey::TextLetterSpacing, defaultStyleLayout<StyleLayoutSymbol>().text.letter_spacing },
{ PropertyKey::TextJustify, defaultStyleLayout<StyleLayoutSymbol>().text.justify },
{ PropertyKey::TextAnchor, defaultStyleLayout<StyleLayoutSymbol>().text.anchor },
{ PropertyKey::TextMaxAngle, defaultStyleLayout<StyleLayoutSymbol>().text.max_angle },
{ PropertyKey::TextRotate, defaultStyleLayout<StyleLayoutSymbol>().text.rotate },
{ PropertyKey::TextPadding, defaultStyleLayout<StyleLayoutSymbol>().text.padding },
{ PropertyKey::TextKeepUpright, defaultStyleLayout<StyleLayoutSymbol>().text.keep_upright },
{ PropertyKey::TextTransform, defaultStyleLayout<StyleLayoutSymbol>().text.transform },
{ PropertyKey::TextOffset, defaultStyleLayout<StyleLayoutSymbol>().text.offset },
{ PropertyKey::TextAllowOverlap, defaultStyleLayout<StyleLayoutSymbol>().text.allow_overlap },
{ PropertyKey::TextIgnorePlacement, defaultStyleLayout<StyleLayoutSymbol>().text.ignore_placement },
{ PropertyKey::TextOptional, defaultStyleLayout<StyleLayoutSymbol>().text.optional },
};

View File

@@ -1,14 +0,0 @@
#include <mbgl/style/style_bucket.hpp>
namespace mbgl {
template<> const StyleBucketFill &defaultLayoutProperties() { static StyleBucketFill p; return p; }
template<> const StyleBucketLine &defaultLayoutProperties() { static StyleBucketLine p; return p; }
template<> const StyleBucketSymbol &defaultLayoutProperties() { static StyleBucketSymbol p; return p; }
template<> const StyleBucketRaster &defaultLayoutProperties() { static StyleBucketRaster p; return p; }
template<> const StyleBucketBackground &defaultLayoutProperties() { static StyleBucketBackground p; return p; }
StyleBucket::StyleBucket(StyleLayerType type_) : type(type_) {
}
}

View File

@@ -4,112 +4,21 @@
#include <mbgl/style/types.hpp>
#include <mbgl/style/filter_expression.hpp>
#include <mbgl/style/style_source.hpp>
#include <mbgl/util/vec.hpp>
#include <mbgl/util/variant.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/ptr.hpp>
#include <mbgl/style/class_properties.hpp>
#include <forward_list>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/ptr.hpp>
namespace mbgl {
class Source;
class StyleBucketFill {
public:
// Make movable only.
StyleBucketFill() = default;
StyleBucketFill(StyleBucketFill &&) = default;
StyleBucketFill& operator=(StyleBucketFill &&) = default;
StyleBucketFill(const StyleBucketFill &) = delete;
StyleBucketFill& operator=(const StyleBucketFill &) = delete;
};
class StyleBucketLine {
public:
// Make movable only.
StyleBucketLine() = default;
StyleBucketLine(StyleBucketLine &&) = default;
StyleBucketLine& operator=(StyleBucketLine &&) = default;
StyleBucketLine(const StyleBucketLine &) = delete;
StyleBucketLine& operator=(const StyleBucketLine &) = delete;
CapType cap = CapType::Butt;
JoinType join = JoinType::Miter;
float miter_limit = 2.0f;
float round_limit = 1.0f;
};
class StyleBucketSymbol {
public:
// Make movable only.
StyleBucketSymbol() = default;
StyleBucketSymbol(StyleBucketSymbol &&) = default;
StyleBucketSymbol& operator=(StyleBucketSymbol &&) = default;
StyleBucketSymbol(const StyleBucketSymbol &) = delete;
StyleBucketSymbol& operator=(const StyleBucketSymbol &) = delete;
PlacementType placement = PlacementType::Point;
float min_distance = 250.0f;
bool avoid_edges = false;
struct {
bool allow_overlap = false;
bool ignore_placement = false;
bool optional = false;
RotationAlignmentType rotation_alignment = RotationAlignmentType::Viewport;
float max_size = 1.0f;
std::string image;
float rotate = 0.0f;
float padding = 2.0f;
bool keep_upright = false;
std::array<float, 2> offset = {{ 0, 0 }};
} icon;
struct {
RotationAlignmentType rotation_alignment = RotationAlignmentType::Viewport;
std::string field;
std::string font;
float max_size = 16.0f;
float max_width = 15.0f /* em */;
float line_height = 1.2f /* em */;
float letter_spacing = 0.0f /* em */;
TextJustifyType justify = TextJustifyType::Center;
TextAnchorType anchor = TextAnchorType::Center;
float max_angle = 45.0f /* degrees */;
float rotate = 0.0f;
float padding = 2.0f;
bool keep_upright = true;
TextTransformType transform = TextTransformType::None;
std::array<float, 2> offset = {{ 0, 0 }};
bool allow_overlap = false;
bool ignore_placement = false;
bool optional = false;
} text;
};
class StyleBucketRaster {
public:
// Make movable only.
StyleBucketRaster() = default;
StyleBucketRaster(StyleBucketRaster &&) = default;
StyleBucketRaster& operator=(StyleBucketRaster &&) = default;
StyleBucketRaster(const StyleBucketRaster &) = delete;
StyleBucketRaster& operator=(const StyleBucketRaster &) = delete;
};
class StyleBucketBackground {
public:
};
class StyleBucket : public util::noncopyable {
public:
typedef util::ptr<StyleBucket> Ptr;
StyleBucket(StyleLayerType type);
StyleLayerType type;
inline StyleBucket(StyleLayerType type_) : type(type_) {}
const StyleLayerType type;
std::string name;
util::ptr<StyleSource> style_source;
std::string source_layer;
@@ -120,9 +29,6 @@ public:
VisibilityType visibility = VisibilityType::Visible;
};
template <typename T>
const T &defaultLayoutProperties();
};
#endif

View File

@@ -0,0 +1,11 @@
#include <mbgl/style/style_layout.hpp>
namespace mbgl {
template<> const StyleLayoutFill &defaultStyleLayout() { static StyleLayoutFill p; return p; }
template<> const StyleLayoutLine &defaultStyleLayout() { static StyleLayoutLine p; return p; }
template<> const StyleLayoutSymbol &defaultStyleLayout() { static StyleLayoutSymbol p; return p; }
template<> const StyleLayoutRaster &defaultStyleLayout() { static StyleLayoutRaster p; return p; }
template<> const StyleLayoutBackground &defaultStyleLayout() { static StyleLayoutBackground p; return p; }
}

View File

@@ -0,0 +1,108 @@
#ifndef MBGL_STYLE_STYLE_LAYOUT
#define MBGL_STYLE_STYLE_LAYOUT
#include <mbgl/style/types.hpp>
namespace mbgl {
class Source;
class StyleLayoutFill {
public:
// Make movable only.
StyleLayoutFill() = default;
StyleLayoutFill(StyleLayoutFill &&) = default;
StyleLayoutFill& operator=(StyleLayoutFill &&) = default;
StyleLayoutFill(const StyleLayoutFill &) = delete;
StyleLayoutFill& operator=(const StyleLayoutFill &) = delete;
};
class StyleLayoutLine {
public:
// Make movable only.
StyleLayoutLine() = default;
StyleLayoutLine(StyleLayoutLine &&) = default;
StyleLayoutLine& operator=(StyleLayoutLine &&) = default;
StyleLayoutLine(const StyleLayoutLine &) = delete;
StyleLayoutLine& operator=(const StyleLayoutLine &) = delete;
CapType cap = CapType::Butt;
JoinType join = JoinType::Miter;
float miter_limit = 2.0f;
float round_limit = 1.0f;
};
class StyleLayoutSymbol {
public:
// Make movable only.
StyleLayoutSymbol() = default;
StyleLayoutSymbol(StyleLayoutSymbol &&) = default;
StyleLayoutSymbol& operator=(StyleLayoutSymbol &&) = default;
StyleLayoutSymbol(const StyleLayoutSymbol &) = delete;
StyleLayoutSymbol& operator=(const StyleLayoutSymbol &) = delete;
PlacementType placement = PlacementType::Point;
float min_distance = 250.0f;
bool avoid_edges = false;
struct {
bool allow_overlap = false;
bool ignore_placement = false;
bool optional = false;
RotationAlignmentType rotation_alignment = RotationAlignmentType::Viewport;
float max_size = 1.0f;
std::string image;
float rotate = 0.0f;
float padding = 2.0f;
bool keep_upright = false;
std::array<float, 2> offset = {{ 0, 0 }};
} icon;
struct {
RotationAlignmentType rotation_alignment = RotationAlignmentType::Viewport;
std::string field;
std::string font;
float max_size = 16.0f;
float max_width = 15.0f /* em */;
float line_height = 1.2f /* em */;
float letter_spacing = 0.0f /* em */;
TextJustifyType justify = TextJustifyType::Center;
TextAnchorType anchor = TextAnchorType::Center;
float max_angle = 45.0f /* degrees */;
float rotate = 0.0f;
float padding = 2.0f;
bool keep_upright = true;
TextTransformType transform = TextTransformType::None;
std::array<float, 2> offset = {{ 0, 0 }};
bool allow_overlap = false;
bool ignore_placement = false;
bool optional = false;
} text;
};
class StyleLayoutRaster {
public:
// Make movable only.
StyleLayoutRaster() = default;
StyleLayoutRaster(StyleLayoutRaster &&) = default;
StyleLayoutRaster& operator=(StyleLayoutRaster &&) = default;
StyleLayoutRaster(const StyleLayoutRaster &) = delete;
StyleLayoutRaster& operator=(const StyleLayoutRaster &) = delete;
};
class StyleLayoutBackground {
public:
// Make movable only.
StyleLayoutBackground() = default;
StyleLayoutBackground(StyleLayoutBackground &&) = default;
StyleLayoutBackground& operator=(StyleLayoutBackground &&) = default;
StyleLayoutBackground(const StyleLayoutBackground &) = delete;
StyleLayoutBackground& operator=(const StyleLayoutBackground &) = delete;
};
template <typename T>
const T &defaultStyleLayout();
};
#endif

View File

@@ -3,6 +3,7 @@
#include <mbgl/style/style_layer_group.hpp>
#include <mbgl/util/constants.hpp>
#include <mbgl/util/std.hpp>
#include <mbgl/util/vec.hpp>
#include <mbgl/platform/log.hpp>
#include <csscolorparser/csscolorparser.hpp>

View File

@@ -4,6 +4,7 @@
#include <mbgl/text/placement.hpp>
#include <mbgl/text/glyph_store.hpp>
#include <mbgl/style/style_bucket.hpp>
#include <mbgl/style/style_layout.hpp>
#include <mbgl/util/math.hpp>
@@ -129,10 +130,10 @@ GlyphBox getMergedBoxes(const GlyphBoxes &glyphs, const Anchor &anchor) {
}
Placement Placement::getIcon(Anchor &anchor, const Rect<uint16_t> &image, float boxScale,
const std::vector<Coordinate> &line, const StyleBucketSymbol &props) {
const std::vector<Coordinate> &line, const StyleLayoutSymbol &layout) {
const float dx = props.icon.offset[0];
const float dy = props.icon.offset[1];
const float dx = layout.icon.offset[0];
const float dy = layout.icon.offset[1];
float x1 = dx - image.originalW / 2.0f;
float x2 = x1 + image.w;
float y1 = dy - image.originalH / 2.0f;
@@ -143,8 +144,8 @@ Placement Placement::getIcon(Anchor &anchor, const Rect<uint16_t> &image, float
vec2<float> br{x2, y2};
vec2<float> bl{x1, y2};
float angle = props.icon.rotate * M_PI / 180.0f;
if (anchor.segment >= 0 && props.icon.rotation_alignment != RotationAlignmentType::Viewport) {
float angle = layout.icon.rotate * M_PI / 180.0f;
if (anchor.segment >= 0 && layout.icon.rotation_alignment != RotationAlignmentType::Viewport) {
const Coordinate &next = line[anchor.segment];
angle += -std::atan2(next.x - anchor.x, next.y - anchor.y) + M_PI / 2;
}
@@ -178,7 +179,7 @@ Placement Placement::getIcon(Anchor &anchor, const Rect<uint16_t> &image, float
/* anchor */ anchor,
/* minScale */ Placement::globalMinScale,
/* maxScale */ std::numeric_limits<float>::infinity(),
/* padding */ props.icon.padding);
/* padding */ layout.icon.padding);
placement.shapes.emplace_back(
/* tl */ tl,
@@ -199,12 +200,12 @@ Placement Placement::getIcon(Anchor &anchor, const Rect<uint16_t> &image, float
Placement Placement::getGlyphs(Anchor &anchor, const vec2<float> &origin, const Shaping &shaping,
const GlyphPositions &face, float boxScale, bool horizontal,
const std::vector<Coordinate> &line,
const StyleBucketSymbol &props) {
const float maxAngle = props.text.max_angle * M_PI / 180;
const float rotate = props.text.rotate * M_PI / 180;
const float padding = props.text.padding;
const bool alongLine = props.text.rotation_alignment != RotationAlignmentType::Viewport;
const bool keepUpright = props.text.keep_upright;
const StyleLayoutSymbol &layout) {
const float maxAngle = layout.text.max_angle * M_PI / 180;
const float rotate = layout.text.rotate * M_PI / 180;
const float padding = layout.text.padding;
const bool alongLine = layout.text.rotation_alignment != RotationAlignmentType::Viewport;
const bool keepUpright = layout.text.keep_upright;
Placement placement;

View File

@@ -9,16 +9,16 @@
namespace mbgl {
struct Anchor;
class StyleBucketSymbol;
class StyleLayoutSymbol;
class Placement {
public:
static Placement getIcon(Anchor &anchor, const Rect<uint16_t> &image, float iconBoxScale,
const std::vector<Coordinate> &line, const StyleBucketSymbol &props);
const std::vector<Coordinate> &line, const StyleLayoutSymbol &layout);
static Placement getGlyphs(Anchor &anchor, const vec2<float> &origin, const Shaping &shaping,
const GlyphPositions &face, float boxScale, bool horizontal,
const std::vector<Coordinate> &line, const StyleBucketSymbol &props);
const std::vector<Coordinate> &line, const StyleLayoutSymbol &layout);
static const float globalMinScale;