summaryrefslogtreecommitdiff
path: root/src/text
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-05-14 17:42:10 +0200
committerKonstantin Käfer <mail@kkaefer.com>2014-05-14 17:42:10 +0200
commit51f523ec146d4bda676beea6c8f9ebb7233a3abf (patch)
tree54e0382807e68cb1a141840f29736b304702e675 /src/text
parent5e6573463045d852fb2fe9d26469ec3cb4f033ee (diff)
parenta9d559fe5158091f72f408dfa8d1d367f222348c (diff)
downloadqtlocation-mapboxgl-51f523ec146d4bda676beea6c8f9ebb7233a3abf.tar.gz
Merge branch 'master' into outdoors-style
Conflicts: bin/style.js include/llmr/map/transform.hpp src/renderer/painter.cpp src/text/placement.cpp
Diffstat (limited to 'src/text')
-rw-r--r--src/text/collision.cpp16
-rw-r--r--src/text/placement.cpp16
-rw-r--r--src/text/rotation_range.cpp24
3 files changed, 28 insertions, 28 deletions
diff --git a/src/text/collision.cpp b/src/text/collision.cpp
index 6c13023217..90837fbe64 100644
--- a/src/text/collision.cpp
+++ b/src/text/collision.cpp
@@ -104,7 +104,7 @@ PlacementProperty Collision::place(const PlacedGlyphs &placed_glyphs,
const CollisionRect &box = glyph.box;
float x12 = box.tl.x * box.tl.x, y12 = box.tl.y * box.tl.y,
x22 = box.br.x * box.br.x, y22 = box.br.y * box.br.y,
- diag = sqrt(
+ diag = std::sqrt(
util::max(x12 + y12, x12 + y22, x22 + y12, x22 + y22));
glyph.bbox = CollisionRect{{-diag, -diag}, {diag, diag}};
@@ -147,7 +147,7 @@ float Collision::getPlacementScale(const GlyphBoxes &glyphs,
return -1;
}
- float minScale = fmax(minPlacementScale, glyph.minScale);
+ float minScale = std::fmax(minPlacementScale, glyph.minScale);
float maxScale = glyph.maxScale;
if (minScale >= maxScale) {
@@ -184,7 +184,7 @@ float Collision::getPlacementScale(const GlyphBoxes &glyphs,
}
// todo: unhardcode the 8 = tileExtent/tileSize
- float padding = fmax(pad, placement.padding) * 8.0f;
+ float padding = std::fmax(pad, placement.padding) * 8.0f;
// Original algorithm:
float s1 = (ob.tl.x - nb.br.x - padding) /
@@ -207,7 +207,7 @@ float Collision::getPlacementScale(const GlyphBoxes &glyphs,
s3 = s4 = 1;
}
- float collisionFreeScale = fmin(fmax(s1, s2), fmax(s3, s4));
+ float collisionFreeScale = std::fmin(std::fmax(s1, s2), std::fmax(s3, s4));
// Only update label's min scale if the glyph was
// restricted by a collision
@@ -278,12 +278,12 @@ PlacementRange Collision::getPlacementRange(const GlyphBoxes &glyphs,
if (!(intersectX && intersectY))
continue;
- float scale = fmax(placementScale, b.placementScale);
+ float scale = std::fmax(placementScale, b.placementScale);
// TODO? glyph.box or glyph.bbox?
CollisionRange range = rotationRange(glyph, b, scale);
- placementRange[0] = fmin(placementRange[0], range[0]);
- placementRange[1] = fmax(placementRange[1], range[1]);
+ placementRange[0] = std::fmin(placementRange[0], range[0]);
+ placementRange[1] = std::fmax(placementRange[1], range[1]);
}
}
@@ -303,7 +303,7 @@ void Collision::insert(const GlyphBoxes &glyphs, const CollisionAnchor &anchor,
const CollisionRect &bbox = glyph.bbox;
const CollisionRect &box = glyph.box;
- float minScale = fmax(placementScale, glyph.minScale);
+ float minScale = std::fmax(placementScale, glyph.minScale);
Box bounds{Point{anchor.x + bbox.tl.x / minScale,
anchor.y + bbox.tl.y / minScale},
diff --git a/src/text/placement.cpp b/src/text/placement.cpp
index 2ae95e4fdd..ab5180fd0c 100644
--- a/src/text/placement.cpp
+++ b/src/text/placement.cpp
@@ -28,7 +28,7 @@ Placement::Placement(int8_t zoom)
// glyphs be placed, slowing down collision checking. Only place labels if
// they will show up within the intended zoom range of the tile.
// TODO make this not hardcoded to 3
- maxPlacementScale(exp(log(2) * util::min((25.5 - zoom), 3.0))) {}
+ maxPlacementScale(std::exp(log(2) * util::min((25.5 - zoom), 3.0))) {}
bool byScale(const Anchor &a, const Anchor &b) { return a.scale < b.scale; }
@@ -95,20 +95,20 @@ void getSegmentGlyphs(std::back_insert_iterator<GlyphInstances> glyphs,
float prevscale = std::numeric_limits<float>::infinity();
float prevAngle = 0.0f;
- offset = fabs(offset);
+ offset = std::fabs(offset);
const float placementScale = anchor.scale;
while (true) {
const float dist = util::dist<float>(newAnchor, end);
const float scale = offset / dist;
- float angle = -atan2(end.x - newAnchor.x, end.y - newAnchor.y) +
+ float angle = -std::atan2(end.x - newAnchor.x, end.y - newAnchor.y) +
direction * M_PI / 2.0f;
if (upsideDown)
angle += M_PI;
// Don't place around sharp corners
- float angleDiff = fmod((angle - prevAngle), (2.0f * M_PI));
+ float angleDiff = std::fmod((angle - prevAngle), (2.0f * M_PI));
if (prevAngle && std::fabs(angleDiff) > maxAngleDelta) {
anchor.scale = prevscale;
break;
@@ -120,7 +120,7 @@ void getSegmentGlyphs(std::back_insert_iterator<GlyphInstances> glyphs,
/* minScale */ scale,
/* maxScale */ prevscale,
/* angle */ static_cast<float>(
- fmod((angle + 2.0 * M_PI), (2.0 * M_PI)))};
+ std::fmod((angle + 2.0 * M_PI), (2.0 * M_PI)))};
if (scale <= placementScale)
break;
@@ -228,8 +228,8 @@ PlacedGlyphs getGlyphs(Anchor &anchor, float advance, const Shaping &shaping,
if (angle) {
// Compute the transformation matrix.
- float angle_sin = sin(angle);
- float angle_cos = cos(angle);
+ float angle_sin = std::sin(angle);
+ float angle_cos = std::cos(angle);
std::array<float, 4> matrix = {
{angle_cos, -angle_sin, angle_sin, angle_cos}};
@@ -251,7 +251,7 @@ PlacedGlyphs getGlyphs(Anchor &anchor, float advance, const Shaping &shaping,
glyphs.emplace_back(PlacedGlyph{
tl, tr, bl, br, glyph.rect, width, height,
static_cast<float>(
- fmod((anchor.angle + rotate + instance.offset + 2 * M_PI),
+ std::fmod((anchor.angle + rotate + instance.offset + 2 * M_PI),
(2 * M_PI))),
GlyphBox{box, instance.minScale, instance.maxScale,
instance.anchor, horizontal}});
diff --git a/src/text/rotation_range.cpp b/src/text/rotation_range.cpp
index 3c1244763f..9cbf958b71 100644
--- a/src/text/rotation_range.cpp
+++ b/src/text/rotation_range.cpp
@@ -54,19 +54,19 @@ rotatingRotatingCollisions(const CollisionRect &a, const CollisionRect &b,
// Calculate angles at which collisions may occur
const std::array<float, 8> c = {{
// top/bottom
- /*[0]*/ static_cast<float>(asin((float)(a.br.y - b.tl.y) / d)),
- /*[1]*/ static_cast<float>(asin((float)(a.br.y - b.tl.y) / d) + M_PI),
+ /*[0]*/ static_cast<float>(std::asin((float)(a.br.y - b.tl.y) / d)),
+ /*[1]*/ static_cast<float>(std::asin((float)(a.br.y - b.tl.y) / d) + M_PI),
/*[2]*/ static_cast<float>(2 * M_PI -
- asin((float)(-a.tl.y + b.br.y) / d)),
- /*[3]*/ static_cast<float>(M_PI - asin((float)(-a.tl.y + b.br.y) / d)),
+ std::asin((float)(-a.tl.y + b.br.y) / d)),
+ /*[3]*/ static_cast<float>(M_PI - std::asin((float)(-a.tl.y + b.br.y) / d)),
// left/right
/*[4]*/ static_cast<float>(2 * M_PI -
- acos((float)(a.br.x - b.tl.x) / d)),
- /*[5]*/ static_cast<float>(acos((float)(a.br.x - b.tl.x) / d)),
- /*[6]*/ static_cast<float>(M_PI - acos((float)(-a.tl.x + b.br.x) / d)),
+ std::acos((float)(a.br.x - b.tl.x) / d)),
+ /*[5]*/ static_cast<float>(std::acos((float)(a.br.x - b.tl.x) / d)),
+ /*[6]*/ static_cast<float>(M_PI - std::acos((float)(-a.tl.x + b.br.x) / d)),
/*[7]*/ static_cast<float>(M_PI +
- acos((float)(-a.tl.x + b.br.x) / d))}};
+ std::acos((float)(-a.tl.x + b.br.x) / d))}};
const float rl = a.br.x - b.tl.x;
const float lr = -a.tl.x + b.br.x;
@@ -98,7 +98,7 @@ rotatingRotatingCollisions(const CollisionRect &a, const CollisionRect &b,
// between anchors.
// Convert the angles to angles from north.
f.push_back(
- fmod((c[i] + angleBetweenAnchors + 2 * M_PI), (2 * M_PI)));
+ std::fmod((c[i] + angleBetweenAnchors + 2 * M_PI), (2 * M_PI)));
}
}
@@ -117,7 +117,7 @@ rotatingRotatingCollisions(const CollisionRect &a, const CollisionRect &b,
double getAngle(const CollisionPoint &p1, const CollisionPoint &p2,
CollisionAngle d, const CollisionPoint &corner) {
- return fmod(util::angle_between(util::interp(p1.x, p2.x, d),
+ return std::fmod(util::angle_between(util::interp(p1.x, p2.x, d),
util::interp(p1.y, p2.y, d), corner.x,
corner.y) +
2 * M_PI,
@@ -141,8 +141,8 @@ void circleEdgeCollisions(std::back_insert_iterator<CollisionAngles> angles,
// a collision exists only if line intersects circle at two points
if (discriminant > 0) {
- CollisionAngle x1 = (-b - sqrt(discriminant)) / (2 * a);
- CollisionAngle x2 = (-b + sqrt(discriminant)) / (2 * a);
+ CollisionAngle x1 = (-b - std::sqrt(discriminant)) / (2 * a);
+ CollisionAngle x2 = (-b + std::sqrt(discriminant)) / (2 * a);
// only add points if within line segment
// hack to handle floating point representations of 0 and 1