diff options
60 files changed, 237 insertions, 214 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 3b2c97122e..786c7196ae 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -7,11 +7,11 @@ #include <mbgl/util/noncopyable.hpp> #include <mbgl/util/time.hpp> #include <mbgl/util/uv.hpp> +#include <mbgl/util/ptr.hpp> #include <cstdint> #include <atomic> #include <iosfwd> -#include <memory> #include <set> #include <vector> @@ -48,7 +48,7 @@ public: // Triggers a lazy rerender: only performs a render when the map is not clean. void rerender(); - void renderLayer(std::shared_ptr<StyleLayer> layer_desc, RenderPass pass, const Tile::ID* id = nullptr, const mat4* matrix = nullptr); + void renderLayer(util::ptr<StyleLayer> layer_desc, RenderPass pass, const Tile::ID* id = nullptr, const mat4* matrix = nullptr); // Forces a map update: always triggers a rerender. void update(); @@ -65,7 +65,7 @@ public: void resize(uint16_t width, uint16_t height, float ratio, uint16_t fb_width, uint16_t fb_height); // Styling - const std::set<std::shared_ptr<StyleSource>> getActiveSources() const; + const std::set<util::ptr<StyleSource>> getActiveSources() const; void setAppliedClasses(const std::vector<std::string> &classes); void toggleClass(const std::string &name); const std::vector<std::string> &getAppliedClasses() const; @@ -118,14 +118,14 @@ public: public: inline const TransformState &getState() const { return state; } - inline std::shared_ptr<FileSource> getFileSource() const { return fileSource; } - inline std::shared_ptr<Style> getStyle() const { return style; } - inline std::shared_ptr<GlyphAtlas> getGlyphAtlas() { return glyphAtlas; } - inline std::shared_ptr<GlyphStore> getGlyphStore() { return glyphStore; } - inline std::shared_ptr<SpriteAtlas> getSpriteAtlas() { return spriteAtlas; } - std::shared_ptr<Sprite> getSprite(); - inline std::shared_ptr<Texturepool> getTexturepool() { return texturepool; } - inline std::shared_ptr<uv::loop> getLoop() { return loop; } + inline util::ptr<FileSource> getFileSource() const { return fileSource; } + inline util::ptr<Style> getStyle() const { return style; } + inline util::ptr<GlyphAtlas> getGlyphAtlas() { return glyphAtlas; } + inline util::ptr<GlyphStore> getGlyphStore() { return glyphStore; } + inline util::ptr<SpriteAtlas> getSpriteAtlas() { return spriteAtlas; } + util::ptr<Sprite> getSprite(); + inline util::ptr<Texturepool> getTexturepool() { return texturepool; } + inline util::ptr<uv::loop> getLoop() { return loop; } inline timestamp getAnimationTime() const { return animationTime; } inline timestamp getTime() const { return animationTime; } void updateTiles(); @@ -141,7 +141,7 @@ private: void setup(); void updateSources(); - void updateSources(const std::shared_ptr<StyleLayerGroup> &group); + void updateSources(const util::ptr<StyleLayerGroup> &group); void updateRenderState(); @@ -154,11 +154,11 @@ private: // Unconditionally performs a render with the current map state. void render(); - void renderLayers(std::shared_ptr<StyleLayerGroup> group); + void renderLayers(util::ptr<StyleLayerGroup> group); private: bool async = false; - std::shared_ptr<uv::loop> loop; + util::ptr<uv::loop> loop; std::unique_ptr<uv::thread> thread; std::unique_ptr<uv_async_t> async_terminate; std::unique_ptr<uv_async_t> async_render; @@ -189,14 +189,14 @@ private: Transform transform; TransformState state; - std::shared_ptr<FileSource> fileSource; + util::ptr<FileSource> fileSource; - std::shared_ptr<Style> style; - std::shared_ptr<GlyphAtlas> glyphAtlas; - std::shared_ptr<GlyphStore> glyphStore; - std::shared_ptr<SpriteAtlas> spriteAtlas; - std::shared_ptr<Sprite> sprite; - std::shared_ptr<Texturepool> texturepool; + util::ptr<Style> style; + util::ptr<GlyphAtlas> glyphAtlas; + util::ptr<GlyphStore> glyphStore; + util::ptr<SpriteAtlas> spriteAtlas; + util::ptr<Sprite> sprite; + util::ptr<Texturepool> texturepool; Painter painter; @@ -209,7 +209,7 @@ private: int indent = 0; - std::set<std::shared_ptr<StyleSource>> activeSources; + std::set<util::ptr<StyleSource>> activeSources; }; diff --git a/include/mbgl/map/raster_tile_data.hpp b/include/mbgl/map/raster_tile_data.hpp index 98aa3baaf5..329bbf4634 100644 --- a/include/mbgl/map/raster_tile_data.hpp +++ b/include/mbgl/map/raster_tile_data.hpp @@ -5,8 +5,6 @@ #include <mbgl/map/tile_data.hpp> #include <mbgl/renderer/raster_bucket.hpp> -#include <memory> - namespace mbgl { class Map; @@ -22,8 +20,8 @@ public: ~RasterTileData(); virtual void parse(); - virtual void render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const mat4 &matrix); - virtual bool hasData(std::shared_ptr<StyleLayer> layer_desc) const; + virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix); + virtual bool hasData(util::ptr<StyleLayer> layer_desc) const; protected: StyleBucketRaster properties; diff --git a/include/mbgl/map/source.hpp b/include/mbgl/map/source.hpp index cb069db272..471165f37c 100644 --- a/include/mbgl/map/source.hpp +++ b/include/mbgl/map/source.hpp @@ -8,12 +8,12 @@ #include <mbgl/util/noncopyable.hpp> #include <mbgl/util/time.hpp> #include <mbgl/util/mat4.hpp> +#include <mbgl/util/ptr.hpp> #include <cstdint> #include <forward_list> #include <iosfwd> #include <map> -#include <memory> namespace mbgl { @@ -33,8 +33,8 @@ public: void updateMatrices(const mat4 &projMatrix, const TransformState &transform); void drawClippingMasks(Painter &painter); size_t getTileCount() const; - void render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc); - void render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix); + void render(Painter &painter, util::ptr<StyleLayer> layer_desc); + void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix); void finishRender(Painter &painter); std::forward_list<Tile::ID> getIDs() const; diff --git a/include/mbgl/map/sprite.hpp b/include/mbgl/map/sprite.hpp index 6461a5e33d..454ebd8886 100644 --- a/include/mbgl/map/sprite.hpp +++ b/include/mbgl/map/sprite.hpp @@ -3,11 +3,11 @@ #include <mbgl/util/image.hpp> #include <mbgl/util/noncopyable.hpp> +#include <mbgl/util/ptr.hpp> #include <cstdint> #include <atomic> #include <iosfwd> -#include <memory> #include <string> #include <unordered_map> #include <future> @@ -34,11 +34,11 @@ public: class Sprite : public std::enable_shared_from_this<Sprite>, private util::noncopyable { private: struct Key {}; - void load(const std::shared_ptr<FileSource> &fileSource); + void load(const util::ptr<FileSource> &fileSource); public: Sprite(const Key &, const std::string& base_url, float pixelRatio); - static std::shared_ptr<Sprite> Create(const std::string& base_url, float pixelRatio, const std::shared_ptr<FileSource> &fileSource); + static util::ptr<Sprite> Create(const std::string& base_url, float pixelRatio, const util::ptr<FileSource> &fileSource); const SpritePosition &getSpritePosition(const std::string& name) const; diff --git a/include/mbgl/map/tile.hpp b/include/mbgl/map/tile.hpp index 75ced7e384..b9f0556add 100644 --- a/include/mbgl/map/tile.hpp +++ b/include/mbgl/map/tile.hpp @@ -3,6 +3,7 @@ #include <mbgl/util/mat4.hpp> #include <mbgl/util/noncopyable.hpp> +#include <mbgl/util/ptr.hpp> #include <cstdint> #include <bitset> @@ -10,7 +11,6 @@ #include <cstdint> #include <forward_list> #include <iosfwd> -#include <memory> #include <string> namespace mbgl { @@ -78,7 +78,7 @@ public: const Tile::ID id; ClipID clip; mat4 matrix; - std::shared_ptr<TileData> data; + util::ptr<TileData> data; }; } diff --git a/include/mbgl/map/tile_data.hpp b/include/mbgl/map/tile_data.hpp index 900224be2d..803f0447b3 100644 --- a/include/mbgl/map/tile_data.hpp +++ b/include/mbgl/map/tile_data.hpp @@ -6,11 +6,11 @@ #include <mbgl/geometry/debug_font_buffer.hpp> #include <mbgl/util/noncopyable.hpp> +#include <mbgl/util/ptr.hpp> #include <atomic> #include <exception> #include <iosfwd> -#include <memory> #include <string> namespace mbgl { @@ -28,7 +28,7 @@ public: struct geometry_too_long_exception : exception {}; public: - typedef std::shared_ptr<TileData> Ptr; + typedef util::ptr<TileData> Ptr; enum class State { invalid, @@ -56,8 +56,8 @@ public: virtual void beforeParse(); virtual void parse() = 0; virtual void afterParse(); - virtual void render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const mat4 &matrix) = 0; - virtual bool hasData(std::shared_ptr<StyleLayer> layer_desc) const = 0; + virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix) = 0; + virtual bool hasData(util::ptr<StyleLayer> layer_desc) const = 0; public: diff --git a/include/mbgl/map/tile_parser.hpp b/include/mbgl/map/tile_parser.hpp index fa64dad6d5..ddb4b98820 100644 --- a/include/mbgl/map/tile_parser.hpp +++ b/include/mbgl/map/tile_parser.hpp @@ -4,10 +4,10 @@ #include <mbgl/map/vector_tile.hpp> #include <mbgl/style/filter_expression.hpp> #include <mbgl/text/glyph.hpp> +#include <mbgl/util/ptr.hpp> #include <cstdint> #include <iosfwd> -#include <memory> #include <string> namespace mbgl { @@ -32,11 +32,11 @@ class Collision; class TileParser { public: TileParser(const std::string &data, VectorTileData &tile, - const std::shared_ptr<const Style> &style, - const std::shared_ptr<GlyphAtlas> &glyphAtlas, - const std::shared_ptr<GlyphStore> &glyphStore, - const std::shared_ptr<SpriteAtlas> &spriteAtlas, - const std::shared_ptr<Sprite> &sprite); + const util::ptr<const Style> &style, + const util::ptr<GlyphAtlas> &glyphAtlas, + const util::ptr<GlyphStore> &glyphStore, + const util::ptr<SpriteAtlas> &spriteAtlas, + const util::ptr<Sprite> &sprite); ~TileParser(); public: @@ -44,11 +44,11 @@ public: private: bool obsolete() const; - void parseStyleLayers(std::shared_ptr<StyleLayerGroup> group); - std::unique_ptr<Bucket> createBucket(std::shared_ptr<StyleBucket> bucket_desc); + void parseStyleLayers(util::ptr<StyleLayerGroup> group); + std::unique_ptr<Bucket> createBucket(util::ptr<StyleBucket> bucket_desc); std::unique_ptr<Bucket> createFillBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketFill &fill); - std::unique_ptr<Bucket> createRasterBucket(const std::shared_ptr<Texturepool> &texturepool, const StyleBucketRaster &raster); + std::unique_ptr<Bucket> createRasterBucket(const util::ptr<Texturepool> &texturepool, const StyleBucketRaster &raster); std::unique_ptr<Bucket> createLineBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketLine &line); std::unique_ptr<Bucket> createSymbolBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketSymbol &symbol); @@ -59,12 +59,12 @@ private: VectorTileData& tile; // Cross-thread shared data. - std::shared_ptr<const Style> style; - std::shared_ptr<GlyphAtlas> glyphAtlas; - std::shared_ptr<GlyphStore> glyphStore; - std::shared_ptr<SpriteAtlas> spriteAtlas; - std::shared_ptr<Sprite> sprite; - std::shared_ptr<Texturepool> texturePool; + util::ptr<const Style> style; + util::ptr<GlyphAtlas> glyphAtlas; + util::ptr<GlyphStore> glyphStore; + util::ptr<SpriteAtlas> spriteAtlas; + util::ptr<Sprite> sprite; + util::ptr<Texturepool> texturePool; std::unique_ptr<Collision> collision; }; diff --git a/include/mbgl/map/transform.hpp b/include/mbgl/map/transform.hpp index d0f56b7fba..5404f333c1 100644 --- a/include/mbgl/map/transform.hpp +++ b/include/mbgl/map/transform.hpp @@ -98,10 +98,10 @@ private: // cache values for spherical mercator math double Bc, Cc; - std::forward_list<std::shared_ptr<util::transition>> transitions; - std::shared_ptr<util::transition> scale_timeout; - std::shared_ptr<util::transition> rotate_timeout; - std::shared_ptr<util::transition> pan_timeout; + std::forward_list<util::ptr<util::transition>> transitions; + util::ptr<util::transition> scale_timeout; + util::ptr<util::transition> rotate_timeout; + util::ptr<util::transition> pan_timeout; }; } diff --git a/include/mbgl/map/vector_tile_data.hpp b/include/mbgl/map/vector_tile_data.hpp index deb628e485..3f80c0080c 100644 --- a/include/mbgl/map/vector_tile_data.hpp +++ b/include/mbgl/map/vector_tile_data.hpp @@ -32,8 +32,8 @@ public: virtual void beforeParse(); virtual void parse(); virtual void afterParse(); - virtual void render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const mat4 &matrix); - virtual bool hasData(std::shared_ptr<StyleLayer> layer_desc) const; + virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix); + virtual bool hasData(util::ptr<StyleLayer> layer_desc) const; protected: // Holds the actual geometries in this tile. diff --git a/include/mbgl/renderer/bucket.hpp b/include/mbgl/renderer/bucket.hpp index 1391f6e3e3..696bfb1110 100644 --- a/include/mbgl/renderer/bucket.hpp +++ b/include/mbgl/renderer/bucket.hpp @@ -1,11 +1,11 @@ #ifndef MBGL_RENDERER_BUCKET #define MBGL_RENDERER_BUCKET -#include <string> -#include <memory> #include <mbgl/map/tile.hpp> #include <mbgl/util/noncopyable.hpp> +#include <string> + namespace mbgl { class Painter; @@ -13,7 +13,7 @@ class StyleLayer; class Bucket : private util::noncopyable { public: - virtual void render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) = 0; + virtual void render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) = 0; virtual bool hasData() const = 0; virtual ~Bucket() {} diff --git a/include/mbgl/renderer/debug_bucket.hpp b/include/mbgl/renderer/debug_bucket.hpp index 660b7fcba8..fb6cfb4cae 100644 --- a/include/mbgl/renderer/debug_bucket.hpp +++ b/include/mbgl/renderer/debug_bucket.hpp @@ -6,7 +6,6 @@ #include <mbgl/geometry/vao.hpp> #include <vector> -#include <memory> #ifndef BUFFER_OFFSET #define BUFFER_OFFSET(i) ((char *)nullptr + (i)) @@ -20,7 +19,7 @@ class DebugBucket : public Bucket { public: DebugBucket(DebugFontBuffer& fontBuffer); - virtual void render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); + virtual void render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); virtual bool hasData() const; void drawLines(PlainShader& shader); diff --git a/include/mbgl/renderer/fill_bucket.hpp b/include/mbgl/renderer/fill_bucket.hpp index 15868e4092..ae766ec28d 100644 --- a/include/mbgl/renderer/fill_bucket.hpp +++ b/include/mbgl/renderer/fill_bucket.hpp @@ -44,7 +44,7 @@ public: const StyleBucketFill& properties); ~FillBucket(); - virtual void render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); + virtual void render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); virtual bool hasData() const; void addGeometry(pbf& data); diff --git a/include/mbgl/renderer/line_bucket.hpp b/include/mbgl/renderer/line_bucket.hpp index 8babb734ed..7337ca80ad 100644 --- a/include/mbgl/renderer/line_bucket.hpp +++ b/include/mbgl/renderer/line_bucket.hpp @@ -1,13 +1,12 @@ #ifndef MBGL_RENDERER_LINEBUCKET #define MBGL_RENDERER_LINEBUCKET -#include "bucket.hpp" +#include <mbgl/renderer/bucket.hpp> #include <mbgl/geometry/vao.hpp> #include <mbgl/geometry/elements_buffer.hpp> #include <mbgl/geometry/line_buffer.hpp> #include <mbgl/style/style_bucket.hpp> -#include <memory> #include <vector> namespace mbgl { @@ -30,7 +29,7 @@ public: PointElementsBuffer& pointElementsBuffer, const StyleBucketLine& properties); - virtual void render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); + virtual void render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); virtual bool hasData() const; void addGeometry(pbf& data); diff --git a/include/mbgl/renderer/painter.hpp b/include/mbgl/renderer/painter.hpp index 75529d1136..13c2050bd0 100644 --- a/include/mbgl/renderer/painter.hpp +++ b/include/mbgl/renderer/painter.hpp @@ -22,6 +22,7 @@ #include <mbgl/shader/gaussian_shader.hpp> #include <mbgl/map/transform_state.hpp> +#include <mbgl/util/ptr.hpp> #include <map> #include <unordered_map> @@ -72,7 +73,7 @@ public: void changeMatrix(); // Renders a particular layer from a tile. - void renderTileLayer(const Tile& tile, std::shared_ptr<StyleLayer> layer_desc, const mat4 &matrix); + void renderTileLayer(const Tile& tile, util::ptr<StyleLayer> layer_desc, const mat4 &matrix); // Renders debug information for a tile. void renderTileDebug(const Tile& tile); @@ -82,11 +83,11 @@ public: void renderDebugText(DebugBucket& bucket, const mat4 &matrix); void renderDebugText(const std::vector<std::string> &strings); - void renderFill(FillBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); - void renderLine(LineBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); - void renderSymbol(SymbolBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); - void renderRaster(RasterBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); - void renderBackground(std::shared_ptr<StyleLayer> layer_desc); + void renderFill(FillBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); + void renderLine(LineBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); + void renderSymbol(SymbolBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); + void renderRaster(RasterBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); + void renderBackground(util::ptr<StyleLayer> layer_desc); float saturationFactor(float saturation); float contrastFactor(float contrast); @@ -96,7 +97,7 @@ public: void renderPrerenderedTexture(RasterBucket &bucket, const mat4 &matrix, const RasterProperties& properties); - void createPrerendered(RasterBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id); + void createPrerendered(RasterBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id); void resize(); @@ -110,7 +111,7 @@ public: // Configures the painter strata that is used for early z-culling of fragments. void setStrata(float strata); - void drawClippingMasks(const std::set<std::shared_ptr<StyleSource>> &sources); + void drawClippingMasks(const std::set<util::ptr<StyleSource>> &sources); void drawClippingMask(const mat4& matrix, const ClipID& clip); void resetFramebuffer(); diff --git a/include/mbgl/renderer/raster_bucket.hpp b/include/mbgl/renderer/raster_bucket.hpp index 66cceac8e7..794da3b143 100644 --- a/include/mbgl/renderer/raster_bucket.hpp +++ b/include/mbgl/renderer/raster_bucket.hpp @@ -16,9 +16,9 @@ class VertexArrayObject; class RasterBucket : public Bucket { public: - RasterBucket(const std::shared_ptr<Texturepool> &texturepool, const StyleBucketRaster& properties); + RasterBucket(const util::ptr<Texturepool> &texturepool, const StyleBucketRaster& properties); - virtual void render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); + virtual void render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); virtual bool hasData() const; bool setImage(const std::string &data); diff --git a/include/mbgl/renderer/symbol_bucket.hpp b/include/mbgl/renderer/symbol_bucket.hpp index c71d276456..42682401ef 100644 --- a/include/mbgl/renderer/symbol_bucket.hpp +++ b/include/mbgl/renderer/symbol_bucket.hpp @@ -56,7 +56,7 @@ class SymbolBucket : public Bucket { public: SymbolBucket(const StyleBucketSymbol &properties, Collision &collision); - virtual void render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix); + virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix); virtual bool hasData() const; virtual bool hasTextData() const; virtual bool hasIconData() const; diff --git a/include/mbgl/storage/base_request.hpp b/include/mbgl/storage/base_request.hpp index 05ef1e4a7b..c903742f4b 100644 --- a/include/mbgl/storage/base_request.hpp +++ b/include/mbgl/storage/base_request.hpp @@ -1,11 +1,13 @@ #ifndef MBGL_STORAGE_BASE_REQUEST #define MBGL_STORAGE_BASE_REQUEST +#include <mbgl/util/ptr.hpp> + #include <string> #include <forward_list> -#include <memory> #include <functional> + typedef struct uv_loop_s uv_loop_t; typedef struct uv_async_s uv_async_t; @@ -28,7 +30,7 @@ public: BaseRequest(const std::string &path); virtual ~BaseRequest(); - Callback *add(Callback &&callback, const std::shared_ptr<BaseRequest> &request); + Callback *add(Callback &&callback, const util::ptr<BaseRequest> &request); void remove(Callback *callback); void notify(); @@ -40,7 +42,7 @@ public: private: // This object may hold a shared_ptr to itself. It does this to prevent destruction of this object // while a request is in progress. - std::shared_ptr<BaseRequest> self; + util::ptr<BaseRequest> self; std::forward_list<std::unique_ptr<Callback>> callbacks; }; diff --git a/include/mbgl/storage/file_request.hpp b/include/mbgl/storage/file_request.hpp index 331ed8421f..c99237ad4b 100644 --- a/include/mbgl/storage/file_request.hpp +++ b/include/mbgl/storage/file_request.hpp @@ -1,11 +1,6 @@ #ifndef MBGL_STORAGE_FILE_REQUEST #define MBGL_STORAGE_FILE_REQUEST - -#include <string> -#include <memory> -#include <cassert> - #include <mbgl/storage/base_request.hpp> namespace mbgl { diff --git a/include/mbgl/storage/file_source.hpp b/include/mbgl/storage/file_source.hpp index 4cc95ae24e..06d416d0c6 100644 --- a/include/mbgl/storage/file_source.hpp +++ b/include/mbgl/storage/file_source.hpp @@ -5,7 +5,6 @@ #include <mbgl/storage/request.hpp> #include <string> -#include <memory> #include <unordered_map> #include <functional> @@ -44,7 +43,7 @@ private: std::string base; std::unordered_map<std::string, std::weak_ptr<BaseRequest>> pending; - std::shared_ptr<SQLiteStore> store; + util::ptr<SQLiteStore> store; uv_loop_t *loop = nullptr; uv_messenger_t *queue = nullptr; }; diff --git a/include/mbgl/storage/http_request.hpp b/include/mbgl/storage/http_request.hpp index 30f7b3aa6d..ef3210d48d 100644 --- a/include/mbgl/storage/http_request.hpp +++ b/include/mbgl/storage/http_request.hpp @@ -19,7 +19,7 @@ class SQLiteStore; class HTTPRequest : public BaseRequest { public: - HTTPRequest(ResourceType type, const std::string &path, uv_loop_t *loop, std::shared_ptr<SQLiteStore> store); + HTTPRequest(ResourceType type, const std::string &path, uv_loop_t *loop, util::ptr<SQLiteStore> store); ~HTTPRequest(); private: @@ -29,7 +29,7 @@ private: const unsigned long thread_id; CacheRequestBaton *cache_baton = nullptr; HTTPRequestBaton *http_baton = nullptr; - std::shared_ptr<SQLiteStore> store; + util::ptr<SQLiteStore> store; const ResourceType type; }; diff --git a/include/mbgl/storage/request.hpp b/include/mbgl/storage/request.hpp index fa27fbc781..10c938ed15 100644 --- a/include/mbgl/storage/request.hpp +++ b/include/mbgl/storage/request.hpp @@ -2,8 +2,8 @@ #define MBGL_STORAGE_REQUEST #include <mbgl/storage/response.hpp> +#include <mbgl/util/ptr.hpp> -#include <memory> #include <functional> #include <forward_list> @@ -22,7 +22,7 @@ private: Request& operator=(Request &&) = delete; public: - Request(const std::shared_ptr<BaseRequest> &base); + Request(const util::ptr<BaseRequest> &base); ~Request(); void onload(Callback cb); @@ -30,7 +30,7 @@ public: private: const unsigned long thread_id; - std::shared_ptr<BaseRequest> base; + util::ptr<BaseRequest> base; std::forward_list<Callback *> callbacks; }; diff --git a/include/mbgl/storage/sqlite_store.hpp b/include/mbgl/storage/sqlite_store.hpp index e03e6cf2bc..cb7730d0bf 100644 --- a/include/mbgl/storage/sqlite_store.hpp +++ b/include/mbgl/storage/sqlite_store.hpp @@ -38,7 +38,7 @@ private: private: const unsigned long thread_id; - std::shared_ptr<mapbox::sqlite::Database> db; + util::ptr<mapbox::sqlite::Database> db; uv_worker_t *worker = nullptr; }; diff --git a/include/mbgl/style/style.hpp b/include/mbgl/style/style.hpp index c09de6ebba..56f318ecbb 100644 --- a/include/mbgl/style/style.hpp +++ b/include/mbgl/style/style.hpp @@ -6,6 +6,7 @@ #include <mbgl/util/time.hpp> #include <mbgl/util/uv.hpp> +#include <mbgl/util/ptr.hpp> #include <cstdint> #include <map> @@ -13,7 +14,6 @@ #include <unordered_map> #include <vector> #include <set> -#include <memory> namespace mbgl { @@ -49,7 +49,7 @@ public: const std::string &getSpriteURL() const; public: - std::shared_ptr<StyleLayerGroup> layers; + util::ptr<StyleLayerGroup> layers; std::vector<std::string> appliedClasses; std::string glyph_url; diff --git a/include/mbgl/style/style_bucket.hpp b/include/mbgl/style/style_bucket.hpp index c2cde52aa5..c4a8f6037e 100644 --- a/include/mbgl/style/style_bucket.hpp +++ b/include/mbgl/style/style_bucket.hpp @@ -8,8 +8,8 @@ #include <mbgl/util/vec.hpp> #include <mbgl/util/variant.hpp> #include <mbgl/util/noncopyable.hpp> +#include <mbgl/util/ptr.hpp> -#include <memory> #include <forward_list> namespace mbgl { @@ -93,12 +93,12 @@ typedef mapbox::util::variant<StyleBucketFill, StyleBucketLine, StyleBucketSymbo class StyleBucket { public: - typedef std::shared_ptr<StyleBucket> Ptr; + typedef util::ptr<StyleBucket> Ptr; StyleBucket(StyleLayerType type); std::string name; - std::shared_ptr<StyleSource> style_source; + util::ptr<StyleSource> style_source; std::string source_layer; FilterExpression filter; StyleBucketRender render = std::false_type(); diff --git a/include/mbgl/style/style_layer.hpp b/include/mbgl/style/style_layer.hpp index 84981e3fb4..641dc1e71c 100644 --- a/include/mbgl/style/style_layer.hpp +++ b/include/mbgl/style/style_layer.hpp @@ -6,8 +6,9 @@ #include <mbgl/style/style_properties.hpp> #include <mbgl/style/applied_class_properties.hpp> +#include <mbgl/util/ptr.hpp> + #include <vector> -#include <memory> #include <string> #include <map> #include <set> @@ -64,7 +65,7 @@ public: // Bucket information, telling the renderer how to generate the geometries // for this layer (feature property filters, tessellation instructions, ...). - std::shared_ptr<StyleBucket> bucket; + util::ptr<StyleBucket> bucket; // Contains all style classes that can be applied to this layer. const std::map<ClassID, ClassProperties> styles; @@ -80,7 +81,7 @@ public: StyleProperties properties; // Child layer array (if this layer has child layers). - std::shared_ptr<StyleLayerGroup> layers; + util::ptr<StyleLayerGroup> layers; }; } diff --git a/include/mbgl/style/style_layer_group.hpp b/include/mbgl/style/style_layer_group.hpp index 983dd136f0..1af6e23bd7 100644 --- a/include/mbgl/style/style_layer_group.hpp +++ b/include/mbgl/style/style_layer_group.hpp @@ -15,7 +15,7 @@ public: bool hasTransitions() const; public: - std::vector<std::shared_ptr<StyleLayer>> layers; + std::vector<util::ptr<StyleLayer>> layers; }; } diff --git a/include/mbgl/style/style_parser.hpp b/include/mbgl/style/style_parser.hpp index e4e1b7f632..fc253bb1dd 100644 --- a/include/mbgl/style/style_parser.hpp +++ b/include/mbgl/style/style_parser.hpp @@ -27,7 +27,7 @@ public: void parse(JSVal document); - std::shared_ptr<StyleLayerGroup> getLayers() { + util::ptr<StyleLayerGroup> getLayers() { return root; } @@ -46,14 +46,14 @@ private: void parseSources(JSVal value); std::unique_ptr<StyleLayerGroup> createLayers(JSVal value); - std::shared_ptr<StyleLayer> createLayer(JSVal value); + util::ptr<StyleLayer> createLayer(JSVal value); void parseLayers(); - void parseLayer(std::pair<JSVal, std::shared_ptr<StyleLayer>> &pair); + void parseLayer(std::pair<JSVal, util::ptr<StyleLayer>> &pair); void parseStyles(JSVal value, std::map<ClassID, ClassProperties> &styles); void parseStyle(JSVal, ClassProperties &properties); - void parseReference(JSVal value, std::shared_ptr<StyleLayer> &layer); - void parseBucket(JSVal value, std::shared_ptr<StyleLayer> &layer); - void parseRender(JSVal value, std::shared_ptr<StyleLayer> &layer); + void parseReference(JSVal value, util::ptr<StyleLayer> &layer); + void parseBucket(JSVal value, util::ptr<StyleLayer> &layer); + void parseRender(JSVal value, util::ptr<StyleLayer> &layer); void parseSprite(JSVal value); void parseGlyphURL(JSVal value); @@ -94,13 +94,13 @@ private: private: std::unordered_map<std::string, const rapidjson::Value *> constants; - std::unordered_map<std::string, const std::shared_ptr<StyleSource>> sources; + std::unordered_map<std::string, const util::ptr<StyleSource>> sources; // This stores the root layer. - std::shared_ptr<StyleLayerGroup> root; + util::ptr<StyleLayerGroup> root; // This maps ids to Layer objects, with all items being at the root level. - std::unordered_map<std::string, std::pair<JSVal, std::shared_ptr<StyleLayer>>> layers; + std::unordered_map<std::string, std::pair<JSVal, util::ptr<StyleLayer>>> layers; // Store a stack of layers we're parsing right now. This is to prevent reference cycles. std::forward_list<StyleLayer *> stack; diff --git a/include/mbgl/style/style_source.hpp b/include/mbgl/style/style_source.hpp index b598550c65..4b89a6557c 100644 --- a/include/mbgl/style/style_source.hpp +++ b/include/mbgl/style/style_source.hpp @@ -2,13 +2,12 @@ #define MBGL_STYLE_STYLE_SOURCE #include <mbgl/style/types.hpp> +#include <mbgl/util/ptr.hpp> +#include <rapidjson/document.h> -#include <memory> #include <vector> #include <string> -#include <rapidjson/document.h> - namespace mbgl { class Source; @@ -34,7 +33,7 @@ public: SourceInfo info; bool enabled = false; - std::shared_ptr<Source> source; + util::ptr<Source> source; StyleSource(const SourceInfo &info) : info(info) diff --git a/include/mbgl/text/glyph_store.hpp b/include/mbgl/text/glyph_store.hpp index 9730967053..f8a7cb4d0c 100644 --- a/include/mbgl/text/glyph_store.hpp +++ b/include/mbgl/text/glyph_store.hpp @@ -4,6 +4,7 @@ #include <mbgl/text/glyph.hpp> #include <mbgl/util/pbf.hpp> #include <mbgl/util/vec.hpp> +#include <mbgl/util/ptr.hpp> #include <cstdint> #include <vector> @@ -47,7 +48,7 @@ private: class GlyphPBF { public: - GlyphPBF(const std::string &glyphURL, const std::string &fontStack, GlyphRange glyphRange, const std::shared_ptr<FileSource> &fileSource); + GlyphPBF(const std::string &glyphURL, const std::string &fontStack, GlyphRange glyphRange, const util::ptr<FileSource> &fileSource); private: GlyphPBF(const GlyphPBF &) = delete; @@ -70,7 +71,7 @@ private: // Manages Glyphrange PBF loading. class GlyphStore { public: - GlyphStore(const std::shared_ptr<FileSource> &fileSource); + GlyphStore(const util::ptr<FileSource> &fileSource); // Block until all specified GlyphRanges of the specified font stack are loaded. void waitForGlyphRanges(const std::string &fontStack, const std::set<GlyphRange> &glyphRanges); @@ -89,7 +90,7 @@ public: std::string glyphURL; private: - const std::shared_ptr<FileSource> fileSource; + const util::ptr<FileSource> fileSource; std::unordered_map<std::string, std::map<GlyphRange, std::unique_ptr<GlyphPBF>>> ranges; std::unordered_map<std::string, std::unique_ptr<FontStack>> stacks; std::mutex mtx; diff --git a/include/mbgl/util/ptr.hpp b/include/mbgl/util/ptr.hpp new file mode 100644 index 0000000000..5511083fc6 --- /dev/null +++ b/include/mbgl/util/ptr.hpp @@ -0,0 +1,29 @@ +#ifndef MBGL_UTIL_PTR +#define MBGL_UTIL_PTR + +#include <memory> +#include <cassert> + +namespace mbgl { +namespace util { + +template <typename T> +class ptr : public ::std::shared_ptr<T> { +public: + template <typename... Args> + inline ptr(Args &&... args) + : ::std::shared_ptr<T>(::std::forward<Args>(args)...) {} + + inline auto operator->() const -> decltype(::std::shared_ptr<T>::operator->()) { + assert(*this); + return ::std::shared_ptr<T>::operator->(); + } + inline auto operator*() const -> decltype(::std::shared_ptr<T>::operator*()) { + assert(*this); + return ::std::shared_ptr<T>::operator*(); + } +}; +} +} + +#endif
\ No newline at end of file diff --git a/include/mbgl/util/raster.hpp b/include/mbgl/util/raster.hpp index e526ffa5ac..7051c30091 100644 --- a/include/mbgl/util/raster.hpp +++ b/include/mbgl/util/raster.hpp @@ -4,11 +4,11 @@ #include <mbgl/util/transition.hpp> #include <mbgl/util/texturepool.hpp> #include <mbgl/util/image.hpp> +#include <mbgl/util/ptr.hpp> #include <mbgl/renderer/prerendered_texture.hpp> #include <string> #include <mutex> -#include <memory> typedef struct uv_loop_s uv_loop_t; @@ -17,7 +17,7 @@ namespace mbgl { class Raster : public std::enable_shared_from_this<Raster> { public: - Raster(const std::shared_ptr<Texturepool> &texturepool); + Raster(const util::ptr<Texturepool> &texturepool); ~Raster(); // load image data @@ -57,7 +57,7 @@ private: bool loaded = false; // shared texture pool - std::shared_ptr<Texturepool> texturepool; + util::ptr<Texturepool> texturepool; // min/mag filter uint32_t filter = 0; @@ -66,7 +66,7 @@ private: std::unique_ptr<util::Image> img; // fade in transition - std::shared_ptr<util::transition> fade_transition = nullptr; + util::ptr<util::transition> fade_transition = nullptr; }; } diff --git a/include/mbgl/util/uv_detail.hpp b/include/mbgl/util/uv_detail.hpp index eefb5ac8df..272ca41495 100644 --- a/include/mbgl/util/uv_detail.hpp +++ b/include/mbgl/util/uv_detail.hpp @@ -1,6 +1,8 @@ #ifndef MBGL_UTIL_UV_DETAIL #define MBGL_UTIL_UV_DETAIL +#include <mbgl/util/ptr.hpp> + #include <uv.h> #include <functional> @@ -113,7 +115,7 @@ public: typedef void (*after_work_callback)(T &object); template<typename... Args> - work(const std::shared_ptr<loop> &loop, work_callback work_cb, after_work_callback after_work_cb, Args&&... args) + work(const mbgl::util::ptr<loop> &loop, work_callback work_cb, after_work_callback after_work_cb, Args&&... args) : loop(loop), data(std::forward<Args>(args)...), work_cb(work_cb), @@ -135,7 +137,7 @@ private: } private: - std::shared_ptr<uv::loop> loop; + mbgl::util::ptr<uv::loop> loop; uv_work_t req; T data; work_callback work_cb; diff --git a/src/map/map.cpp b/src/map/map.cpp index 7db75cca06..ecf4eb2837 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -23,7 +23,6 @@ #include <mbgl/platform/log.hpp> #include <algorithm> -#include <memory> #include <iostream> #define _USE_MATH_DEFINES @@ -245,7 +244,7 @@ std::string Map::getAccessToken() const { return accessToken; } -std::shared_ptr<Sprite> Map::getSprite() { +util::ptr<Sprite> Map::getSprite() { const float pixelRatio = state.getPixelRatio(); const std::string &sprite_url = style->getSpriteURL(); if (!sprite || sprite->pixelRatio != pixelRatio) { @@ -478,7 +477,7 @@ void Map::updateSources() { assert(uv_thread_self() == map_thread); // First, disable all existing sources. - for (const std::shared_ptr<StyleSource> &source : activeSources) { + for (const util::ptr<StyleSource> &source : activeSources) { source->enabled = false; } @@ -486,7 +485,7 @@ void Map::updateSources() { updateSources(style->layers); // Then, construct or destroy the actual source object, depending on enabled state. - for (const std::shared_ptr<StyleSource> &style_source : activeSources) { + for (const util::ptr<StyleSource> &style_source : activeSources) { if (style_source->enabled) { if (!style_source->source) { style_source->source = std::make_shared<Source>(style_source->info); @@ -498,20 +497,20 @@ void Map::updateSources() { } // Finally, remove all sources that are disabled. - util::erase_if(activeSources, [](std::shared_ptr<StyleSource> source){ + util::erase_if(activeSources, [](util::ptr<StyleSource> source){ return !source->enabled; }); } -const std::set<std::shared_ptr<StyleSource>> Map::getActiveSources() const { +const std::set<util::ptr<StyleSource>> Map::getActiveSources() const { return activeSources; } -void Map::updateSources(const std::shared_ptr<StyleLayerGroup> &group) { +void Map::updateSources(const util::ptr<StyleLayerGroup> &group) { if (!group) { return; } - for (const std::shared_ptr<StyleLayer> &layer : group->layers) { + for (const util::ptr<StyleLayer> &layer : group->layers) { if (!layer) continue; if (layer->bucket) { if (layer->bucket->style_source) { @@ -524,7 +523,7 @@ void Map::updateSources(const std::shared_ptr<StyleLayerGroup> &group) { } void Map::updateTiles() { - for (const std::shared_ptr<StyleSource> &source : getActiveSources()) { + for (const util::ptr<StyleSource> &source : getActiveSources()) { source->source->update(*this); } } @@ -532,7 +531,7 @@ void Map::updateTiles() { void Map::updateRenderState() { // Update all clipping IDs. ClipIDGenerator generator; - for (const std::shared_ptr<StyleSource> &source : getActiveSources()) { + for (const util::ptr<StyleSource> &source : getActiveSources()) { generator.update(source->source->getLoadedTiles()); source->source->updateMatrices(painter.projMatrix, state); } @@ -609,7 +608,7 @@ void Map::render() { // This guarantees that we have at least one function per tile called. // When only rendering layers via the stylesheet, it's possible that we don't // ever visit a tile during rendering. - for (const std::shared_ptr<StyleSource> &source : getActiveSources()) { + for (const util::ptr<StyleSource> &source : getActiveSources()) { source->source->finishRender(painter); } @@ -621,7 +620,7 @@ void Map::render() { glFlush(); } -void Map::renderLayers(std::shared_ptr<StyleLayerGroup> group) { +void Map::renderLayers(util::ptr<StyleLayerGroup> group) { if (!group) { // Make sure that we actually do have a layer group. return; @@ -664,7 +663,7 @@ void Map::renderLayers(std::shared_ptr<StyleLayerGroup> group) { } } -void Map::renderLayer(std::shared_ptr<StyleLayer> layer_desc, RenderPass pass, const Tile::ID* id, const mat4* matrix) { +void Map::renderLayer(util::ptr<StyleLayer> layer_desc, RenderPass pass, const Tile::ID* id, const mat4* matrix) { if (layer_desc->type == StyleLayerType::Background) { // This layer defines a background color/image. diff --git a/src/map/raster_tile_data.cpp b/src/map/raster_tile_data.cpp index 182a614393..2f09a5fec5 100644 --- a/src/map/raster_tile_data.cpp +++ b/src/map/raster_tile_data.cpp @@ -25,10 +25,10 @@ void RasterTileData::parse() { } } -void RasterTileData::render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const mat4 &matrix) { +void RasterTileData::render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix) { bucket.render(painter, layer_desc, id, matrix); } -bool RasterTileData::hasData(std::shared_ptr<StyleLayer> /*layer_desc*/) const { +bool RasterTileData::hasData(util::ptr<StyleLayer> /*layer_desc*/) const { return bucket.hasData(); } diff --git a/src/map/source.cpp b/src/map/source.cpp index 50a276a165..348d99d3b0 100644 --- a/src/map/source.cpp +++ b/src/map/source.cpp @@ -35,7 +35,7 @@ void Source::load(Map& map) { } std::string url = util::mapbox::normalizeSourceURL(info.url, map.getAccessToken()); - std::shared_ptr<Source> source = shared_from_this(); + util::ptr<Source> source = shared_from_this(); map.getFileSource()->request(ResourceType::JSON, url)->onload([source, &map](const Response &res) { if (res.code != 200) { @@ -99,7 +99,7 @@ void Source::drawClippingMasks(Painter &painter) { } } -void Source::render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc) { +void Source::render(Painter &painter, util::ptr<StyleLayer> layer_desc) { gl::group group(std::string("layer: ") + layer_desc->id); for (const std::pair<const Tile::ID, std::unique_ptr<Tile>> &pair : tiles) { Tile &tile = *pair.second; @@ -109,7 +109,7 @@ void Source::render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc) { } } -void Source::render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix) { +void Source::render(Painter &painter, util::ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix) { auto it = tiles.find(id); if (it != tiles.end() && it->second->data && it->second->data->state == TileData::State::parsed) { painter.renderTileLayer(*it->second, layer_desc, matrix); @@ -334,7 +334,7 @@ bool Source::updateTiles(Map &map) { // Remove all the expired pointers from the set. util::erase_if(tile_data, [&retain_data](std::pair<const Tile::ID, std::weak_ptr<TileData>> &pair) { - const std::shared_ptr<TileData> tile = pair.second.lock(); + const util::ptr<TileData> tile = pair.second.lock(); if (!tile) { return true; } diff --git a/src/map/sprite.cpp b/src/map/sprite.cpp index c756ead159..c069ece45a 100644 --- a/src/map/sprite.cpp +++ b/src/map/sprite.cpp @@ -22,8 +22,8 @@ SpritePosition::SpritePosition(uint16_t x, uint16_t y, uint16_t width, uint16_t sdf(sdf) { } -std::shared_ptr<Sprite> Sprite::Create(const std::string& base_url, float pixelRatio, const std::shared_ptr<FileSource> &fileSource) { - std::shared_ptr<Sprite> sprite(std::make_shared<Sprite>(Key(), base_url, pixelRatio)); +util::ptr<Sprite> Sprite::Create(const std::string& base_url, float pixelRatio, const util::ptr<FileSource> &fileSource) { + util::ptr<Sprite> sprite(std::make_shared<Sprite>(Key(), base_url, pixelRatio)); sprite->load(fileSource); return sprite; } @@ -51,7 +51,7 @@ Sprite::operator bool() const { // Note: This is a separate function that must be called exactly once after creation // The reason this isn't part of the constructor is that calling shared_from_this() in // the constructor fails. -void Sprite::load(const std::shared_ptr<FileSource> &fileSource) { +void Sprite::load(const util::ptr<FileSource> &fileSource) { if (!valid) { // Treat a non-existent sprite as a successfully loaded empty sprite. loadedImage = true; @@ -60,7 +60,7 @@ void Sprite::load(const std::shared_ptr<FileSource> &fileSource) { return; } - std::shared_ptr<Sprite> sprite = shared_from_this(); + util::ptr<Sprite> sprite = shared_from_this(); fileSource->request(ResourceType::JSON, jsonURL)->onload([sprite](const Response &res) { if (res.code == 200) { diff --git a/src/map/tile_data.cpp b/src/map/tile_data.cpp index 6c2869dfe8..2a0e96cad6 100644 --- a/src/map/tile_data.cpp +++ b/src/map/tile_data.cpp @@ -47,7 +47,7 @@ void TileData::request() { std::weak_ptr<TileData> weak_tile = shared_from_this(); req = map.getFileSource()->request(ResourceType::Tile, url); req->onload([weak_tile, url](const Response &res) { - std::shared_ptr<TileData> tile = weak_tile.lock(); + util::ptr<TileData> tile = weak_tile.lock(); if (!tile || tile->state == State::obsolete) { // noop. Tile is obsolete and we're now just waiting for the refcount // to drop to zero for destruction. @@ -86,12 +86,12 @@ void TileData::reparse() { // We're creating a new work request. The work request deletes itself after it executed // the after work handler - new uv::work<std::shared_ptr<TileData>>( + new uv::work<util::ptr<TileData>>( map.getLoop(), - [](std::shared_ptr<TileData> &tile) { + [](util::ptr<TileData> &tile) { tile->parse(); }, - [](std::shared_ptr<TileData> &tile) { + [](util::ptr<TileData> &tile) { tile->afterParse(); tile->map.update(); }, diff --git a/src/map/tile_parser.cpp b/src/map/tile_parser.cpp index 8fbcfa45d7..4a92dd5e14 100644 --- a/src/map/tile_parser.cpp +++ b/src/map/tile_parser.cpp @@ -38,11 +38,11 @@ namespace mbgl { TileParser::~TileParser() = default; TileParser::TileParser(const std::string &data, VectorTileData &tile, - const std::shared_ptr<const Style> &style_, - const std::shared_ptr<GlyphAtlas> &glyphAtlas_, - const std::shared_ptr<GlyphStore> &glyphStore_, - const std::shared_ptr<SpriteAtlas> &spriteAtlas_, - const std::shared_ptr<Sprite> &sprite_) + const util::ptr<const Style> &style_, + const util::ptr<GlyphAtlas> &glyphAtlas_, + const util::ptr<GlyphStore> &glyphStore_, + const util::ptr<SpriteAtlas> &spriteAtlas_, + const util::ptr<Sprite> &sprite_) : vector_data(pbf((const uint8_t *)data.data(), data.size())), tile(tile), style(style_), @@ -66,12 +66,12 @@ void TileParser::parse() { bool TileParser::obsolete() const { return tile.state == TileData::State::obsolete; } -void TileParser::parseStyleLayers(std::shared_ptr<StyleLayerGroup> group) { +void TileParser::parseStyleLayers(util::ptr<StyleLayerGroup> group) { if (!group) { return; } - for (const std::shared_ptr<StyleLayer> &layer_desc : group->layers) { + for (const util::ptr<StyleLayer> &layer_desc : group->layers) { // Cancel early when parsing. if (obsolete()) { return; @@ -103,7 +103,7 @@ void TileParser::parseStyleLayers(std::shared_ptr<StyleLayerGroup> group) { } } -std::unique_ptr<Bucket> TileParser::createBucket(std::shared_ptr<StyleBucket> bucket_desc) { +std::unique_ptr<Bucket> TileParser::createBucket(util::ptr<StyleBucket> bucket_desc) { if (!bucket_desc) { fprintf(stderr, "missing bucket desc\n"); return nullptr; @@ -164,7 +164,7 @@ std::unique_ptr<Bucket> TileParser::createFillBucket(const VectorTileLayer& laye return obsolete() ? nullptr : std::move(bucket); } -std::unique_ptr<Bucket> TileParser::createRasterBucket(const std::shared_ptr<Texturepool> &texturepool, const StyleBucketRaster &raster) { +std::unique_ptr<Bucket> TileParser::createRasterBucket(const util::ptr<Texturepool> &texturepool, const StyleBucketRaster &raster) { std::unique_ptr<RasterBucket> bucket = std::make_unique<RasterBucket>(texturepool, raster); return obsolete() ? nullptr : std::move(bucket); } diff --git a/src/map/transform.cpp b/src/map/transform.cpp index 6c5e70cc2f..baa615b94a 100644 --- a/src/map/transform.cpp +++ b/src/map/transform.cpp @@ -466,7 +466,7 @@ bool Transform::needsTransition() const { void Transform::updateTransitions(const timestamp now) { uv::writelock lock(mtx); - transitions.remove_if([now](const std::shared_ptr<util::transition> &transition) { + transitions.remove_if([now](const util::ptr<util::transition> &transition) { return transition->update(now) == util::transition::complete; }); } diff --git a/src/map/vector_tile_data.cpp b/src/map/vector_tile_data.cpp index 5181cbb2ce..4ad8fa869d 100644 --- a/src/map/vector_tile_data.cpp +++ b/src/map/vector_tile_data.cpp @@ -14,7 +14,7 @@ VectorTileData::VectorTileData(Tile::ID id, Map &map, const SourceInfo &source) } VectorTileData::~VectorTileData() { - std::shared_ptr<GlyphAtlas> glyphAtlas = map.getGlyphAtlas(); + util::ptr<GlyphAtlas> glyphAtlas = map.getGlyphAtlas(); if (glyphAtlas) { glyphAtlas->removeGlyphs(id.to_uint64()); } @@ -52,7 +52,7 @@ void VectorTileData::afterParse() { parser.reset(); } -void VectorTileData::render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const mat4 &matrix) { +void VectorTileData::render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix) { if (state == State::parsed && layer_desc->bucket) { auto databucket_it = buckets.find(layer_desc->bucket->name); if (databucket_it != buckets.end()) { @@ -62,7 +62,7 @@ void VectorTileData::render(Painter &painter, std::shared_ptr<StyleLayer> layer_ } } -bool VectorTileData::hasData(std::shared_ptr<StyleLayer> layer_desc) const { +bool VectorTileData::hasData(util::ptr<StyleLayer> layer_desc) const { if (state == State::parsed && layer_desc->bucket) { auto databucket_it = buckets.find(layer_desc->bucket->name); if (databucket_it != buckets.end()) { diff --git a/src/renderer/debug_bucket.cpp b/src/renderer/debug_bucket.cpp index a3ac329f49..699c1c1db9 100644 --- a/src/renderer/debug_bucket.cpp +++ b/src/renderer/debug_bucket.cpp @@ -14,7 +14,7 @@ DebugBucket::DebugBucket(DebugFontBuffer& fontBuffer) : fontBuffer(fontBuffer) { } -void DebugBucket::render(Painter& painter, std::shared_ptr<StyleLayer> /*layer_desc*/, const Tile::ID& /*id*/, const mat4 &matrix) { +void DebugBucket::render(Painter& painter, util::ptr<StyleLayer> /*layer_desc*/, const Tile::ID& /*id*/, const mat4 &matrix) { painter.renderDebugText(*this, matrix); } diff --git a/src/renderer/fill_bucket.cpp b/src/renderer/fill_bucket.cpp index 875cc279b9..5358cae0b2 100644 --- a/src/renderer/fill_bucket.cpp +++ b/src/renderer/fill_bucket.cpp @@ -204,7 +204,7 @@ void FillBucket::tessellate() { lineGroup.vertex_length += total_vertex_count; } -void FillBucket::render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) { +void FillBucket::render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) { painter.renderFill(*this, layer_desc, id, matrix); } diff --git a/src/renderer/line_bucket.cpp b/src/renderer/line_bucket.cpp index 2e89a7c35d..3ef7411be6 100644 --- a/src/renderer/line_bucket.cpp +++ b/src/renderer/line_bucket.cpp @@ -341,7 +341,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) { } } -void LineBucket::render(Painter& painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) { +void LineBucket::render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) { painter.renderLine(*this, layer_desc, id, matrix); } diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index c1705cd7cf..9643fb1561 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -177,7 +177,7 @@ void Painter::prepareTile(const Tile& tile) { glStencilFunc(GL_EQUAL, ref, mask); } -void Painter::renderTileLayer(const Tile& tile, std::shared_ptr<StyleLayer> layer_desc, const mat4 &matrix) { +void Painter::renderTileLayer(const Tile& tile, util::ptr<StyleLayer> layer_desc, const mat4 &matrix) { assert(tile.data); if (tile.data->hasData(layer_desc) || layer_desc->type == StyleLayerType::Raster) { gl::group group(util::sprintf<32>("render %d/%d/%d\n", tile.id.z, tile.id.y, tile.id.z)); @@ -186,7 +186,7 @@ void Painter::renderTileLayer(const Tile& tile, std::shared_ptr<StyleLayer> laye } } -void Painter::renderBackground(std::shared_ptr<StyleLayer> layer_desc) { +void Painter::renderBackground(util::ptr<StyleLayer> layer_desc) { const BackgroundProperties& properties = layer_desc->getProperties<BackgroundProperties>(); Color color = properties.color; diff --git a/src/renderer/painter_clipping.cpp b/src/renderer/painter_clipping.cpp index 45b14a2f78..dc625ded4e 100644 --- a/src/renderer/painter_clipping.cpp +++ b/src/renderer/painter_clipping.cpp @@ -6,7 +6,7 @@ using namespace mbgl; -void Painter::drawClippingMasks(const std::set<std::shared_ptr<StyleSource>> &sources) { +void Painter::drawClippingMasks(const std::set<util::ptr<StyleSource>> &sources) { gl::group group("clipping masks"); useProgram(plainShader->program); @@ -17,7 +17,7 @@ void Painter::drawClippingMasks(const std::set<std::shared_ptr<StyleSource>> &so coveringPlainArray.bind(*plainShader, tileStencilBuffer, BUFFER_OFFSET(0)); - for (const std::shared_ptr<StyleSource> &source : sources) { + for (const util::ptr<StyleSource> &source : sources) { source->source->drawClippingMasks(*this); } diff --git a/src/renderer/painter_fill.cpp b/src/renderer/painter_fill.cpp index 6d56b9077e..6c17ab037a 100644 --- a/src/renderer/painter_fill.cpp +++ b/src/renderer/painter_fill.cpp @@ -10,7 +10,7 @@ using namespace mbgl; -void Painter::renderFill(FillBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) { +void Painter::renderFill(FillBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) { // Abort early. if (!bucket.hasData()) return; diff --git a/src/renderer/painter_line.cpp b/src/renderer/painter_line.cpp index 161abcd6ff..cd973b46d6 100644 --- a/src/renderer/painter_line.cpp +++ b/src/renderer/painter_line.cpp @@ -8,7 +8,7 @@ using namespace mbgl; -void Painter::renderLine(LineBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) { +void Painter::renderLine(LineBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) { // Abort early. if (pass == RenderPass::Opaque) return; if (!bucket.hasData()) return; @@ -62,7 +62,7 @@ void Painter::renderLine(LineBucket& bucket, std::shared_ptr<StyleLayer> layer_d bucket.drawPoints(*linejoinShader); } - const std::shared_ptr<Sprite> &sprite = map.getSprite(); + const util::ptr<Sprite> &sprite = map.getSprite(); if (properties.image.size() && sprite) { SpriteAtlasPosition imagePos = map.getSpriteAtlas()->getPosition(properties.image, *sprite); diff --git a/src/renderer/painter_raster.cpp b/src/renderer/painter_raster.cpp index 7f7afc3e84..c362042e55 100644 --- a/src/renderer/painter_raster.cpp +++ b/src/renderer/painter_raster.cpp @@ -9,7 +9,7 @@ using namespace mbgl; -void Painter::renderRaster(RasterBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) { +void Painter::renderRaster(RasterBucket& bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix) { if (pass != RenderPass::Translucent) return; const RasterProperties &properties = layer_desc->getProperties<RasterProperties>(); @@ -34,7 +34,7 @@ void Painter::renderRaster(RasterBucket& bucket, std::shared_ptr<StyleLayer> lay // call updateTiles to get parsed data for sublayers map.updateTiles(); - for (const std::shared_ptr<StyleLayer> &layer : layer_desc->layers->layers) { + for (const util::ptr<StyleLayer> &layer : layer_desc->layers->layers) { setOpaque(); map.renderLayer(layer, RenderPass::Opaque, &id, &preMatrix); setTranslucent(); diff --git a/src/renderer/painter_symbol.cpp b/src/renderer/painter_symbol.cpp index 4fce66217f..415dead70e 100644 --- a/src/renderer/painter_symbol.cpp +++ b/src/renderer/painter_symbol.cpp @@ -112,7 +112,7 @@ void Painter::renderSDF(SymbolBucket &bucket, } } -void Painter::renderSymbol(SymbolBucket &bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix) { +void Painter::renderSymbol(SymbolBucket &bucket, util::ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix) { // Abort early. if (pass == RenderPass::Opaque) { return; diff --git a/src/renderer/raster_bucket.cpp b/src/renderer/raster_bucket.cpp index 492eea980d..fc5e3dd3c8 100644 --- a/src/renderer/raster_bucket.cpp +++ b/src/renderer/raster_bucket.cpp @@ -3,13 +3,13 @@ using namespace mbgl; -RasterBucket::RasterBucket(const std::shared_ptr<Texturepool> &texturepool, const StyleBucketRaster& properties) +RasterBucket::RasterBucket(const util::ptr<Texturepool> &texturepool, const StyleBucketRaster& properties) : properties(properties), texture(properties), raster(texturepool) { } -void RasterBucket::render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix) { +void RasterBucket::render(Painter &painter, util::ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix) { painter.renderRaster(*this, layer_desc, id, matrix); } diff --git a/src/renderer/symbol_bucket.cpp b/src/renderer/symbol_bucket.cpp index 374ea2dc26..3a4b017ef3 100644 --- a/src/renderer/symbol_bucket.cpp +++ b/src/renderer/symbol_bucket.cpp @@ -22,7 +22,7 @@ namespace mbgl { SymbolBucket::SymbolBucket(const StyleBucketSymbol &properties, Collision &collision) : properties(properties), collision(collision) {} -void SymbolBucket::render(Painter &painter, std::shared_ptr<StyleLayer> layer_desc, +void SymbolBucket::render(Painter &painter, util::ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix) { painter.renderSymbol(*this, layer_desc, id, matrix); } diff --git a/src/storage/base_request.cpp b/src/storage/base_request.cpp index 76d7fe648d..9698da73ac 100644 --- a/src/storage/base_request.cpp +++ b/src/storage/base_request.cpp @@ -20,7 +20,7 @@ void BaseRequest::notify() { // The parameter exists solely so that any calls to ->remove() // are not going to cause deallocation of this object while this call is in progress. - std::shared_ptr<BaseRequest> retain = self; + util::ptr<BaseRequest> retain = self; // Swap the lists so that it's safe for callbacks to call ->cancel() // on the request object, which would modify the list. @@ -40,7 +40,7 @@ void BaseRequest::notify() { self.reset(); } -Callback *BaseRequest::add(Callback &&callback, const std::shared_ptr<BaseRequest> &request) { +Callback *BaseRequest::add(Callback &&callback, const util::ptr<BaseRequest> &request) { assert(thread_id == uv_thread_self()); assert(this == request.get()); if (response) { diff --git a/src/storage/file_source.cpp b/src/storage/file_source.cpp index 43c51def7b..1f8b0dd8e2 100644 --- a/src/storage/file_source.cpp +++ b/src/storage/file_source.cpp @@ -10,7 +10,7 @@ namespace mbgl { FileSource::FileSource(uv_loop_t *loop_) : thread_id(uv_thread_self()), - store(std::shared_ptr<SQLiteStore>(new SQLiteStore(loop_, "cache.db"))), + store(util::ptr<SQLiteStore>(new SQLiteStore(loop_, "cache.db"))), loop(loop_), queue(new uv_messenger_t) { @@ -51,7 +51,7 @@ std::unique_ptr<Request> FileSource::request(ResourceType type, const std::strin } }(); - std::shared_ptr<BaseRequest> request; + util::ptr<BaseRequest> request; // First, try to find an existing Request object. auto it = pending.find(absoluteURL); diff --git a/src/storage/http_request.cpp b/src/storage/http_request.cpp index 966356a614..3d456a836d 100644 --- a/src/storage/http_request.cpp +++ b/src/storage/http_request.cpp @@ -21,7 +21,7 @@ struct CacheRequestBaton { uv_loop_t *loop; }; -HTTPRequest::HTTPRequest(ResourceType type_, const std::string &path, uv_loop_t *loop, std::shared_ptr<SQLiteStore> store_) +HTTPRequest::HTTPRequest(ResourceType type_, const std::string &path, uv_loop_t *loop, util::ptr<SQLiteStore> store_) : BaseRequest(path), thread_id(uv_thread_self()), store(store_), type(type_) { cache_baton = new CacheRequestBaton; cache_baton->request = this; diff --git a/src/storage/request.cpp b/src/storage/request.cpp index 98e3f01237..65d1d7eb35 100644 --- a/src/storage/request.cpp +++ b/src/storage/request.cpp @@ -7,7 +7,7 @@ namespace mbgl { -Request::Request(const std::shared_ptr<BaseRequest> &base_) +Request::Request(const util::ptr<BaseRequest> &base_) : thread_id(uv_thread_self()), base(base_) { } diff --git a/src/storage/sqlite_store.cpp b/src/storage/sqlite_store.cpp index 51e5aa1d21..baa599eef9 100644 --- a/src/storage/sqlite_store.cpp +++ b/src/storage/sqlite_store.cpp @@ -62,7 +62,7 @@ void SQLiteStore::createSchema() { } struct GetBaton { - std::shared_ptr<Database> db; + util::ptr<Database> db; std::string path; ResourceType type; void *ptr = nullptr; @@ -120,7 +120,7 @@ void SQLiteStore::get(const std::string &path, GetCallback callback, void *ptr) struct PutBaton { - std::shared_ptr<Database> db; + util::ptr<Database> db; std::string path; ResourceType type; Response response; @@ -164,7 +164,7 @@ void SQLiteStore::put(const std::string &path, ResourceType type, const Response } struct ExpirationBaton { - std::shared_ptr<Database> db; + util::ptr<Database> db; std::string path; int64_t expires; }; diff --git a/src/style/style_layer_group.cpp b/src/style/style_layer_group.cpp index c7e4360d21..a731aebdcb 100644 --- a/src/style/style_layer_group.cpp +++ b/src/style/style_layer_group.cpp @@ -5,7 +5,7 @@ namespace mbgl { void StyleLayerGroup::setClasses(const std::vector<std::string> &class_names, timestamp now, const PropertyTransition &defaultTransition) { - for (const std::shared_ptr<StyleLayer> &layer : layers) { + for (const util::ptr<StyleLayer> &layer : layers) { if (layer) { layer->setClasses(class_names, now, defaultTransition); } @@ -13,7 +13,7 @@ void StyleLayerGroup::setClasses(const std::vector<std::string> &class_names, ti } void StyleLayerGroup::updateProperties(float z, timestamp t) { - for (const std::shared_ptr<StyleLayer> &layer: layers) { + for (const util::ptr<StyleLayer> &layer: layers) { if (layer) { layer->updateProperties(z, t); } @@ -21,7 +21,7 @@ void StyleLayerGroup::updateProperties(float z, timestamp t) { } bool StyleLayerGroup::hasTransitions() const { - for (const std::shared_ptr<const StyleLayer> &layer: layers) { + for (const util::ptr<const StyleLayer> &layer: layers) { if (layer) { if (layer->hasTransitions()) { return true; diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp index 7e695e71cb..3eed161510 100644 --- a/src/style/style_parser.cpp +++ b/src/style/style_parser.cpp @@ -451,7 +451,7 @@ std::unique_ptr<StyleLayerGroup> StyleParser::createLayers(JSVal value) { if (value.IsArray()) { std::unique_ptr<StyleLayerGroup> group = std::make_unique<StyleLayerGroup>(); for (rapidjson::SizeType i = 0; i < value.Size(); ++i) { - std::shared_ptr<StyleLayer> layer = createLayer(value[i]); + util::ptr<StyleLayer> layer = createLayer(value[i]); if (layer) { group->layers.emplace_back(layer); } @@ -463,7 +463,7 @@ std::unique_ptr<StyleLayerGroup> StyleParser::createLayers(JSVal value) { } } -std::shared_ptr<StyleLayer> StyleParser::createLayer(JSVal value) { +util::ptr<StyleLayer> StyleParser::createLayer(JSVal value) { if (value.IsObject()) { if (!value.HasMember("id")) { Log::Warning(Event::ParseStyle, "layer must have an id"); @@ -487,7 +487,7 @@ std::shared_ptr<StyleLayer> StyleParser::createLayer(JSVal value) { std::map<ClassID, ClassProperties> styles; parseStyles(value, styles); - std::shared_ptr<StyleLayer> layer = std::make_shared<StyleLayer>( + util::ptr<StyleLayer> layer = std::make_shared<StyleLayer>( layer_id, std::move(styles)); if (value.HasMember("layers")) { @@ -495,7 +495,7 @@ std::shared_ptr<StyleLayer> StyleParser::createLayer(JSVal value) { } // Store the layer ID so we can reference it later. - layers.emplace(layer_id, std::pair<JSVal, std::shared_ptr<StyleLayer>> { value, layer }); + layers.emplace(layer_id, std::pair<JSVal, util::ptr<StyleLayer>> { value, layer }); return layer; } else { @@ -505,14 +505,14 @@ std::shared_ptr<StyleLayer> StyleParser::createLayer(JSVal value) { } void StyleParser::parseLayers() { - for (std::pair<const std::string, std::pair<JSVal, std::shared_ptr<StyleLayer>>> &pair : layers) { + for (std::pair<const std::string, std::pair<JSVal, util::ptr<StyleLayer>>> &pair : layers) { parseLayer(pair.second); } } -void StyleParser::parseLayer(std::pair<JSVal, std::shared_ptr<StyleLayer>> &pair) { +void StyleParser::parseLayer(std::pair<JSVal, util::ptr<StyleLayer>> &pair) { JSVal value = pair.first; - std::shared_ptr<StyleLayer> &layer = pair.second; + util::ptr<StyleLayer> &layer = pair.second; if (value.HasMember("type")) { JSVal type = value["type"]; @@ -642,7 +642,7 @@ void StyleParser::parseStyle(JSVal value, ClassProperties &klass) { parseOptionalProperty<Function<Color>>("background-color", Key::BackgroundColor, klass, value); } -void StyleParser::parseReference(JSVal value, std::shared_ptr<StyleLayer> &layer) { +void StyleParser::parseReference(JSVal value, util::ptr<StyleLayer> &layer) { if (!value.IsString()) { Log::Warning(Event::ParseStyle, "layer ref of '%s' must be a string", layer->id.c_str()); return; @@ -661,7 +661,7 @@ void StyleParser::parseReference(JSVal value, std::shared_ptr<StyleLayer> &layer stack.pop_front(); - std::shared_ptr<StyleLayer> reference = it->second.second; + util::ptr<StyleLayer> reference = it->second.second; layer->type = reference->type; @@ -676,7 +676,7 @@ void StyleParser::parseReference(JSVal value, std::shared_ptr<StyleLayer> &layer #pragma mark - Parse Bucket -void StyleParser::parseBucket(JSVal value, std::shared_ptr<StyleLayer> &layer) { +void StyleParser::parseBucket(JSVal value, util::ptr<StyleLayer> &layer) { layer->bucket = std::make_shared<StyleBucket>(layer->type); // We name the buckets according to the layer that defined it. @@ -822,7 +822,7 @@ std::vector<Value> StyleParser::parseValues(JSVal value) { return values; } -void StyleParser::parseRender(JSVal value, std::shared_ptr<StyleLayer> &layer) { +void StyleParser::parseRender(JSVal value, util::ptr<StyleLayer> &layer) { if (!value.IsObject()) { Log::Warning(Event::ParseStyle, "render property of layer '%s' must be an object", layer->id.c_str()); return; diff --git a/src/text/glyph_store.cpp b/src/text/glyph_store.cpp index 0ad6139ac9..ecf78a17dc 100644 --- a/src/text/glyph_store.cpp +++ b/src/text/glyph_store.cpp @@ -137,7 +137,7 @@ void FontStack::lineWrap(Shaping &shaping, const float lineHeight, const float m align(shaping, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, line); } -GlyphPBF::GlyphPBF(const std::string &glyphURL, const std::string &fontStack, GlyphRange glyphRange, const std::shared_ptr<FileSource> &fileSource) +GlyphPBF::GlyphPBF(const std::string &glyphURL, const std::string &fontStack, GlyphRange glyphRange, const util::ptr<FileSource> &fileSource) : future(promise.get_future().share()) { // Load the glyph set URL @@ -224,7 +224,7 @@ void GlyphPBF::parse(FontStack &stack) { data.clear(); } -GlyphStore::GlyphStore(const std::shared_ptr<FileSource> &fileSource) : fileSource(fileSource) {} +GlyphStore::GlyphStore(const util::ptr<FileSource> &fileSource) : fileSource(fileSource) {} void GlyphStore::setURL(const std::string &url) { glyphURL = url; diff --git a/src/util/raster.cpp b/src/util/raster.cpp index 9a71573d01..7b52c51037 100644 --- a/src/util/raster.cpp +++ b/src/util/raster.cpp @@ -1,20 +1,19 @@ -#include <mbgl/util/raster.hpp> - -#include <memory> -#include <cassert> -#include <cstring> - #include <mbgl/platform/platform.hpp> #include <mbgl/platform/gl.hpp> + +#include <mbgl/util/raster.hpp> #include <mbgl/util/time.hpp> #include <mbgl/util/uv_detail.hpp> #include <mbgl/util/std.hpp> #include <png.h> +#include <cassert> +#include <cstring> + using namespace mbgl; -Raster::Raster(const std::shared_ptr<Texturepool> &texturepool) +Raster::Raster(const util::ptr<Texturepool> &texturepool) : texturepool(texturepool) {} |