summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2015-05-07 21:00:20 +0300
committerThiago Marcos P. Santos <thiago@mapbox.com>2015-05-18 10:42:05 +0300
commit41dc5e836a9b37a8c3bf4f1116de09aceec4264d (patch)
tree69131d4341353ef28f2883d1433c613700beeb38 /src
parentf222efb939a6c6055d97fdae6ed36960948864e6 (diff)
downloadqtlocation-mapboxgl-41dc5e836a9b37a8c3bf4f1116de09aceec4264d.tar.gz
Emit the signal on the MapThread
We were previously emitting the signal on the thread parsing the glyph, but signals can only be trigger from the MapThread because the observers are living there.
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/map/map_context.cpp2
-rw-r--r--src/mbgl/text/glyph_store.cpp10
-rw-r--r--src/mbgl/text/glyph_store.hpp12
3 files changed, 19 insertions, 5 deletions
diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp
index 5191293a08..f373274ebd 100644
--- a/src/mbgl/map/map_context.cpp
+++ b/src/mbgl/map/map_context.cpp
@@ -36,7 +36,7 @@ MapContext::MapContext(uv_loop_t* loop, View& view_, FileSource& fileSource, Map
envScope(env, ThreadType::Map, "Map"),
updated(static_cast<UpdateType>(Update::Nothing)),
asyncUpdate(util::make_unique<uv::async>(loop, [this] { update(); })),
- glyphStore(util::make_unique<GlyphStore>(env)),
+ glyphStore(util::make_unique<GlyphStore>(loop, env)),
glyphAtlas(util::make_unique<GlyphAtlas>(1024, 1024)),
spriteAtlas(util::make_unique<SpriteAtlas>(512, 512)),
lineAtlas(util::make_unique<LineAtlas>(512, 512)),
diff --git a/src/mbgl/text/glyph_store.cpp b/src/mbgl/text/glyph_store.cpp
index 71c1be6d95..8531912185 100644
--- a/src/mbgl/text/glyph_store.cpp
+++ b/src/mbgl/text/glyph_store.cpp
@@ -9,6 +9,7 @@
#include <mbgl/util/constants.hpp>
#include <mbgl/util/token.hpp>
#include <mbgl/util/math.hpp>
+#include <mbgl/util/uv_detail.hpp>
#include <mbgl/storage/file_source.hpp>
#include <mbgl/platform/log.hpp>
#include <mbgl/platform/platform.hpp>
@@ -236,8 +237,11 @@ bool GlyphPBF::isParsed() const {
return parsed;
}
-GlyphStore::GlyphStore(Environment& env_)
- : env(env_), observer(nullptr) {
+GlyphStore::GlyphStore(uv_loop_t* loop, Environment& env_)
+ : env(env_),
+ asyncEmitGlyphRangeLoaded(util::make_unique<uv::async>(loop, [this] { emitGlyphRangeLoaded(); })),
+ observer(nullptr) {
+ asyncEmitGlyphRangeLoaded->unref();
}
GlyphStore::~GlyphStore() {
@@ -258,7 +262,7 @@ bool GlyphStore::requestGlyphRangesIfNeeded(const std::string& fontStack,
auto callback = [this, fontStack](GlyphPBF* glyph) {
glyph->parse(*createFontStack(fontStack));
- emitGlyphRangeLoaded();
+ asyncEmitGlyphRangeLoaded->send();
};
std::lock_guard<std::mutex> lock(rangesMutex);
diff --git a/src/mbgl/text/glyph_store.hpp b/src/mbgl/text/glyph_store.hpp
index a41eec5330..efa848dd08 100644
--- a/src/mbgl/text/glyph_store.hpp
+++ b/src/mbgl/text/glyph_store.hpp
@@ -13,6 +13,14 @@
#include <string>
#include <unordered_map>
+typedef struct uv_loop_s uv_loop_t;
+
+namespace uv {
+
+class async;
+
+}
+
namespace mbgl {
class FileSource;
@@ -87,7 +95,7 @@ public:
virtual void onGlyphRangeLoaded() = 0;
};
- GlyphStore(Environment &);
+ GlyphStore(uv_loop_t* loop, Environment &);
~GlyphStore();
// Asynchronously request for GlyphRanges and when it gets loaded, notifies the
@@ -116,6 +124,8 @@ private:
std::unordered_map<std::string, std::unique_ptr<FontStack>> stacks;
std::mutex stacksMutex;
+ std::unique_ptr<uv::async> asyncEmitGlyphRangeLoaded;
+
Observer* observer;
};