summaryrefslogtreecommitdiff
path: root/src/mbgl/style
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-05-12 12:32:42 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-05-15 08:20:18 -0700
commit8fb1a81c46f4358d731712c16868aa1108d5d34c (patch)
treef56e8f16e0c0824b0d9aab045bd234bfd7fcde45 /src/mbgl/style
parentb3ec985568176b077756b66754470988436d43c1 (diff)
downloadqtlocation-mapboxgl-8fb1a81c46f4358d731712c16868aa1108d5d34c.tar.gz
[core] Immutable<Impl> for Image
Diffstat (limited to 'src/mbgl/style')
-rw-r--r--src/mbgl/style/image.cpp5
-rw-r--r--src/mbgl/style/style.cpp5
2 files changed, 5 insertions, 5 deletions
diff --git a/src/mbgl/style/image.cpp b/src/mbgl/style/image.cpp
index c5fecec2b2..606d9907a4 100644
--- a/src/mbgl/style/image.cpp
+++ b/src/mbgl/style/image.cpp
@@ -8,11 +8,10 @@ namespace style {
Image::Image(PremultipliedImage &&image,
const float pixelRatio,
bool sdf)
- : impl(std::make_shared<Impl>(std::move(image), pixelRatio, sdf)) {
+ : impl(makeMutable<Impl>(std::move(image), pixelRatio, sdf)) {
}
-PremultipliedImage& Image::getImage() const {
- assert(impl);
+const PremultipliedImage& Image::getImage() const {
return impl->image;
}
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index ae9ed97427..256949af3b 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -544,7 +544,7 @@ bool Style::isLoaded() const {
void Style::addImage(const std::string& id, std::unique_ptr<style::Image> image) {
addSpriteImage(spriteImages, id, std::move(image), [&](style::Image& added) {
- spriteAtlas->addImage(id, std::make_unique<style::Image>(added));
+ spriteAtlas->addImage(id, added.impl);
observer->onUpdate(Update::Repaint);
});
}
@@ -557,7 +557,8 @@ void Style::removeImage(const std::string& id) {
}
const style::Image* Style::getImage(const std::string& id) const {
- return spriteAtlas->getImage(id);
+ auto it = spriteImages.find(id);
+ return it == spriteImages.end() ? nullptr : it->second.get();
}
RenderData Style::getRenderData(MapDebugOptions debugOptions, float angle) const {