summaryrefslogtreecommitdiff
path: root/src/mbgl
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2017-08-22 12:57:11 +0300
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2017-08-22 12:57:11 +0300
commit1c633072fcea7ad153ab6f8ec40dd72d83541ead (patch)
treefa90c930a58672fa48bf46840f6b88ec645864f0 /src/mbgl
parentc53896caefc96a8c18ab746026330ddc4fc0338e (diff)
downloadqtlocation-mapboxgl-1c633072fcea7ad153ab6f8ec40dd72d83541ead.tar.gz
Bump Mapbox GL Native
mapbox-gl-native @ bd15e273dce767458d335aeb1f50aa081390d593
Diffstat (limited to 'src/mbgl')
-rw-r--r--src/mbgl/actor/scheduler.cpp19
-rw-r--r--src/mbgl/annotation/render_annotation_source.cpp2
-rw-r--r--src/mbgl/map/map.cpp6
-rw-r--r--src/mbgl/map/transform_state.hpp2
-rw-r--r--src/mbgl/map/zoom_history.hpp37
-rw-r--r--src/mbgl/programs/attributes.hpp1
-rw-r--r--src/mbgl/programs/line_program.cpp2
-rw-r--r--src/mbgl/programs/line_program.hpp12
-rw-r--r--src/mbgl/renderer/buckets/line_bucket.cpp6
-rw-r--r--src/mbgl/shaders/line.cpp20
-rw-r--r--src/mbgl/shaders/line_pattern.cpp19
-rw-r--r--src/mbgl/shaders/line_sdf.cpp19
-rw-r--r--src/mbgl/sprite/sprite_loader.cpp4
-rw-r--r--src/mbgl/storage/file_source_request.cpp4
-rw-r--r--src/mbgl/style/style.cpp16
-rw-r--r--src/mbgl/style/style_impl.cpp25
-rw-r--r--src/mbgl/style/style_impl.hpp12
-rw-r--r--src/mbgl/text/glyph.hpp6
-rw-r--r--src/mbgl/text/quads.cpp23
-rw-r--r--src/mbgl/text/shaping.cpp4
-rw-r--r--src/mbgl/tile/geometry_tile.cpp4
-rw-r--r--src/mbgl/tile/geometry_tile_worker.cpp7
-rw-r--r--src/mbgl/tile/raster_tile.cpp4
23 files changed, 130 insertions, 124 deletions
diff --git a/src/mbgl/actor/scheduler.cpp b/src/mbgl/actor/scheduler.cpp
new file mode 100644
index 0000000000..d7cdb2737b
--- /dev/null
+++ b/src/mbgl/actor/scheduler.cpp
@@ -0,0 +1,19 @@
+#include <mbgl/actor/scheduler.hpp>
+#include <mbgl/util/thread_local.hpp>
+
+namespace mbgl {
+
+static auto& current() {
+ static util::ThreadLocal<Scheduler> scheduler;
+ return scheduler;
+};
+
+void Scheduler::SetCurrent(Scheduler* scheduler) {
+ current().set(scheduler);
+}
+
+Scheduler* Scheduler::GetCurrent() {
+ return current().get();
+}
+
+} //namespace mbgl
diff --git a/src/mbgl/annotation/render_annotation_source.cpp b/src/mbgl/annotation/render_annotation_source.cpp
index de38b596d5..c2e6191d1d 100644
--- a/src/mbgl/annotation/render_annotation_source.cpp
+++ b/src/mbgl/annotation/render_annotation_source.cpp
@@ -38,7 +38,7 @@ void RenderAnnotationSource::update(Immutable<style::Source::Impl> baseImpl_,
parameters,
SourceType::Annotations,
util::tileSize,
- { 0, 22 },
+ { 0, util::DEFAULT_MAX_ZOOM },
[&] (const OverscaledTileID& tileID) {
return std::make_unique<AnnotationTile>(tileID, parameters);
});
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index 7d57f6863e..d5a5923e6c 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -727,11 +727,7 @@ void Map::Impl::onStyleLoading() {
void Map::Impl::onStyleLoaded() {
if (!cameraMutated) {
- // Zoom first because it may constrain subsequent operations.
- map.setZoom(style->getDefaultZoom());
- map.setLatLng(style->getDefaultLatLng());
- map.setBearing(style->getDefaultBearing());
- map.setPitch(style->getDefaultPitch());
+ map.jumpTo(style->getDefaultCamera());
}
annotationManager.onStyleLoaded();
diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp
index f35f570549..4d6b89573e 100644
--- a/src/mbgl/map/transform_state.hpp
+++ b/src/mbgl/map/transform_state.hpp
@@ -96,7 +96,7 @@ private:
// Limit the amount of zooming possible on the map.
double min_scale = std::pow(2, 0);
- double max_scale = std::pow(2, 20);
+ double max_scale = std::pow(2, util::DEFAULT_MAX_ZOOM);
double min_pitch = 0.0;
double max_pitch = util::PITCH_MAX;
diff --git a/src/mbgl/map/zoom_history.hpp b/src/mbgl/map/zoom_history.hpp
index 697e28573c..ddec53e6af 100644
--- a/src/mbgl/map/zoom_history.hpp
+++ b/src/mbgl/map/zoom_history.hpp
@@ -8,34 +8,39 @@ namespace mbgl {
struct ZoomHistory {
float lastZoom;
+ float lastFloorZoom;
float lastIntegerZoom;
TimePoint lastIntegerZoomTime;
bool first = true;
bool update(float z, const TimePoint& now) {
constexpr TimePoint zero = TimePoint(Duration::zero());
+ const float floorZ = std::floor(z);
+
if (first) {
first = false;
- lastIntegerZoom = std::floor(z);
+ lastIntegerZoom = floorZ;
lastIntegerZoomTime = zero;
lastZoom = z;
+ lastFloorZoom = floorZ;
+ return true;
+ }
+
+ if (lastFloorZoom > floorZ) {
+ lastIntegerZoom = floorZ + 1;
+ lastIntegerZoomTime = now == Clock::time_point::max() ? zero : now;
+ } else if (lastFloorZoom < floorZ || lastIntegerZoom != floorZ) {
+ lastIntegerZoom = floorZ;
+ lastIntegerZoomTime = now == Clock::time_point::max() ? zero : now;
+ }
+
+ if (z != lastZoom) {
+ lastZoom = z;
+ lastFloorZoom = floorZ;
return true;
- } else {
- if (std::floor(lastZoom) < std::floor(z)) {
- lastIntegerZoom = std::floor(z);
- lastIntegerZoomTime = now == Clock::time_point::max() ? zero : now;
- } else if (std::floor(lastZoom) > std::floor(z)) {
- lastIntegerZoom = std::floor(z + 1);
- lastIntegerZoomTime = now == Clock::time_point::max() ? zero : now;
- }
-
- if (z != lastZoom) {
- lastZoom = z;
- return true;
- }
-
- return false;
}
+
+ return false;
}
};
diff --git a/src/mbgl/programs/attributes.hpp b/src/mbgl/programs/attributes.hpp
index 684d9d6099..3a38453d30 100644
--- a/src/mbgl/programs/attributes.hpp
+++ b/src/mbgl/programs/attributes.hpp
@@ -23,6 +23,7 @@ inline uint16_t packUint8Pair(T a, T b) {
MBGL_DEFINE_ATTRIBUTE(int16_t, 2, a_pos);
MBGL_DEFINE_ATTRIBUTE(int16_t, 2, a_extrude);
MBGL_DEFINE_ATTRIBUTE(int16_t, 4, a_pos_offset);
+MBGL_DEFINE_ATTRIBUTE(int16_t, 3, a_pos_normal);
MBGL_DEFINE_ATTRIBUTE(float, 3, a_projected_pos);
MBGL_DEFINE_ATTRIBUTE(int16_t, 2, a_label_pos);
MBGL_DEFINE_ATTRIBUTE(int16_t, 2, a_anchor_pos);
diff --git a/src/mbgl/programs/line_program.cpp b/src/mbgl/programs/line_program.cpp
index db5c916d32..f9e91f569f 100644
--- a/src/mbgl/programs/line_program.cpp
+++ b/src/mbgl/programs/line_program.cpp
@@ -10,7 +10,7 @@ namespace mbgl {
using namespace style;
-static_assert(sizeof(LineLayoutVertex) == 8, "expected LineLayoutVertex size");
+static_assert(sizeof(LineLayoutVertex) == 10, "expected LineLayoutVertex size");
template <class Values, class...Args>
Values makeValues(const RenderLinePaintProperties::PossiblyEvaluated& properties,
diff --git a/src/mbgl/programs/line_program.hpp b/src/mbgl/programs/line_program.hpp
index ed4a09bf10..95b9362b85 100644
--- a/src/mbgl/programs/line_program.hpp
+++ b/src/mbgl/programs/line_program.hpp
@@ -30,7 +30,7 @@ MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_gl_units_to_pixels);
} // namespace uniforms
struct LineLayoutAttributes : gl::Attributes<
- attributes::a_pos,
+ attributes::a_pos_normal,
attributes::a_data<uint8_t, 4>>
{};
@@ -50,14 +50,16 @@ public:
/*
* @param p vertex position
* @param e extrude normal
- * @param t texture normal
+ * @param round whether the vertex uses a round line cap
+ * @param up whether the line normal points up or down
* @param dir direction of the line cap (-1/0/1)
*/
- static LayoutVertex layoutVertex(Point<int16_t> p, Point<double> e, Point<bool> t, int8_t dir, int32_t linesofar = 0) {
+ static LayoutVertex layoutVertex(Point<int16_t> p, Point<double> e, bool round, bool up, int8_t dir, int32_t linesofar = 0) {
return LayoutVertex {
{{
- static_cast<int16_t>((p.x * 2) | t.x),
- static_cast<int16_t>((p.y * 2) | t.y)
+ p.x,
+ p.y,
+ static_cast<int16_t>(attributes::packUint8Pair(round ? 1 : 0, up ? 1 : 0))
}},
{{
// add 128 to store a byte in an unsigned byte
diff --git a/src/mbgl/renderer/buckets/line_bucket.cpp b/src/mbgl/renderer/buckets/line_bucket.cpp
index 194b012eee..a96518df38 100644
--- a/src/mbgl/renderer/buckets/line_bucket.cpp
+++ b/src/mbgl/renderer/buckets/line_bucket.cpp
@@ -401,7 +401,7 @@ void LineBucket::addCurrentVertex(const GeometryCoordinate& currentCoordinate,
Point<double> extrude = normal;
if (endLeft)
extrude = extrude - (util::perp(normal) * endLeft);
- vertices.emplace_back(LineProgram::layoutVertex(currentCoordinate, extrude, { round, false }, endLeft, distance * LINE_DISTANCE_SCALE));
+ vertices.emplace_back(LineProgram::layoutVertex(currentCoordinate, extrude, round, false, endLeft, distance * LINE_DISTANCE_SCALE));
e3 = vertices.vertexSize() - 1 - startVertex;
if (e1 >= 0 && e2 >= 0) {
triangleStore.emplace_back(e1, e2, e3);
@@ -412,7 +412,7 @@ void LineBucket::addCurrentVertex(const GeometryCoordinate& currentCoordinate,
extrude = normal * -1.0;
if (endRight)
extrude = extrude - (util::perp(normal) * endRight);
- vertices.emplace_back(LineProgram::layoutVertex(currentCoordinate, extrude, { round, true }, -endRight, distance * LINE_DISTANCE_SCALE));
+ vertices.emplace_back(LineProgram::layoutVertex(currentCoordinate, extrude, round, true, -endRight, distance * LINE_DISTANCE_SCALE));
e3 = vertices.vertexSize() - 1 - startVertex;
if (e1 >= 0 && e2 >= 0) {
triangleStore.emplace_back(e1, e2, e3);
@@ -437,7 +437,7 @@ void LineBucket::addPieSliceVertex(const GeometryCoordinate& currentVertex,
std::size_t startVertex,
std::vector<TriangleElement>& triangleStore) {
Point<double> flippedExtrude = extrude * (lineTurnsLeft ? -1.0 : 1.0);
- vertices.emplace_back(LineProgram::layoutVertex(currentVertex, flippedExtrude, { false, lineTurnsLeft }, 0, distance * LINE_DISTANCE_SCALE));
+ vertices.emplace_back(LineProgram::layoutVertex(currentVertex, flippedExtrude, false, lineTurnsLeft, 0, distance * LINE_DISTANCE_SCALE));
e3 = vertices.vertexSize() - 1 - startVertex;
if (e1 >= 0 && e2 >= 0) {
triangleStore.emplace_back(e1, e2, e3);
diff --git a/src/mbgl/shaders/line.cpp b/src/mbgl/shaders/line.cpp
index 26dda5e73c..f68cc91377 100644
--- a/src/mbgl/shaders/line.cpp
+++ b/src/mbgl/shaders/line.cpp
@@ -21,7 +21,7 @@ const char* line::vertexSource = R"MBGL_SHADER(
// #define scale 63.0
#define scale 0.015873016
-attribute vec2 a_pos;
+attribute vec3 a_pos_normal;
attribute vec4 a_data;
uniform mat4 u_matrix;
@@ -131,20 +131,21 @@ void main() {
vec2 a_extrude = a_data.xy - 128.0;
float a_direction = mod(a_data.z, 4.0) - 1.0;
- // We store the texture normals in the most insignificant bit
- // transform y so that 0 => -1 and 1 => 1
+ vec2 pos = a_pos_normal.xy;
+
+ // transform y normal so that 0 => -1 and 1 => 1
// In the texture normal, x is 0 if the normal points straight up/down and 1 if it's a round cap
// y is 1 if the normal points up, and -1 if it points down
- mediump vec2 normal = mod(a_pos, 2.0);
+ mediump vec2 normal = unpack_float(a_pos_normal.z);
normal.y = sign(normal.y - 0.5);
- v_normal = normal;
+ v_normal = normal;
- // these transformations used to be applied in the JS and native code bases.
- // moved them into the shader for clarity and simplicity.
+ // these transformations used to be applied in the JS and native code bases.
+ // moved them into the shader for clarity and simplicity.
gapwidth = gapwidth / 2.0;
float halfwidth = width / 2.0;
- offset = -1.0 * offset;
+ offset = -1.0 * offset;
float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);
float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;
@@ -161,9 +162,6 @@ void main() {
mediump float t = 1.0 - abs(u);
mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);
- // Remove the texture normal bit to get the position
- vec2 pos = floor(a_pos * 0.5);
-
vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);
gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;
diff --git a/src/mbgl/shaders/line_pattern.cpp b/src/mbgl/shaders/line_pattern.cpp
index 9eee9192d4..f1e64577e2 100644
--- a/src/mbgl/shaders/line_pattern.cpp
+++ b/src/mbgl/shaders/line_pattern.cpp
@@ -23,7 +23,7 @@ const char* line_pattern::vertexSource = R"MBGL_SHADER(
// Retina devices need a smaller distance to avoid aliasing.
#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0
-attribute vec2 a_pos;
+attribute vec3 a_pos_normal;
attribute vec4 a_data;
uniform mat4 u_matrix;
@@ -119,19 +119,21 @@ void main() {
float a_direction = mod(a_data.z, 4.0) - 1.0;
float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;
- // We store the texture normals in the most insignificant bit
- // transform y so that 0 => -1 and 1 => 1
+ vec2 pos = a_pos_normal.xy;
+
+ // transform y normal so that 0 => -1 and 1 => 1
// In the texture normal, x is 0 if the normal points straight up/down and 1 if it's a round cap
// y is 1 if the normal points up, and -1 if it points down
- mediump vec2 normal = mod(a_pos, 2.0);
+ mediump vec2 normal = unpack_float(a_pos_normal.z);
normal.y = sign(normal.y - 0.5);
+
v_normal = normal;
- // these transformations used to be applied in the JS and native code bases.
- // moved them into the shader for clarity and simplicity.
+ // these transformations used to be applied in the JS and native code bases.
+ // moved them into the shader for clarity and simplicity.
gapwidth = gapwidth / 2.0;
float halfwidth = width / 2.0;
- offset = -1.0 * offset;
+ offset = -1.0 * offset;
float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);
float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;
@@ -148,9 +150,6 @@ void main() {
mediump float t = 1.0 - abs(u);
mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);
- // Remove the texture normal bit to get the position
- vec2 pos = floor(a_pos * 0.5);
-
vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);
gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;
diff --git a/src/mbgl/shaders/line_sdf.cpp b/src/mbgl/shaders/line_sdf.cpp
index e1aadffcf4..dd81433543 100644
--- a/src/mbgl/shaders/line_sdf.cpp
+++ b/src/mbgl/shaders/line_sdf.cpp
@@ -23,7 +23,7 @@ const char* line_sdf::vertexSource = R"MBGL_SHADER(
// Retina devices need a smaller distance to avoid aliasing.
#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0
-attribute vec2 a_pos;
+attribute vec3 a_pos_normal;
attribute vec4 a_data;
uniform mat4 u_matrix;
@@ -157,20 +157,22 @@ void main() {
float a_direction = mod(a_data.z, 4.0) - 1.0;
float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;
- // We store the texture normals in the most insignificant bit
- // transform y so that 0 => -1 and 1 => 1
+ vec2 pos = a_pos_normal.xy;
+
+ // transform y normal so that 0 => -1 and 1 => 1
// In the texture normal, x is 0 if the normal points straight up/down and 1 if it's a round cap
// y is 1 if the normal points up, and -1 if it points down
- mediump vec2 normal = mod(a_pos, 2.0);
+ mediump vec2 normal = unpack_float(a_pos_normal.z);
normal.y = sign(normal.y - 0.5);
+
v_normal = normal;
- // these transformations used to be applied in the JS and native code bases.
- // moved them into the shader for clarity and simplicity.
+ // these transformations used to be applied in the JS and native code bases.
+ // moved them into the shader for clarity and simplicity.
gapwidth = gapwidth / 2.0;
float halfwidth = width / 2.0;
offset = -1.0 * offset;
-
+
float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);
float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;
@@ -186,9 +188,6 @@ void main() {
mediump float t = 1.0 - abs(u);
mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);
- // Remove the texture normal bit to get the position
- vec2 pos = floor(a_pos * 0.5);
-
vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);
gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;
diff --git a/src/mbgl/sprite/sprite_loader.cpp b/src/mbgl/sprite/sprite_loader.cpp
index 60ece5ed73..93d6dfd9ae 100644
--- a/src/mbgl/sprite/sprite_loader.cpp
+++ b/src/mbgl/sprite/sprite_loader.cpp
@@ -10,8 +10,8 @@
#include <mbgl/storage/file_source.hpp>
#include <mbgl/storage/resource.hpp>
#include <mbgl/storage/response.hpp>
-#include <mbgl/util/run_loop.hpp>
#include <mbgl/actor/actor.hpp>
+#include <mbgl/actor/scheduler.hpp>
#include <cassert>
@@ -21,7 +21,7 @@ static SpriteLoaderObserver nullObserver;
struct SpriteLoader::Loader {
Loader(Scheduler& scheduler, SpriteLoader& imageManager)
- : mailbox(std::make_shared<Mailbox>(*util::RunLoop::Get())),
+ : mailbox(std::make_shared<Mailbox>(*Scheduler::GetCurrent())),
worker(scheduler, ActorRef<SpriteLoader>(imageManager, mailbox)) {
}
diff --git a/src/mbgl/storage/file_source_request.cpp b/src/mbgl/storage/file_source_request.cpp
index 8a6fb21181..09ea8cc32a 100644
--- a/src/mbgl/storage/file_source_request.cpp
+++ b/src/mbgl/storage/file_source_request.cpp
@@ -1,13 +1,13 @@
#include <mbgl/storage/file_source_request.hpp>
#include <mbgl/actor/mailbox.hpp>
-#include <mbgl/util/run_loop.hpp>
+#include <mbgl/actor/scheduler.hpp>
namespace mbgl {
FileSourceRequest::FileSourceRequest(FileSource::Callback&& callback)
: responseCallback(callback)
- , mailbox(std::make_shared<Mailbox>(*util::RunLoop::Get())) {
+ , mailbox(std::make_shared<Mailbox>(*Scheduler::GetCurrent())) {
}
FileSourceRequest::~FileSourceRequest() {
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index 5fe1ab4a06..bd8631fc52 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -34,20 +34,8 @@ std::string Style::getName() const {
return impl->getName();
}
-LatLng Style::getDefaultLatLng() const {
- return impl->getDefaultLatLng();
-}
-
-double Style::getDefaultZoom() const {
- return impl->getDefaultZoom();
-}
-
-double Style::getDefaultBearing() const {
- return impl->getDefaultBearing();
-}
-
-double Style::getDefaultPitch() const {
- return impl->getDefaultPitch();
+CameraOptions Style::getDefaultCamera() const {
+ return impl->getDefaultCamera();
}
TransitionOptions Style::getTransitionOptions() const {
diff --git a/src/mbgl/style/style_impl.cpp b/src/mbgl/style/style_impl.cpp
index 604af4be20..0fb49d1d22 100644
--- a/src/mbgl/style/style_impl.cpp
+++ b/src/mbgl/style/style_impl.cpp
@@ -107,10 +107,11 @@ void Style::Impl::parse(const std::string& json_) {
}
name = parser.name;
- defaultLatLng = parser.latLng;
- defaultZoom = parser.zoom;
- defaultBearing = parser.bearing;
- defaultPitch = parser.pitch;
+ defaultCamera.center = parser.latLng;
+ defaultCamera.zoom = parser.zoom;
+ defaultCamera.angle = parser.bearing;
+ defaultCamera.pitch = parser.pitch;
+
setLight(std::make_unique<Light>(parser.light));
spriteLoaded = false;
@@ -232,20 +233,8 @@ std::string Style::Impl::getName() const {
return name;
}
-LatLng Style::Impl::getDefaultLatLng() const {
- return defaultLatLng;
-}
-
-double Style::Impl::getDefaultZoom() const {
- return defaultZoom;
-}
-
-double Style::Impl::getDefaultBearing() const {
- return defaultBearing;
-}
-
-double Style::Impl::getDefaultPitch() const {
- return defaultPitch;
+CameraOptions Style::Impl::getDefaultCamera() const {
+ return defaultCamera;
}
std::vector<Source*> Style::Impl::getSources() {
diff --git a/src/mbgl/style/style_impl.hpp b/src/mbgl/style/style_impl.hpp
index 76f244d5a4..3dc222bfad 100644
--- a/src/mbgl/style/style_impl.hpp
+++ b/src/mbgl/style/style_impl.hpp
@@ -12,6 +12,8 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/collection.hpp>
+#include <mbgl/map/camera.hpp>
+
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/optional.hpp>
#include <mbgl/util/geo.hpp>
@@ -69,10 +71,7 @@ public:
std::unique_ptr<Layer> removeLayer(const std::string& layerID);
std::string getName() const;
- LatLng getDefaultLatLng() const;
- double getDefaultZoom() const;
- double getDefaultBearing() const;
- double getDefaultPitch() const;
+ CameraOptions getDefaultCamera() const;
TransitionOptions getTransitionOptions() const;
void setTransitionOptions(const TransitionOptions&);
@@ -117,10 +116,7 @@ private:
// Defaults
std::string name;
- LatLng defaultLatLng;
- double defaultZoom = 0;
- double defaultBearing = 0;
- double defaultPitch = 0;
+ CameraOptions defaultCamera;
// SpriteLoaderObserver implementation.
void onSpriteLoaded(std::vector<std::unique_ptr<Image>>&&) override;
diff --git a/src/mbgl/text/glyph.hpp b/src/mbgl/text/glyph.hpp
index 19ecdfd17c..6cccb72ebe 100644
--- a/src/mbgl/text/glyph.hpp
+++ b/src/mbgl/text/glyph.hpp
@@ -58,13 +58,13 @@ using GlyphMap = std::map<FontStack, Glyphs>;
class PositionedGlyph {
public:
- explicit PositionedGlyph(GlyphID glyph_, float x_, float y_, float angle_)
- : glyph(glyph_), x(x_), y(y_), angle(angle_) {}
+ explicit PositionedGlyph(GlyphID glyph_, float x_, float y_, bool vertical_)
+ : glyph(glyph_), x(x_), y(y_), vertical(vertical_) {}
GlyphID glyph = 0;
float x = 0;
float y = 0;
- float angle = 0;
+ bool vertical = false;
};
enum class WritingModeType : uint8_t;
diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp
index 7908ea4abc..0014ae8d01 100644
--- a/src/mbgl/text/quads.cpp
+++ b/src/mbgl/text/quads.cpp
@@ -133,18 +133,27 @@ SymbolQuads getGlyphQuads(const Shaping& shapedText,
const float x2 = x1 + rect.w;
const float y2 = y1 + rect.h;
- const Point<float> center{builtInOffset.x - halfAdvance, static_cast<float>(static_cast<float>(glyph.metrics.advance) / 2.0)};
-
Point<float> tl{x1, y1};
Point<float> tr{x2, y1};
Point<float> bl{x1, y2};
Point<float> br{x2, y2};
- if (positionedGlyph.angle != 0) {
- tl = util::rotate(tl - center, positionedGlyph.angle) + center;
- tr = util::rotate(tr - center, positionedGlyph.angle) + center;
- bl = util::rotate(bl - center, positionedGlyph.angle) + center;
- br = util::rotate(br - center, positionedGlyph.angle) + center;
+ if (alongLine && positionedGlyph.vertical) {
+ // Vertical-supporting glyphs are laid out in 24x24 point boxes (1 square em)
+ // In horizontal orientation, the y values for glyphs are below the midline
+ // and we use a "yOffset" of -17 to pull them up to the middle.
+ // By rotating counter-clockwise around the point at the center of the left
+ // edge of a 24x24 layout box centered below the midline, we align the center
+ // of the glyphs with the horizontal midline, so the yOffset is no longer
+ // necessary, but we also pull the glyph to the left along the x axis
+ const Point<float> center{-halfAdvance, halfAdvance};
+ const float verticalRotation = -M_PI_2;
+ const Point<float> xOffsetCorrection{5, 0};
+
+ tl = util::rotate(tl - center, verticalRotation) + center + xOffsetCorrection;
+ tr = util::rotate(tr - center, verticalRotation) + center + xOffsetCorrection;
+ bl = util::rotate(bl - center, verticalRotation) + center + xOffsetCorrection;
+ br = util::rotate(br - center, verticalRotation) + center + xOffsetCorrection;
}
if (textRotate) {
diff --git a/src/mbgl/text/shaping.cpp b/src/mbgl/text/shaping.cpp
index 4a206e9bae..a40ef0cf39 100644
--- a/src/mbgl/text/shaping.cpp
+++ b/src/mbgl/text/shaping.cpp
@@ -237,10 +237,10 @@ void shapeLines(Shaping& shaping,
const Glyph& glyph = **it->second;
if (writingMode == WritingModeType::Horizontal || !util::i18n::hasUprightVerticalOrientation(chr)) {
- shaping.positionedGlyphs.emplace_back(chr, x, y, 0);
+ shaping.positionedGlyphs.emplace_back(chr, x, y, false);
x += glyph.metrics.advance + spacing;
} else {
- shaping.positionedGlyphs.emplace_back(chr, x, 0, -M_PI_2);
+ shaping.positionedGlyphs.emplace_back(chr, x, 0, true);
x += verticalHeight + spacing;
}
}
diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp
index 33911df9ed..20056e355d 100644
--- a/src/mbgl/tile/geometry_tile.cpp
+++ b/src/mbgl/tile/geometry_tile.cpp
@@ -17,10 +17,10 @@
#include <mbgl/geometry/feature_index.hpp>
#include <mbgl/text/collision_tile.hpp>
#include <mbgl/map/transform_state.hpp>
-#include <mbgl/util/run_loop.hpp>
#include <mbgl/style/filter_evaluator.hpp>
#include <mbgl/util/chrono.hpp>
#include <mbgl/util/logging.hpp>
+#include <mbgl/actor/scheduler.hpp>
#include <iostream>
@@ -33,7 +33,7 @@ GeometryTile::GeometryTile(const OverscaledTileID& id_,
const TileParameters& parameters)
: Tile(id_),
sourceID(std::move(sourceID_)),
- mailbox(std::make_shared<Mailbox>(*util::RunLoop::Get())),
+ mailbox(std::make_shared<Mailbox>(*Scheduler::GetCurrent())),
worker(parameters.workerScheduler,
ActorRef<GeometryTile>(*this, mailbox),
id_,
diff --git a/src/mbgl/tile/geometry_tile_worker.cpp b/src/mbgl/tile/geometry_tile_worker.cpp
index c622d82e31..add1ea343c 100644
--- a/src/mbgl/tile/geometry_tile_worker.cpp
+++ b/src/mbgl/tile/geometry_tile_worker.cpp
@@ -218,7 +218,12 @@ void GeometryTileWorker::onGlyphsAvailable(GlyphMap newGlyphMap) {
void GeometryTileWorker::onImagesAvailable(ImageMap newImageMap) {
imageMap = std::move(newImageMap);
- pendingImageDependencies.clear();
+ for (const auto& pair : imageMap) {
+ auto it = pendingImageDependencies.find(pair.first);
+ if (it != pendingImageDependencies.end()) {
+ pendingImageDependencies.erase(it);
+ }
+ }
symbolDependenciesChanged();
}
diff --git a/src/mbgl/tile/raster_tile.cpp b/src/mbgl/tile/raster_tile.cpp
index 1260fd1edd..b940e342d7 100644
--- a/src/mbgl/tile/raster_tile.cpp
+++ b/src/mbgl/tile/raster_tile.cpp
@@ -8,7 +8,7 @@
#include <mbgl/storage/file_source.hpp>
#include <mbgl/renderer/tile_parameters.hpp>
#include <mbgl/renderer/buckets/raster_bucket.hpp>
-#include <mbgl/util/run_loop.hpp>
+#include <mbgl/actor/scheduler.hpp>
namespace mbgl {
@@ -17,7 +17,7 @@ RasterTile::RasterTile(const OverscaledTileID& id_,
const Tileset& tileset)
: Tile(id_),
loader(*this, id_, parameters, tileset),
- mailbox(std::make_shared<Mailbox>(*util::RunLoop::Get())),
+ mailbox(std::make_shared<Mailbox>(*Scheduler::GetCurrent())),
worker(parameters.workerScheduler,
ActorRef<RasterTile>(*this, mailbox)) {
}