summaryrefslogtreecommitdiff
path: root/src/mbgl/text
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-04-22 10:38:42 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-04-22 15:53:18 -0700
commit5939dd5b412fcc1ef857711a137589aa865bd442 (patch)
tree4bd4e021ea564ee262cff56ab7b6f76e98b29471 /src/mbgl/text
parentd77e35b6866e461c3cb05de2112d548be4ef7780 (diff)
downloadqtlocation-mapboxgl-5939dd5b412fcc1ef857711a137589aa865bd442.tar.gz
[core] Use the proper type for font stacks
Diffstat (limited to 'src/mbgl/text')
-rw-r--r--src/mbgl/text/glyph_pbf.cpp2
-rw-r--r--src/mbgl/text/glyph_pbf.hpp6
-rw-r--r--src/mbgl/text/glyph_store.cpp14
-rw-r--r--src/mbgl/text/glyph_store.hpp16
4 files changed, 20 insertions, 18 deletions
diff --git a/src/mbgl/text/glyph_pbf.cpp b/src/mbgl/text/glyph_pbf.cpp
index 105ea45190..2588afaefa 100644
--- a/src/mbgl/text/glyph_pbf.cpp
+++ b/src/mbgl/text/glyph_pbf.cpp
@@ -61,7 +61,7 @@ void parseGlyphPBF(mbgl::GlyphSet& glyphSet, const std::string& data) {
namespace mbgl {
GlyphPBF::GlyphPBF(GlyphStore* store,
- const std::string& fontStack,
+ const FontStack& fontStack,
const GlyphRange& glyphRange,
GlyphStore::Observer* observer_,
FileSource& fileSource)
diff --git a/src/mbgl/text/glyph_pbf.hpp b/src/mbgl/text/glyph_pbf.hpp
index 5b47563f7d..d281d2a04f 100644
--- a/src/mbgl/text/glyph_pbf.hpp
+++ b/src/mbgl/text/glyph_pbf.hpp
@@ -3,6 +3,7 @@
#include <mbgl/text/glyph.hpp>
#include <mbgl/text/glyph_store.hpp>
+#include <mbgl/style/types.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <atomic>
@@ -12,14 +13,13 @@
namespace mbgl {
-class GlyphSet;
class AsyncRequest;
class FileSource;
class GlyphPBF : private util::noncopyable {
public:
- GlyphPBF(GlyphStore* store,
- const std::string& fontStack,
+ GlyphPBF(GlyphStore*,
+ const FontStack&,
const GlyphRange&,
GlyphStore::Observer*,
FileSource&);
diff --git a/src/mbgl/text/glyph_store.cpp b/src/mbgl/text/glyph_store.cpp
index 9f6a6b7b72..540908ed63 100644
--- a/src/mbgl/text/glyph_store.cpp
+++ b/src/mbgl/text/glyph_store.cpp
@@ -11,9 +11,9 @@ GlyphStore::GlyphStore(FileSource& fileSource_)
GlyphStore::~GlyphStore() = default;
-void GlyphStore::requestGlyphRange(const std::string& fontStackName, const GlyphRange& range) {
+void GlyphStore::requestGlyphRange(const FontStack& fontStack, const GlyphRange& range) {
std::lock_guard<std::mutex> lock(rangesMutex);
- auto& rangeSets = ranges[fontStackName];
+ auto& rangeSets = ranges[fontStack];
const auto& rangeSetsIt = rangeSets.find(range);
if (rangeSetsIt != rangeSets.end()) {
@@ -21,17 +21,17 @@ void GlyphStore::requestGlyphRange(const std::string& fontStackName, const Glyph
}
rangeSets.emplace(range,
- std::make_unique<GlyphPBF>(this, fontStackName, range, observer, fileSource));
+ std::make_unique<GlyphPBF>(this, fontStack, range, observer, fileSource));
}
-bool GlyphStore::hasGlyphRanges(const std::string& fontStackName, const std::set<GlyphRange>& glyphRanges) {
+bool GlyphStore::hasGlyphRanges(const FontStack& fontStack, const std::set<GlyphRange>& glyphRanges) {
if (glyphRanges.empty()) {
return true;
}
std::lock_guard<std::mutex> lock(rangesMutex);
- const auto& rangeSets = ranges[fontStackName];
+ const auto& rangeSets = ranges[fontStack];
bool hasRanges = true;
for (const auto& range : glyphRanges) {
@@ -39,7 +39,7 @@ bool GlyphStore::hasGlyphRanges(const std::string& fontStackName, const std::set
if (rangeSetsIt == rangeSets.end()) {
// Push the request to the MapThread, so we can easly cancel
// if it is still pending when we destroy this object.
- workQueue.push(std::bind(&GlyphStore::requestGlyphRange, this, fontStackName, range));
+ workQueue.push(std::bind(&GlyphStore::requestGlyphRange, this, fontStack, range));
hasRanges = false;
continue;
@@ -53,7 +53,7 @@ bool GlyphStore::hasGlyphRanges(const std::string& fontStackName, const std::set
return hasRanges;
}
-util::exclusive<GlyphSet> GlyphStore::getGlyphSet(const std::string& fontStack) {
+util::exclusive<GlyphSet> GlyphStore::getGlyphSet(const FontStack& fontStack) {
auto lock = std::make_unique<std::lock_guard<std::mutex>>(glyphSetsMutex);
auto it = glyphSets.find(fontStack);
diff --git a/src/mbgl/text/glyph_store.hpp b/src/mbgl/text/glyph_store.hpp
index 5b80589f4b..f89ff80864 100644
--- a/src/mbgl/text/glyph_store.hpp
+++ b/src/mbgl/text/glyph_store.hpp
@@ -3,11 +3,13 @@
#include <mbgl/text/glyph.hpp>
#include <mbgl/text/glyph_set.hpp>
+#include <mbgl/style/types.hpp>
#include <mbgl/util/exclusive.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/work_queue.hpp>
#include <exception>
+#include <vector>
#include <set>
#include <string>
#include <unordered_map>
@@ -26,21 +28,21 @@ public:
public:
virtual ~Observer() = default;
- virtual void onGlyphsLoaded(const std::string& /* fontStack */, const GlyphRange&) {};
- virtual void onGlyphsError(const std::string& /* fontStack */, const GlyphRange&, std::exception_ptr) {};
+ virtual void onGlyphsLoaded(const FontStack&, const GlyphRange&) {};
+ virtual void onGlyphsError(const FontStack&, const GlyphRange&, std::exception_ptr) {};
};
GlyphStore(FileSource&);
~GlyphStore();
- util::exclusive<GlyphSet> getGlyphSet(const std::string& fontStack);
+ util::exclusive<GlyphSet> getGlyphSet(const FontStack&);
// Returns true if the set of GlyphRanges are available and parsed or false
// if they are not. For the missing ranges, a request on the FileSource is
// made and when the glyph if finally parsed, it gets added to the respective
// GlyphSet and a signal is emitted to notify the observers. This method
// can be called from any thread.
- bool hasGlyphRanges(const std::string& fontStack, const std::set<GlyphRange>& glyphRanges);
+ bool hasGlyphRanges(const FontStack&, const std::set<GlyphRange>&);
void setURL(const std::string &url) {
glyphURL = url;
@@ -53,15 +55,15 @@ public:
void setObserver(Observer* observer);
private:
- void requestGlyphRange(const std::string& fontStackName, const GlyphRange& range);
+ void requestGlyphRange(const FontStack&, const GlyphRange&);
FileSource& fileSource;
std::string glyphURL;
- std::unordered_map<std::string, std::map<GlyphRange, std::unique_ptr<GlyphPBF>>> ranges;
+ std::unordered_map<FontStack, std::map<GlyphRange, std::unique_ptr<GlyphPBF>>, FontStackHash> ranges;
std::mutex rangesMutex;
- std::unordered_map<std::string, std::unique_ptr<GlyphSet>> glyphSets;
+ std::unordered_map<FontStack, std::unique_ptr<GlyphSet>, FontStackHash> glyphSets;
std::mutex glyphSetsMutex;
util::WorkQueue workQueue;