[core] Replace GlyphRangeSet in onGlyphsAvailable with optionals in the map

GlyphRangeSet isn't keyed by FontStack, so using it to indicate that a particular range was loaded could have produced false positives.
This commit is contained in:
John Firebaugh
2017-04-06 09:20:07 -07:00
parent 09a2271576
commit a50d7a331b
10 changed files with 56 additions and 93 deletions

View File

@@ -133,8 +133,8 @@ void GeometryTile::onError(std::exception_ptr err) {
observer->onTileError(*this, err);
}
void GeometryTile::onGlyphsAvailable(GlyphPositionMap glyphPositions, GlyphRangeSet loadedRanges) {
worker.invoke(&GeometryTileWorker::onGlyphsAvailable, std::move(glyphPositions), std::move(loadedRanges));
void GeometryTile::onGlyphsAvailable(GlyphPositionMap glyphPositions) {
worker.invoke(&GeometryTileWorker::onGlyphsAvailable, std::move(glyphPositions));
}
void GeometryTile::getGlyphs(GlyphDependencies glyphDependencies) {

View File

@@ -40,7 +40,7 @@ public:
void setPlacementConfig(const PlacementConfig&) override;
void redoLayout() override;
void onGlyphsAvailable(GlyphPositionMap, GlyphRangeSet) override;
void onGlyphsAvailable(GlyphPositionMap) override;
void onIconsAvailable(SpriteAtlas*, IconMap) override;
void getGlyphs(GlyphDependencies);

View File

@@ -196,30 +196,21 @@ void GeometryTileWorker::coalesce() {
self.invoke(&GeometryTileWorker::coalesced);
}
void GeometryTileWorker::onGlyphsAvailable(GlyphPositionMap newGlyphPositions) {
for (auto& newFontGlyphs : newGlyphPositions) {
const FontStack& fontStack = newFontGlyphs.first;
GlyphPositions& newPositions = newFontGlyphs.second;
void GeometryTileWorker::onGlyphsAvailable(GlyphPositionMap newGlyphPositions, GlyphRangeSet loadedRanges) {
GlyphDependencies loadedGlyphs;
for (auto& pendingFontGlyphs : pendingGlyphDependencies) {
auto newFontGlyphs = newGlyphPositions.find(pendingFontGlyphs.first);
for (auto glyphID : pendingFontGlyphs.second) {
if (newFontGlyphs != newGlyphPositions.end()) {
auto newFontGlyph = newFontGlyphs->second.find(glyphID);
if (newFontGlyph != newFontGlyphs->second.end()) {
glyphPositions[pendingFontGlyphs.first].emplace(glyphID, newFontGlyph->second);
}
GlyphPositions& positions = glyphPositions[fontStack];
GlyphIDs& pendingGlyphIDs = pendingGlyphDependencies[fontStack];
for (auto& newPosition : newPositions) {
const GlyphID& glyphID = newPosition.first;
optional<Glyph>& glyph = newPosition.second;
if (pendingGlyphIDs.erase(glyphID)) {
positions.emplace(glyphID, std::move(glyph));
}
if (loadedRanges.find(getGlyphRange(glyphID)) != loadedRanges.end()) {
// Erase the glyph from our pending font set as long as its range is loaded
// If the glyph itself is missing, that means we can't get a glyph for
// this fontstack, and we go ahead and render with missing glyphs
loadedGlyphs[pendingFontGlyphs.first].insert(glyphID);
}
}
}
for (auto& loadedFont : loadedGlyphs) {
for (auto loadedGlyph : loadedFont.second) {
pendingGlyphDependencies[loadedFont.first].erase(loadedGlyph);
}
}
symbolDependenciesChanged();

View File

@@ -35,7 +35,7 @@ public:
void setData(std::unique_ptr<const GeometryTileData>, uint64_t correlationID);
void setPlacementConfig(PlacementConfig, uint64_t correlationID);
void onGlyphsAvailable(GlyphPositionMap glyphs, GlyphRangeSet loadedRanges);
void onGlyphsAvailable(GlyphPositionMap glyphs);
void onIconsAvailable(IconAtlasMap icons);
private: