From 1d15ed64dcf78daa9459247127857513608c18ad Mon Sep 17 00:00:00 2001 From: Asheem Mamoowala Date: Tue, 20 Jun 2017 11:09:19 -0700 Subject: [core] Use shared pointer to manage Image source raster data and speed up change detection --- src/mbgl/style/sources/image_source_impl.cpp | 8 ++++---- src/mbgl/style/sources/image_source_impl.hpp | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/mbgl/style') diff --git a/src/mbgl/style/sources/image_source_impl.cpp b/src/mbgl/style/sources/image_source_impl.cpp index 98f3cc9db9..eb3e2635e5 100644 --- a/src/mbgl/style/sources/image_source_impl.cpp +++ b/src/mbgl/style/sources/image_source_impl.cpp @@ -12,17 +12,17 @@ ImageSource::Impl::Impl(std::string id_, std::array coords_) ImageSource::Impl::Impl(const Impl& other, std::array coords_) : Source::Impl(other), coords(std::move(coords_)), - image(other.image.clone()) { + image(other.image) { } -ImageSource::Impl::Impl(const Impl& rhs, UnassociatedImage image_) +ImageSource::Impl::Impl(const Impl& rhs, UnassociatedImage&& image_) : Source::Impl(rhs), coords(rhs.coords), - image(std::move(image_)) { + image(std::make_shared(std::move(image_))) { } ImageSource::Impl::~Impl() = default; -const UnassociatedImage& ImageSource::Impl::getImage() const { +std::shared_ptr ImageSource::Impl::getImage() const { return image; } diff --git a/src/mbgl/style/sources/image_source_impl.hpp b/src/mbgl/style/sources/image_source_impl.hpp index 5fd41ac6e6..e0999c34a5 100644 --- a/src/mbgl/style/sources/image_source_impl.hpp +++ b/src/mbgl/style/sources/image_source_impl.hpp @@ -13,17 +13,17 @@ class ImageSource::Impl : public Source::Impl { public: Impl(std::string id, std::array coords); Impl(const Impl& rhs, std::array coords); - Impl(const Impl& rhs, UnassociatedImage image); + Impl(const Impl& rhs, UnassociatedImage&& image); ~Impl() final; - const UnassociatedImage& getImage() const; + std::shared_ptr getImage() const; std::array getCoordinates() const; optional getAttribution() const final; private: std::array coords; - UnassociatedImage image; + std::shared_ptr image; }; } // namespace style -- cgit v1.2.1