[core] There's only ever one icon quad

This commit is contained in:
John Firebaugh
2017-02-24 13:56:05 -08:00
parent 02d56488e4
commit e18f60229e
7 changed files with 217 additions and 214 deletions

View File

@@ -16,17 +16,15 @@ SymbolInstance::SymbolInstance(Anchor& anchor, const GeometryCoordinates& line,
hasText(shapedTextOrientations.first || shapedTextOrientations.second),
hasIcon(shapedIcon),
// Create the quad used for rendering the icon.
iconQuads(addToBuffers && shapedIcon ?
getIconQuads(anchor, shapedIcon, line, layout, iconPlacement, shapedTextOrientations.first) :
SymbolQuads()),
// Create the collision features that will be used to check whether this symbol instance can be placed
textCollisionFeature(line, anchor, shapedTextOrientations.second ?: shapedTextOrientations.first, textBoxScale, textPadding, textPlacement, indexedFeature),
iconCollisionFeature(line, anchor, shapedIcon, iconBoxScale, iconPadding, iconPlacement, indexedFeature) {
// Create the quads used for rendering the glyphs.
// Create the quads used for rendering the icon and glyphs.
if (addToBuffers) {
if (shapedIcon) {
iconQuad = getIconQuad(anchor, shapedIcon, line, layout, iconPlacement, shapedTextOrientations.first);
}
if (shapedTextOrientations.first) {
auto quads = getGlyphQuads(anchor, shapedTextOrientations.first, textBoxScale, line, layout, textPlacement, face);
glyphQuads.insert(glyphQuads.end(), quads.begin(), quads.end());

View File

@@ -24,7 +24,7 @@ public:
bool hasText;
bool hasIcon;
SymbolQuads glyphQuads;
SymbolQuads iconQuads;
optional<SymbolQuad> iconQuad;
CollisionFeature textCollisionFeature;
CollisionFeature iconCollisionFeature;
WritingModeType writingModes;

View File

@@ -430,6 +430,8 @@ std::unique_ptr<SymbolBucket> SymbolLayout::place(CollisionTile& collisionTile)
const bool mayOverlap = layout.get<TextAllowOverlap>() || layout.get<IconAllowOverlap>() ||
layout.get<TextIgnorePlacement>() || layout.get<IconIgnorePlacement>();
const bool keepUpright = layout.get<TextKeepUpright>();
// Sort symbols by their y position on the canvas so that they lower symbols
// are drawn on top of higher symbols.
// Don't sort symbols that won't overlap because it isn't necessary and
@@ -481,20 +483,24 @@ std::unique_ptr<SymbolBucket> SymbolLayout::place(CollisionTile& collisionTile)
// Insert final placement into collision tree and add glyphs/icons to buffers
if (hasText) {
const float placementZoom = util::max(util::log2(glyphScale) + zoom, 0.0f);
collisionTile.insertFeature(symbolInstance.textCollisionFeature, glyphScale, layout.get<TextIgnorePlacement>());
if (glyphScale < collisionTile.maxScale) {
addSymbols(
bucket->text, symbolInstance.glyphQuads, glyphScale,
layout.get<TextKeepUpright>(), textPlacement, collisionTile.config.angle, symbolInstance.writingModes);
for (const auto& symbol : symbolInstance.glyphQuads) {
addSymbol(
bucket->text, symbol, placementZoom,
keepUpright, textPlacement, collisionTile.config.angle, symbolInstance.writingModes);
}
}
}
if (hasIcon) {
const float placementZoom = util::max(util::log2(iconScale) + zoom, 0.0f);
collisionTile.insertFeature(symbolInstance.iconCollisionFeature, iconScale, layout.get<IconIgnorePlacement>());
if (iconScale < collisionTile.maxScale) {
addSymbols(
bucket->icon, symbolInstance.iconQuads, iconScale,
layout.get<IconKeepUpright>(), iconPlacement, collisionTile.config.angle, symbolInstance.writingModes);
if (iconScale < collisionTile.maxScale && symbolInstance.iconQuad) {
addSymbol(
bucket->icon, *symbolInstance.iconQuad, placementZoom,
keepUpright, iconPlacement, collisionTile.config.angle, symbolInstance.writingModes);
}
}
}
@@ -507,73 +513,76 @@ std::unique_ptr<SymbolBucket> SymbolLayout::place(CollisionTile& collisionTile)
}
template <typename Buffer>
void SymbolLayout::addSymbols(Buffer &buffer, const SymbolQuads &symbols, float scale, const bool keepUpright, const style::SymbolPlacementType placement, const float placementAngle, WritingModeType writingModes) {
void SymbolLayout::addSymbol(Buffer& buffer,
const SymbolQuad& symbol,
const float placementZoom,
const bool keepUpright,
const style::SymbolPlacementType placement,
const float placementAngle,
const WritingModeType writingModes) {
constexpr const uint16_t vertexLength = 4;
const float placementZoom = util::max(util::log2(scale) + zoom, 0.0f);
for (const auto& symbol : symbols) {
const auto &tl = symbol.tl;
const auto &tr = symbol.tr;
const auto &bl = symbol.bl;
const auto &br = symbol.br;
const auto &tex = symbol.tex;
const auto &tl = symbol.tl;
const auto &tr = symbol.tr;
const auto &bl = symbol.bl;
const auto &br = symbol.br;
const auto &tex = symbol.tex;
float minZoom = util::max(zoom + util::log2(symbol.minScale), placementZoom);
float maxZoom = util::min(zoom + util::log2(symbol.maxScale), util::MAX_ZOOM_F);
const auto &anchorPoint = symbol.anchorPoint;
float minZoom = util::max(zoom + util::log2(symbol.minScale), placementZoom);
float maxZoom = util::min(zoom + util::log2(symbol.maxScale), util::MAX_ZOOM_F);
const auto &anchorPoint = symbol.anchorPoint;
// drop incorrectly oriented glyphs
const float a = std::fmod(symbol.anchorAngle + placementAngle + M_PI, M_PI * 2);
if (writingModes & WritingModeType::Vertical) {
if (placement == style::SymbolPlacementType::Line && symbol.writingMode == WritingModeType::Vertical) {
if (keepUpright && placement == style::SymbolPlacementType::Line && (a <= (M_PI * 5 / 4) || a > (M_PI * 7 / 4)))
continue;
} else if (keepUpright && placement == style::SymbolPlacementType::Line && (a <= (M_PI * 3 / 4) || a > (M_PI * 5 / 4)))
continue;
} else if (keepUpright && placement == style::SymbolPlacementType::Line &&
(a <= M_PI / 2 || a > M_PI * 3 / 2)) {
continue;
}
if (maxZoom <= minZoom)
continue;
// Lower min zoom so that while fading out the label
// it can be shown outside of collision-free zoom levels
if (minZoom == placementZoom) {
minZoom = 0;
}
if (buffer.segments.empty() || buffer.segments.back().vertexLength + vertexLength > std::numeric_limits<uint16_t>::max()) {
buffer.segments.emplace_back(buffer.vertices.vertexSize(), buffer.triangles.indexSize());
}
// We're generating triangle fans, so we always start with the first
// coordinate in this polygon.
auto& segment = buffer.segments.back();
assert(segment.vertexLength <= std::numeric_limits<uint16_t>::max());
uint16_t index = segment.vertexLength;
// Encode angle of glyph
uint8_t glyphAngle = std::round((symbol.glyphAngle / (M_PI * 2)) * 256);
// coordinates (2 triangles)
buffer.vertices.emplace_back(SymbolLayoutAttributes::vertex(anchorPoint, tl, tex.x, tex.y,
minZoom, maxZoom, placementZoom, glyphAngle));
buffer.vertices.emplace_back(SymbolLayoutAttributes::vertex(anchorPoint, tr, tex.x + tex.w, tex.y,
minZoom, maxZoom, placementZoom, glyphAngle));
buffer.vertices.emplace_back(SymbolLayoutAttributes::vertex(anchorPoint, bl, tex.x, tex.y + tex.h,
minZoom, maxZoom, placementZoom, glyphAngle));
buffer.vertices.emplace_back(SymbolLayoutAttributes::vertex(anchorPoint, br, tex.x + tex.w, tex.y + tex.h,
minZoom, maxZoom, placementZoom, glyphAngle));
// add the two triangles, referencing the four coordinates we just inserted.
buffer.triangles.emplace_back(index + 0, index + 1, index + 2);
buffer.triangles.emplace_back(index + 1, index + 2, index + 3);
segment.vertexLength += vertexLength;
segment.indexLength += 6;
// drop incorrectly oriented glyphs
const float a = std::fmod(symbol.anchorAngle + placementAngle + M_PI, M_PI * 2);
if (writingModes & WritingModeType::Vertical) {
if (placement == style::SymbolPlacementType::Line && symbol.writingMode == WritingModeType::Vertical) {
if (keepUpright && placement == style::SymbolPlacementType::Line && (a <= (M_PI * 5 / 4) || a > (M_PI * 7 / 4)))
return;
} else if (keepUpright && placement == style::SymbolPlacementType::Line && (a <= (M_PI * 3 / 4) || a > (M_PI * 5 / 4)))
return;
} else if (keepUpright && placement == style::SymbolPlacementType::Line &&
(a <= M_PI / 2 || a > M_PI * 3 / 2)) {
return;
}
if (maxZoom <= minZoom)
return;
// Lower min zoom so that while fading out the label
// it can be shown outside of collision-free zoom levels
if (minZoom == placementZoom) {
minZoom = 0;
}
if (buffer.segments.empty() || buffer.segments.back().vertexLength + vertexLength > std::numeric_limits<uint16_t>::max()) {
buffer.segments.emplace_back(buffer.vertices.vertexSize(), buffer.triangles.indexSize());
}
// We're generating triangle fans, so we always start with the first
// coordinate in this polygon.
auto& segment = buffer.segments.back();
assert(segment.vertexLength <= std::numeric_limits<uint16_t>::max());
uint16_t index = segment.vertexLength;
// Encode angle of glyph
uint8_t glyphAngle = std::round((symbol.glyphAngle / (M_PI * 2)) * 256);
// coordinates (2 triangles)
buffer.vertices.emplace_back(SymbolLayoutAttributes::vertex(anchorPoint, tl, tex.x, tex.y,
minZoom, maxZoom, placementZoom, glyphAngle));
buffer.vertices.emplace_back(SymbolLayoutAttributes::vertex(anchorPoint, tr, tex.x + tex.w, tex.y,
minZoom, maxZoom, placementZoom, glyphAngle));
buffer.vertices.emplace_back(SymbolLayoutAttributes::vertex(anchorPoint, bl, tex.x, tex.y + tex.h,
minZoom, maxZoom, placementZoom, glyphAngle));
buffer.vertices.emplace_back(SymbolLayoutAttributes::vertex(anchorPoint, br, tex.x + tex.w, tex.y + tex.h,
minZoom, maxZoom, placementZoom, glyphAngle));
// add the two triangles, referencing the four coordinates we just inserted.
buffer.triangles.emplace_back(index + 0, index + 1, index + 2);
buffer.triangles.emplace_back(index + 1, index + 2, index + 3);
segment.vertexLength += vertexLength;
segment.indexLength += 6;
}
void SymbolLayout::addToDebugBuffers(CollisionTile& collisionTile, SymbolBucket& bucket) {

View File

@@ -66,7 +66,7 @@ private:
// Adds placed items to the buffer.
template <typename Buffer>
void addSymbols(Buffer&, const SymbolQuads&, float scale,
void addSymbol(Buffer&, const SymbolQuad&, float scale,
const bool keepUpright, const style::SymbolPlacementType, const float placementAngle,
WritingModeType writingModes);

View File

@@ -13,7 +13,7 @@ using namespace style;
const float globalMinScale = 0.5f; // underscale by 1 zoom level
SymbolQuads getIconQuads(Anchor& anchor, const PositionedIcon& shapedIcon,
SymbolQuad getIconQuad(Anchor& anchor, const PositionedIcon& shapedIcon,
const GeometryCoordinates& line, const SymbolLayoutProperties::Evaluated& layout,
const style::SymbolPlacementType placement, const Shaping& shapedText) {
@@ -88,9 +88,7 @@ SymbolQuads getIconQuads(Anchor& anchor, const PositionedIcon& shapedIcon,
br = util::matrixMultiply(matrix, br);
}
SymbolQuads quads;
quads.emplace_back(tl, tr, bl, br, image.pos, 0, 0, anchor.point, globalMinScale, std::numeric_limits<float>::infinity(), shapedText.writingMode);
return quads;
return SymbolQuad { tl, tr, bl, br, image.pos, 0, 0, anchor.point, globalMinScale, std::numeric_limits<float>::infinity(), shapedText.writingMode };
}
struct GlyphInstance {

View File

@@ -38,7 +38,7 @@ struct SymbolQuad {
typedef std::vector<SymbolQuad> SymbolQuads;
SymbolQuads getIconQuads(Anchor& anchor, const PositionedIcon& shapedIcon,
SymbolQuad getIconQuad(Anchor& anchor, const PositionedIcon& shapedIcon,
const GeometryCoordinates& line, const style::SymbolLayoutProperties::Evaluated&,
style::SymbolPlacementType placement, const Shaping& shapedText);

View File

@@ -22,23 +22,22 @@ TEST(getIconQuads, normal) {
GeometryCoordinates line;
Shaping shapedText;
SymbolQuads quads =
getIconQuads(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
SymbolQuad quad =
getIconQuad(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quads.size(), 1u);
ASSERT_EQ(quads[0].anchorPoint.x, 2);
ASSERT_EQ(quads[0].anchorPoint.y, 3);
ASSERT_EQ(quads[0].tl.x, -8);
ASSERT_EQ(quads[0].tl.y, -6);
ASSERT_EQ(quads[0].tr.x, 7);
ASSERT_EQ(quads[0].tr.y, -6);
ASSERT_EQ(quads[0].bl.x, -8);
ASSERT_EQ(quads[0].bl.y, 5);
ASSERT_EQ(quads[0].br.x, 7);
ASSERT_EQ(quads[0].br.y, 5);
ASSERT_EQ(quads[0].anchorAngle, 0.0f);
ASSERT_EQ(quads[0].glyphAngle, 0.0f);
ASSERT_EQ(quads[0].minScale, 0.5f);
ASSERT_EQ(quad.anchorPoint.x, 2);
ASSERT_EQ(quad.anchorPoint.y, 3);
ASSERT_EQ(quad.tl.x, -8);
ASSERT_EQ(quad.tl.y, -6);
ASSERT_EQ(quad.tr.x, 7);
ASSERT_EQ(quad.tr.y, -6);
ASSERT_EQ(quad.bl.x, -8);
ASSERT_EQ(quad.bl.y, 5);
ASSERT_EQ(quad.br.x, 7);
ASSERT_EQ(quad.br.y, 5);
ASSERT_EQ(quad.anchorAngle, 0.0f);
ASSERT_EQ(quad.glyphAngle, 0.0f);
ASSERT_EQ(quad.minScale, 0.5f);
}
TEST(getIconQuads, style) {
@@ -61,23 +60,22 @@ TEST(getIconQuads, style) {
// none
{
SymbolLayoutProperties::Evaluated layout;
SymbolQuads quads =
getIconQuads(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
SymbolQuad quad =
getIconQuad(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quads.size(), 1u);
ASSERT_EQ(quads[0].anchorPoint.x, 0);
ASSERT_EQ(quads[0].anchorPoint.y, 0);
ASSERT_EQ(quads[0].tl.x, -11);
ASSERT_EQ(quads[0].tl.y, -11);
ASSERT_EQ(quads[0].tr.x, 9);
ASSERT_EQ(quads[0].tr.y, -11);
ASSERT_EQ(quads[0].bl.x, -11);
ASSERT_EQ(quads[0].bl.y, 9);
ASSERT_EQ(quads[0].br.x, 9);
ASSERT_EQ(quads[0].br.y, 9);
ASSERT_EQ(quads[0].anchorAngle, 0.0f);
ASSERT_EQ(quads[0].glyphAngle, 0.0f);
ASSERT_EQ(quads[0].minScale, 0.5f);
ASSERT_EQ(quad.anchorPoint.x, 0);
ASSERT_EQ(quad.anchorPoint.y, 0);
ASSERT_EQ(quad.tl.x, -11);
ASSERT_EQ(quad.tl.y, -11);
ASSERT_EQ(quad.tr.x, 9);
ASSERT_EQ(quad.tr.y, -11);
ASSERT_EQ(quad.bl.x, -11);
ASSERT_EQ(quad.bl.y, 9);
ASSERT_EQ(quad.br.x, 9);
ASSERT_EQ(quad.br.y, 9);
ASSERT_EQ(quad.anchorAngle, 0.0f);
ASSERT_EQ(quad.glyphAngle, 0.0f);
ASSERT_EQ(quad.minScale, 0.5f);
}
// width
@@ -85,17 +83,17 @@ TEST(getIconQuads, style) {
SymbolLayoutProperties::Evaluated layout;
layout.get<TextSize>() = 24.0f;
layout.get<IconTextFit>() = IconTextFitType::Width;
SymbolQuads quads =
getIconQuads(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
SymbolQuad quad =
getIconQuad(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quads[0].tl.x, -60);
ASSERT_EQ(quads[0].tl.y, 0);
ASSERT_EQ(quads[0].tr.x, 20);
ASSERT_EQ(quads[0].tr.y, 0);
ASSERT_EQ(quads[0].bl.x, -60);
ASSERT_EQ(quads[0].bl.y, 20);
ASSERT_EQ(quads[0].br.x, 20);
ASSERT_EQ(quads[0].br.y, 20);
ASSERT_EQ(quad.tl.x, -60);
ASSERT_EQ(quad.tl.y, 0);
ASSERT_EQ(quad.tr.x, 20);
ASSERT_EQ(quad.tr.y, 0);
ASSERT_EQ(quad.bl.x, -60);
ASSERT_EQ(quad.bl.y, 20);
ASSERT_EQ(quad.br.x, 20);
ASSERT_EQ(quad.br.y, 20);
}
// width x textSize
@@ -103,17 +101,17 @@ TEST(getIconQuads, style) {
SymbolLayoutProperties::Evaluated layout;
layout.get<TextSize>() = 12.0f;
layout.get<IconTextFit>() = IconTextFitType::Width;
SymbolQuads quads =
getIconQuads(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
SymbolQuad quad =
getIconQuad(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quads[0].tl.x, -30);
ASSERT_EQ(quads[0].tl.y, -5);
ASSERT_EQ(quads[0].tr.x, 10);
ASSERT_EQ(quads[0].tr.y, -5);
ASSERT_EQ(quads[0].bl.x, -30);
ASSERT_EQ(quads[0].bl.y, 15);
ASSERT_EQ(quads[0].br.x, 10);
ASSERT_EQ(quads[0].br.y, 15);
ASSERT_EQ(quad.tl.x, -30);
ASSERT_EQ(quad.tl.y, -5);
ASSERT_EQ(quad.tr.x, 10);
ASSERT_EQ(quad.tr.y, -5);
ASSERT_EQ(quad.bl.x, -30);
ASSERT_EQ(quad.bl.y, 15);
ASSERT_EQ(quad.br.x, 10);
ASSERT_EQ(quad.br.y, 15);
}
// width x textSize + padding
@@ -125,17 +123,17 @@ TEST(getIconQuads, style) {
layout.get<IconTextFitPadding>()[1] = 10.0f;
layout.get<IconTextFitPadding>()[2] = 5.0f;
layout.get<IconTextFitPadding>()[3] = 10.0f;
SymbolQuads quads =
getIconQuads(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
SymbolQuad quad =
getIconQuad(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quads[0].tl.x, -40);
ASSERT_EQ(quads[0].tl.y, -10);
ASSERT_EQ(quads[0].tr.x, 20);
ASSERT_EQ(quads[0].tr.y, -10);
ASSERT_EQ(quads[0].bl.x, -40);
ASSERT_EQ(quads[0].bl.y, 20);
ASSERT_EQ(quads[0].br.x, 20);
ASSERT_EQ(quads[0].br.y, 20);
ASSERT_EQ(quad.tl.x, -40);
ASSERT_EQ(quad.tl.y, -10);
ASSERT_EQ(quad.tr.x, 20);
ASSERT_EQ(quad.tr.y, -10);
ASSERT_EQ(quad.bl.x, -40);
ASSERT_EQ(quad.bl.y, 20);
ASSERT_EQ(quad.br.x, 20);
ASSERT_EQ(quad.br.y, 20);
}
// height
@@ -143,17 +141,17 @@ TEST(getIconQuads, style) {
SymbolLayoutProperties::Evaluated layout;
layout.get<TextSize>() = 24.0f;
layout.get<IconTextFit>() = IconTextFitType::Height;
SymbolQuads quads =
getIconQuads(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
SymbolQuad quad =
getIconQuad(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quads[0].tl.x, -30);
ASSERT_EQ(quads[0].tl.y, -10);
ASSERT_EQ(quads[0].tr.x, -10);
ASSERT_EQ(quads[0].tr.y, -10);
ASSERT_EQ(quads[0].bl.x, -30);
ASSERT_EQ(quads[0].bl.y, 30);
ASSERT_EQ(quads[0].br.x, -10);
ASSERT_EQ(quads[0].br.y, 30);
ASSERT_EQ(quad.tl.x, -30);
ASSERT_EQ(quad.tl.y, -10);
ASSERT_EQ(quad.tr.x, -10);
ASSERT_EQ(quad.tr.y, -10);
ASSERT_EQ(quad.bl.x, -30);
ASSERT_EQ(quad.bl.y, 30);
ASSERT_EQ(quad.br.x, -10);
ASSERT_EQ(quad.br.y, 30);
}
// height x textSize
@@ -161,17 +159,17 @@ TEST(getIconQuads, style) {
SymbolLayoutProperties::Evaluated layout;
layout.get<TextSize>() = 12.0f;
layout.get<IconTextFit>() = IconTextFitType::Height;
SymbolQuads quads =
getIconQuads(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
SymbolQuad quad =
getIconQuad(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quads[0].tl.x, -20);
ASSERT_EQ(quads[0].tl.y, -5);
ASSERT_EQ(quads[0].tr.x, 0);
ASSERT_EQ(quads[0].tr.y, -5);
ASSERT_EQ(quads[0].bl.x, -20);
ASSERT_EQ(quads[0].bl.y, 15);
ASSERT_EQ(quads[0].br.x, 0);
ASSERT_EQ(quads[0].br.y, 15);
ASSERT_EQ(quad.tl.x, -20);
ASSERT_EQ(quad.tl.y, -5);
ASSERT_EQ(quad.tr.x, 0);
ASSERT_EQ(quad.tr.y, -5);
ASSERT_EQ(quad.bl.x, -20);
ASSERT_EQ(quad.bl.y, 15);
ASSERT_EQ(quad.br.x, 0);
ASSERT_EQ(quad.br.y, 15);
}
// height x textSize + padding
@@ -183,17 +181,17 @@ TEST(getIconQuads, style) {
layout.get<IconTextFitPadding>()[1] = 10.0f;
layout.get<IconTextFitPadding>()[2] = 5.0f;
layout.get<IconTextFitPadding>()[3] = 10.0f;
SymbolQuads quads =
getIconQuads(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
SymbolQuad quad =
getIconQuad(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quads[0].tl.x, -30);
ASSERT_EQ(quads[0].tl.y, -10);
ASSERT_EQ(quads[0].tr.x, 10);
ASSERT_EQ(quads[0].tr.y, -10);
ASSERT_EQ(quads[0].bl.x, -30);
ASSERT_EQ(quads[0].bl.y, 20);
ASSERT_EQ(quads[0].br.x, 10);
ASSERT_EQ(quads[0].br.y, 20);
ASSERT_EQ(quad.tl.x, -30);
ASSERT_EQ(quad.tl.y, -10);
ASSERT_EQ(quad.tr.x, 10);
ASSERT_EQ(quad.tr.y, -10);
ASSERT_EQ(quad.bl.x, -30);
ASSERT_EQ(quad.bl.y, 20);
ASSERT_EQ(quad.br.x, 10);
ASSERT_EQ(quad.br.y, 20);
}
// both
@@ -201,17 +199,17 @@ TEST(getIconQuads, style) {
SymbolLayoutProperties::Evaluated layout;
layout.get<TextSize>() = 24.0f;
layout.get<IconTextFit>() = IconTextFitType::Both;
SymbolQuads quads =
getIconQuads(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
SymbolQuad quad =
getIconQuad(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quads[0].tl.x, -60);
ASSERT_EQ(quads[0].tl.y, -10);
ASSERT_EQ(quads[0].tr.x, 20);
ASSERT_EQ(quads[0].tr.y, -10);
ASSERT_EQ(quads[0].bl.x, -60);
ASSERT_EQ(quads[0].bl.y, 30);
ASSERT_EQ(quads[0].br.x, 20);
ASSERT_EQ(quads[0].br.y, 30);
ASSERT_EQ(quad.tl.x, -60);
ASSERT_EQ(quad.tl.y, -10);
ASSERT_EQ(quad.tr.x, 20);
ASSERT_EQ(quad.tr.y, -10);
ASSERT_EQ(quad.bl.x, -60);
ASSERT_EQ(quad.bl.y, 30);
ASSERT_EQ(quad.br.x, 20);
ASSERT_EQ(quad.br.y, 30);
}
// both x textSize
@@ -219,17 +217,17 @@ TEST(getIconQuads, style) {
SymbolLayoutProperties::Evaluated layout;
layout.get<TextSize>() = 12.0f;
layout.get<IconTextFit>() = IconTextFitType::Both;
SymbolQuads quads =
getIconQuads(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
SymbolQuad quad =
getIconQuad(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quads[0].tl.x, -30);
ASSERT_EQ(quads[0].tl.y, -5);
ASSERT_EQ(quads[0].tr.x, 10);
ASSERT_EQ(quads[0].tr.y, -5);
ASSERT_EQ(quads[0].bl.x, -30);
ASSERT_EQ(quads[0].bl.y, 15);
ASSERT_EQ(quads[0].br.x, 10);
ASSERT_EQ(quads[0].br.y, 15);
ASSERT_EQ(quad.tl.x, -30);
ASSERT_EQ(quad.tl.y, -5);
ASSERT_EQ(quad.tr.x, 10);
ASSERT_EQ(quad.tr.y, -5);
ASSERT_EQ(quad.bl.x, -30);
ASSERT_EQ(quad.bl.y, 15);
ASSERT_EQ(quad.br.x, 10);
ASSERT_EQ(quad.br.y, 15);
}
// both x textSize + padding
@@ -241,17 +239,17 @@ TEST(getIconQuads, style) {
layout.get<IconTextFitPadding>()[1] = 10.0f;
layout.get<IconTextFitPadding>()[2] = 5.0f;
layout.get<IconTextFitPadding>()[3] = 10.0f;
SymbolQuads quads =
getIconQuads(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
SymbolQuad quad =
getIconQuad(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quads[0].tl.x, -40);
ASSERT_EQ(quads[0].tl.y, -10);
ASSERT_EQ(quads[0].tr.x, 20);
ASSERT_EQ(quads[0].tr.y, -10);
ASSERT_EQ(quads[0].bl.x, -40);
ASSERT_EQ(quads[0].bl.y, 20);
ASSERT_EQ(quads[0].br.x, 20);
ASSERT_EQ(quads[0].br.y, 20);
ASSERT_EQ(quad.tl.x, -40);
ASSERT_EQ(quad.tl.y, -10);
ASSERT_EQ(quad.tr.x, 20);
ASSERT_EQ(quad.tr.y, -10);
ASSERT_EQ(quad.bl.x, -40);
ASSERT_EQ(quad.bl.y, 20);
ASSERT_EQ(quad.br.x, 20);
ASSERT_EQ(quad.br.y, 20);
}
// both x textSize + padding t/r/b/l
@@ -263,17 +261,17 @@ TEST(getIconQuads, style) {
layout.get<IconTextFitPadding>()[1] = 5.0f;
layout.get<IconTextFitPadding>()[2] = 10.0f;
layout.get<IconTextFitPadding>()[3] = 15.0f;
SymbolQuads quads =
getIconQuads(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
SymbolQuad quad =
getIconQuad(anchor, shapedIcon, line, layout, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quads[0].tl.x, -45);
ASSERT_EQ(quads[0].tl.y, -5);
ASSERT_EQ(quads[0].tr.x, 15);
ASSERT_EQ(quads[0].tr.y, -5);
ASSERT_EQ(quads[0].bl.x, -45);
ASSERT_EQ(quads[0].bl.y, 25);
ASSERT_EQ(quads[0].br.x, 15);
ASSERT_EQ(quads[0].br.y, 25);
ASSERT_EQ(quad.tl.x, -45);
ASSERT_EQ(quad.tl.y, -5);
ASSERT_EQ(quad.tr.x, 15);
ASSERT_EQ(quad.tr.y, -5);
ASSERT_EQ(quad.bl.x, -45);
ASSERT_EQ(quad.bl.y, 25);
ASSERT_EQ(quad.br.x, 15);
ASSERT_EQ(quad.br.y, 25);
}
}