summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-04-22 13:28:03 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-04-22 13:28:03 -0700
commit0c5d805bf9ac14eeaaaef8c08281a3e6f33ddb0b (patch)
treebcfd85dcdc22fb6b321d0111a0762affc743dcfa /src
parent9c9ff2d2d4aeac9f605a6ca23447e54adea9f6bd (diff)
downloadqtlocation-mapboxgl-0c5d805bf9ac14eeaaaef8c08281a3e6f33ddb0b.tar.gz
[core] FontStack ⇢ GlyphSet (#4803)
A font stack is an array of font names. This is not that.
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/geometry/glyph_atlas.cpp6
-rw-r--r--src/mbgl/geometry/glyph_atlas.hpp2
-rw-r--r--src/mbgl/renderer/symbol_bucket.cpp8
-rw-r--r--src/mbgl/text/glyph_pbf.cpp8
-rw-r--r--src/mbgl/text/glyph_pbf.hpp2
-rw-r--r--src/mbgl/text/glyph_set.cpp (renamed from src/mbgl/text/font_stack.cpp)13
-rw-r--r--src/mbgl/text/glyph_set.hpp (renamed from src/mbgl/text/font_stack.hpp)6
-rw-r--r--src/mbgl/text/glyph_store.cpp12
-rw-r--r--src/mbgl/text/glyph_store.hpp12
9 files changed, 34 insertions, 35 deletions
diff --git a/src/mbgl/geometry/glyph_atlas.cpp b/src/mbgl/geometry/glyph_atlas.cpp
index 046ba46520..92fc7903b2 100644
--- a/src/mbgl/geometry/glyph_atlas.cpp
+++ b/src/mbgl/geometry/glyph_atlas.cpp
@@ -1,7 +1,5 @@
#include <mbgl/geometry/glyph_atlas.hpp>
-#include <mbgl/text/font_stack.hpp>
-
#include <mbgl/gl/gl.hpp>
#include <mbgl/gl/gl_object_store.hpp>
#include <mbgl/platform/log.hpp>
@@ -27,12 +25,12 @@ GlyphAtlas::~GlyphAtlas() {
void GlyphAtlas::addGlyphs(uintptr_t tileUID,
const std::u32string& text,
const std::string& stackName,
- const FontStack& fontStack,
+ const GlyphSet& glyphSet,
GlyphPositions& face)
{
std::lock_guard<std::mutex> lock(mtx);
- const std::map<uint32_t, SDFGlyph>& sdfs = fontStack.getSDFs();
+ const std::map<uint32_t, SDFGlyph>& sdfs = glyphSet.getSDFs();
for (uint32_t chr : text)
{
diff --git a/src/mbgl/geometry/glyph_atlas.hpp b/src/mbgl/geometry/glyph_atlas.hpp
index 2758ac7cee..9b8af9f75d 100644
--- a/src/mbgl/geometry/glyph_atlas.hpp
+++ b/src/mbgl/geometry/glyph_atlas.hpp
@@ -23,7 +23,7 @@ public:
void addGlyphs(uintptr_t tileUID,
const std::u32string& text,
const std::string& stackName,
- const FontStack&,
+ const GlyphSet&,
GlyphPositions&);
void removeGlyphs(uintptr_t tileUID);
diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp
index 146fd8590f..cdb30bf222 100644
--- a/src/mbgl/renderer/symbol_bucket.cpp
+++ b/src/mbgl/renderer/symbol_bucket.cpp
@@ -11,7 +11,7 @@
#include <mbgl/text/get_anchors.hpp>
#include <mbgl/renderer/painter.hpp>
#include <mbgl/text/glyph_store.hpp>
-#include <mbgl/text/font_stack.hpp>
+#include <mbgl/text/glyph_set.hpp>
#include <mbgl/platform/log.hpp>
#include <mbgl/text/collision_tile.hpp>
#include <mbgl/shader/sdf_shader.hpp>
@@ -225,7 +225,7 @@ void SymbolBucket::addFeatures(uintptr_t tileUID,
layout.textJustify == TextJustifyType::Left ? 0 :
0.5;
- auto fontStack = glyphStore.getFontStack(layout.textFont);
+ auto glyphSet = glyphStore.getGlyphSet(layout.textFont);
for (const auto& feature : features) {
if (feature.geometry.empty()) continue;
@@ -236,7 +236,7 @@ void SymbolBucket::addFeatures(uintptr_t tileUID,
// if feature has text, shape the text
if (feature.label.length()) {
- shapedText = fontStack->getShaping(
+ shapedText = glyphSet->getShaping(
/* string */ feature.label,
/* maxWidth: ems */ layout.symbolPlacement != SymbolPlacementType::Line ?
layout.textMaxWidth * 24 : 0,
@@ -249,7 +249,7 @@ void SymbolBucket::addFeatures(uintptr_t tileUID,
// Add the glyphs we need for this label to the glyph atlas.
if (shapedText) {
- glyphAtlas.addGlyphs(tileUID, feature.label, layout.textFont, **fontStack, face);
+ glyphAtlas.addGlyphs(tileUID, feature.label, layout.textFont, **glyphSet, face);
}
}
diff --git a/src/mbgl/text/glyph_pbf.cpp b/src/mbgl/text/glyph_pbf.cpp
index c9466e8652..105ea45190 100644
--- a/src/mbgl/text/glyph_pbf.cpp
+++ b/src/mbgl/text/glyph_pbf.cpp
@@ -3,8 +3,8 @@
#include <mbgl/storage/file_source.hpp>
#include <mbgl/storage/resource.hpp>
#include <mbgl/storage/response.hpp>
-#include <mbgl/text/font_stack.hpp>
#include <mbgl/text/glyph_store.hpp>
+#include <mbgl/text/glyph_set.hpp>
#include <mbgl/util/exception.hpp>
#include <mbgl/util/pbf.hpp>
#include <mbgl/util/string.hpp>
@@ -13,7 +13,7 @@
namespace {
-void parseGlyphPBF(mbgl::FontStack& stack, const std::string& data) {
+void parseGlyphPBF(mbgl::GlyphSet& glyphSet, const std::string& data) {
mbgl::pbf glyphs_pbf(reinterpret_cast<const uint8_t *>(data.data()), data.size());
while (glyphs_pbf.next()) {
@@ -45,7 +45,7 @@ void parseGlyphPBF(mbgl::FontStack& stack, const std::string& data) {
}
}
- stack.insert(glyph.id, glyph);
+ glyphSet.insert(glyph.id, glyph);
} else {
fontstack_pbf.skip();
}
@@ -77,7 +77,7 @@ GlyphPBF::GlyphPBF(GlyphStore* store,
observer->onGlyphsLoaded(fontStack, glyphRange);
} else {
try {
- parseGlyphPBF(**store->getFontStack(fontStack), *res.data);
+ parseGlyphPBF(**store->getGlyphSet(fontStack), *res.data);
} catch (...) {
observer->onGlyphsError(fontStack, glyphRange, std::current_exception());
return;
diff --git a/src/mbgl/text/glyph_pbf.hpp b/src/mbgl/text/glyph_pbf.hpp
index 93b7c9db76..5b47563f7d 100644
--- a/src/mbgl/text/glyph_pbf.hpp
+++ b/src/mbgl/text/glyph_pbf.hpp
@@ -12,7 +12,7 @@
namespace mbgl {
-class FontStack;
+class GlyphSet;
class AsyncRequest;
class FileSource;
diff --git a/src/mbgl/text/font_stack.cpp b/src/mbgl/text/glyph_set.cpp
index 60e90a77e8..40041dff91 100644
--- a/src/mbgl/text/font_stack.cpp
+++ b/src/mbgl/text/glyph_set.cpp
@@ -1,11 +1,12 @@
-#include <mbgl/text/font_stack.hpp>
-#include <cassert>
+#include <mbgl/text/glyph_set.hpp>
#include <mbgl/platform/log.hpp>
#include <mbgl/util/math.hpp>
+#include <cassert>
+
namespace mbgl {
-void FontStack::insert(uint32_t id, const SDFGlyph &glyph) {
+void GlyphSet::insert(uint32_t id, const SDFGlyph &glyph) {
auto it = sdfs.find(id);
if (it == sdfs.end()) {
// Glyph doesn't exist yet.
@@ -25,11 +26,11 @@ void FontStack::insert(uint32_t id, const SDFGlyph &glyph) {
}
}
-const std::map<uint32_t, SDFGlyph> &FontStack::getSDFs() const {
+const std::map<uint32_t, SDFGlyph> &GlyphSet::getSDFs() const {
return sdfs;
}
-const Shaping FontStack::getShaping(const std::u32string &string, const float maxWidth,
+const Shaping GlyphSet::getShaping(const std::u32string &string, const float maxWidth,
const float lineHeight, const float horizontalAlign,
const float verticalAlign, const float justify,
const float spacing, const vec2<float> &translate) const {
@@ -84,7 +85,7 @@ void justifyLine(std::vector<PositionedGlyph> &positionedGlyphs, const std::map<
}
}
-void FontStack::lineWrap(Shaping &shaping, const float lineHeight, const float maxWidth,
+void GlyphSet::lineWrap(Shaping &shaping, const float lineHeight, const float maxWidth,
const float horizontalAlign, const float verticalAlign,
const float justify, const vec2<float> &translate) const {
uint32_t lastSafeBreak = 0;
diff --git a/src/mbgl/text/font_stack.hpp b/src/mbgl/text/glyph_set.hpp
index d81460a534..5714071650 100644
--- a/src/mbgl/text/font_stack.hpp
+++ b/src/mbgl/text/glyph_set.hpp
@@ -1,12 +1,12 @@
-#ifndef MBGL_TEXT_FONT_STACK
-#define MBGL_TEXT_FONT_STACK
+#ifndef MBGL_TEXT_GLYPH_SET
+#define MBGL_TEXT_GLYPH_SET
#include <mbgl/text/glyph.hpp>
#include <mbgl/util/vec.hpp>
namespace mbgl {
-class FontStack {
+class GlyphSet {
public:
void insert(uint32_t id, const SDFGlyph &glyph);
const std::map<uint32_t, SDFGlyph> &getSDFs() const;
diff --git a/src/mbgl/text/glyph_store.cpp b/src/mbgl/text/glyph_store.cpp
index cd960dd8e2..9f6a6b7b72 100644
--- a/src/mbgl/text/glyph_store.cpp
+++ b/src/mbgl/text/glyph_store.cpp
@@ -53,15 +53,15 @@ bool GlyphStore::hasGlyphRanges(const std::string& fontStackName, const std::set
return hasRanges;
}
-util::exclusive<FontStack> GlyphStore::getFontStack(const std::string& fontStack) {
- auto lock = std::make_unique<std::lock_guard<std::mutex>>(stacksMutex);
+util::exclusive<GlyphSet> GlyphStore::getGlyphSet(const std::string& fontStack) {
+ auto lock = std::make_unique<std::lock_guard<std::mutex>>(glyphSetsMutex);
- auto it = stacks.find(fontStack);
- if (it == stacks.end()) {
- it = stacks.emplace(fontStack, std::make_unique<FontStack>()).first;
+ auto it = glyphSets.find(fontStack);
+ if (it == glyphSets.end()) {
+ it = glyphSets.emplace(fontStack, std::make_unique<GlyphSet>()).first;
}
- // FIXME: We lock all FontStacks, but what we should
+ // FIXME: We lock all GlyphSets, but what we should
// really do is lock only the one we are returning.
return { it->second.get(), std::move(lock) };
}
diff --git a/src/mbgl/text/glyph_store.hpp b/src/mbgl/text/glyph_store.hpp
index 6829397851..5b80589f4b 100644
--- a/src/mbgl/text/glyph_store.hpp
+++ b/src/mbgl/text/glyph_store.hpp
@@ -1,8 +1,8 @@
#ifndef MBGL_TEXT_GLYPH_STORE
#define MBGL_TEXT_GLYPH_STORE
-#include <mbgl/text/font_stack.hpp>
#include <mbgl/text/glyph.hpp>
+#include <mbgl/text/glyph_set.hpp>
#include <mbgl/util/exclusive.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/work_queue.hpp>
@@ -18,7 +18,7 @@ class FileSource;
class GlyphPBF;
// The GlyphStore manages the loading and storage of Glyphs
-// and creation of FontStack objects. The GlyphStore lives
+// and creation of GlyphSet objects. The GlyphStore lives
// on the MapThread but can be queried from any thread.
class GlyphStore : private util::noncopyable {
public:
@@ -33,12 +33,12 @@ public:
GlyphStore(FileSource&);
~GlyphStore();
- util::exclusive<FontStack> getFontStack(const std::string& fontStack);
+ util::exclusive<GlyphSet> getGlyphSet(const std::string& 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
- // FontStack and a signal is emitted to notify the observers. This method
+ // 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);
@@ -61,8 +61,8 @@ private:
std::unordered_map<std::string, std::map<GlyphRange, std::unique_ptr<GlyphPBF>>> ranges;
std::mutex rangesMutex;
- std::unordered_map<std::string, std::unique_ptr<FontStack>> stacks;
- std::mutex stacksMutex;
+ std::unordered_map<std::string, std::unique_ptr<GlyphSet>> glyphSets;
+ std::mutex glyphSetsMutex;
util::WorkQueue workQueue;