use util::ptr as a wrapper around std::shared_ptr that asserts nonemptiness
This commit is contained in:
@@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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() {}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
|
||||
bool hasTransitions() const;
|
||||
public:
|
||||
std::vector<std::shared_ptr<StyleLayer>> layers;
|
||||
std::vector<util::ptr<StyleLayer>> layers;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
29
include/mbgl/util/ptr.hpp
Normal file
29
include/mbgl/util/ptr.hpp
Normal file
@@ -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
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
},
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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_) {
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user