[core] Use a separate atlas and store for annotation sprites

Fixes #1488
This commit is contained in:
Adam Hunter
2015-11-16 16:26:02 -08:00
committed by John Firebaugh
parent 58886842bc
commit e1091db45e
14 changed files with 69 additions and 27 deletions

View File

@@ -243,7 +243,7 @@ bool MapContext::renderSync(const TransformState& state, const FrameData& frame)
glObjectStore.performCleanup();
if (!painter) painter = std::make_unique<Painter>(data, transformState);
painter->render(*style, frame);
painter->render(*style, frame, data.getAnnotationManager()->getSpriteAtlas());
if (data.mode == MapMode::Still) {
callback(nullptr, std::move(view.readStillImage()));
@@ -269,12 +269,7 @@ bool MapContext::isLoaded() const {
double MapContext::getTopOffsetPixelsForAnnotationSymbol(const std::string& symbol) {
assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
auto sprite = style->spriteStore->getSprite(symbol);
if (sprite) {
return -sprite->height / 2;
} else {
return 0;
}
return data.getAnnotationManager()->getTopOffsetPixelsForAnnotationSymbol(symbol);
}
void MapContext::setSourceTileCacheSize(size_t size) {
@@ -299,14 +294,8 @@ void MapContext::onLowMemory() {
}
void MapContext::setSprite(const std::string& name, std::shared_ptr<const SpriteImage> sprite) {
if (!style) {
Log::Info(Event::Sprite, "Ignoring sprite without stylesheet");
return;
}
style->spriteStore->setSprite(name, sprite);
style->spriteAtlas->updateDirty();
assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
data.getAnnotationManager()->setSprite(name, sprite);
}
void MapContext::onTileDataChanged() {

View File

@@ -24,6 +24,7 @@ public:
: mode(mode_)
, contextMode(contextMode_)
, pixelRatio(pixelRatio_)
, annotationManager(pixelRatio)
, animationTime(Duration::zero())
, defaultFadeDuration(mode_ == MapMode::Continuous ? std::chrono::milliseconds(300) : Duration::zero())
, defaultTransitionDuration(Duration::zero())

View File

@@ -64,7 +64,9 @@ TileParseResult TileWorker::parsePendingLayers() {
if (layer.type == StyleLayerType::Symbol) {
auto symbolBucket = dynamic_cast<SymbolBucket*>(bucket.get());
if (!symbolBucket->needsDependencies(*style.glyphStore, *style.spriteStore)) {
symbolBucket->addFeatures(reinterpret_cast<uintptr_t>(this), *style.spriteAtlas,
const SymbolLayer* symbolLayer = dynamic_cast<const SymbolLayer*>(&layer);
symbolBucket->addFeatures(reinterpret_cast<uintptr_t>(this),
*symbolLayer->spriteAtlas,
*style.glyphAtlas, *style.glyphStore, *collisionTile);
insertBucket(layer.bucketName(), std::move(bucket));
pending.erase(it++);