merge with mbgl-config
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <mbgl/geometry/binpack.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/ptr.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
@@ -26,7 +27,6 @@ class SpriteAtlas : public util::noncopyable {
|
||||
public:
|
||||
typedef uint16_t dimension;
|
||||
|
||||
public:
|
||||
// Add way to construct this from another SpriteAtlas (e.g. with another pixelRatio)
|
||||
SpriteAtlas(dimension width, dimension height);
|
||||
~SpriteAtlas();
|
||||
@@ -34,22 +34,16 @@ public:
|
||||
// Changes the pixel ratio.
|
||||
bool resize(float newRatio);
|
||||
|
||||
// Update uninitialized (= outdated) sprites in this atlas from the given sprite.
|
||||
void update(const Sprite &sprite);
|
||||
// Changes the source sprite.
|
||||
void setSprite(util::ptr<Sprite> sprite);
|
||||
|
||||
// Returns the coordinates of an image that is sourced from the sprite image.
|
||||
// This getter attempts to read the image from the sprite if it is already loaded.
|
||||
// In that case, it copies it into the sprite atlas and returns the dimensions.
|
||||
// Otherwise, it returns a 0/0/0/0 rect.
|
||||
Rect<dimension> getImage(const std::string &name, const Sprite &sprite);
|
||||
Rect<dimension> getImage(const std::string& name);
|
||||
|
||||
// Returns the coordinates of an image that is sourced from the sprite image.
|
||||
// This getter waits until the sprite image was loaded, copies it into the sprite
|
||||
// image and returns the dimensions.
|
||||
// NEVER CALL THIS FUNCTION FROM THE RENDER THREAD! it is blocking.
|
||||
Rect<dimension> waitForImage(const std::string &name, const Sprite &sprite);
|
||||
|
||||
SpriteAtlasPosition getPosition(const std::string &name, const Sprite &sprite, bool repeating = false);
|
||||
SpriteAtlasPosition getPosition(const std::string& name, bool repeating = false);
|
||||
|
||||
// Binds the image buffer of this sprite atlas to the GPU, and uploads data if it is out
|
||||
// of date.
|
||||
@@ -61,19 +55,18 @@ public:
|
||||
inline float getTextureHeight() const { return height * pixelRatio; }
|
||||
inline float getPixelRatio() const { return pixelRatio; }
|
||||
|
||||
private:
|
||||
void allocate();
|
||||
Rect<SpriteAtlas::dimension> allocateImage(size_t width, size_t height);
|
||||
void copy(const Rect<dimension> &dst, const SpritePosition &src, const Sprite &sprite);
|
||||
|
||||
public:
|
||||
const dimension width = 0;
|
||||
const dimension height = 0;
|
||||
|
||||
private:
|
||||
std::mutex mtx;
|
||||
void allocate();
|
||||
Rect<SpriteAtlas::dimension> allocateImage(size_t width, size_t height);
|
||||
void copy(const Rect<dimension>& dst, const SpritePosition& src);
|
||||
|
||||
std::recursive_mutex mtx;
|
||||
float pixelRatio = 1.0f;
|
||||
BinPack<dimension> bin;
|
||||
util::ptr<Sprite> sprite;
|
||||
std::map<std::string, Rect<dimension>> images;
|
||||
std::set<std::string> uninitialized;
|
||||
uint32_t *data = nullptr;
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
|
||||
#include <mbgl/map/transform.hpp>
|
||||
#include <mbgl/renderer/painter.hpp>
|
||||
|
||||
#include <mbgl/geometry/glyph_atlas.hpp>
|
||||
#include <mbgl/geometry/sprite_atlas.hpp>
|
||||
#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>
|
||||
@@ -17,10 +17,8 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class GlyphAtlas;
|
||||
class GlyphStore;
|
||||
class LayerDescription;
|
||||
class SpriteAtlas;
|
||||
class Sprite;
|
||||
class Style;
|
||||
class StyleLayer;
|
||||
@@ -55,8 +53,6 @@ public:
|
||||
// Triggers a lazy rerender: only performs a render when the map is not clean.
|
||||
void rerender();
|
||||
|
||||
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();
|
||||
|
||||
@@ -133,12 +129,11 @@ public:
|
||||
inline const TransformState &getState() const { return state; }
|
||||
inline util::ptr<FileSource> getFileSource() const { return fileSource; }
|
||||
inline util::ptr<Style> getStyle() const { return style; }
|
||||
inline util::ptr<GlyphAtlas> getGlyphAtlas() { return glyphAtlas; }
|
||||
inline GlyphAtlas & getGlyphAtlas() { return glyphAtlas; }
|
||||
inline util::ptr<GlyphStore> getGlyphStore() { return glyphStore; }
|
||||
inline util::ptr<SpriteAtlas> getSpriteAtlas() { return spriteAtlas; }
|
||||
inline SpriteAtlas & getSpriteAtlas() { return spriteAtlas; }
|
||||
util::ptr<Sprite> getSprite();
|
||||
inline util::ptr<Texturepool> getTexturepool() { return texturepool; }
|
||||
inline util::ptr<uv::loop> getLoop() { return loop; }
|
||||
uv::worker &getWorker();
|
||||
inline timestamp getAnimationTime() const { return animationTime; }
|
||||
inline timestamp getTime() const { return animationTime; }
|
||||
@@ -156,22 +151,18 @@ private:
|
||||
void updateSources();
|
||||
void updateSources(const util::ptr<StyleLayerGroup> &group);
|
||||
|
||||
void updateRenderState();
|
||||
|
||||
size_t countLayers(const std::vector<LayerDescription>& layers);
|
||||
|
||||
// Prepares a map render by updating the tiles we need for the current view, as well as updating
|
||||
// the stylesheet.
|
||||
void prepare();
|
||||
|
||||
|
||||
// Unconditionally performs a render with the current map state.
|
||||
void render();
|
||||
void renderLayers(util::ptr<StyleLayerGroup> group);
|
||||
|
||||
private:
|
||||
bool async = false;
|
||||
util::ptr<uv::loop> loop;
|
||||
std::unique_ptr<uv::loop> loop;
|
||||
std::unique_ptr<uv::worker> workers;
|
||||
std::unique_ptr<uv::thread> thread;
|
||||
std::unique_ptr<uv_async_t> async_terminate;
|
||||
@@ -209,9 +200,9 @@ private:
|
||||
util::ptr<FileSource> fileSource;
|
||||
|
||||
util::ptr<Style> style;
|
||||
util::ptr<GlyphAtlas> glyphAtlas;
|
||||
GlyphAtlas glyphAtlas;
|
||||
util::ptr<GlyphStore> glyphStore;
|
||||
util::ptr<SpriteAtlas> spriteAtlas;
|
||||
SpriteAtlas spriteAtlas;
|
||||
util::ptr<Sprite> sprite;
|
||||
util::ptr<Texturepool> texturepool;
|
||||
|
||||
@@ -224,8 +215,6 @@ private:
|
||||
bool debug = false;
|
||||
timestamp animationTime = 0;
|
||||
|
||||
int indent = 0;
|
||||
|
||||
std::set<util::ptr<StyleSource>> activeSources;
|
||||
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
virtual void parse();
|
||||
virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix);
|
||||
virtual bool hasData(util::ptr<StyleLayer> layer_desc) const;
|
||||
virtual bool hasData(StyleLayer const& layer_desc) const;
|
||||
|
||||
protected:
|
||||
StyleBucketRaster properties;
|
||||
|
||||
@@ -53,11 +53,9 @@ public:
|
||||
}
|
||||
|
||||
// Override this in the child class.
|
||||
virtual void beforeParse();
|
||||
virtual void parse() = 0;
|
||||
virtual void afterParse();
|
||||
virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix) = 0;
|
||||
virtual bool hasData(util::ptr<StyleLayer> layer_desc) const = 0;
|
||||
virtual bool hasData(StyleLayer const& layer_desc) const = 0;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <mbgl/style/filter_expression.hpp>
|
||||
#include <mbgl/text/glyph.hpp>
|
||||
#include <mbgl/util/ptr.hpp>
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <cstdint>
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
@@ -29,13 +29,14 @@ class StyleLayerGroup;
|
||||
class VectorTileData;
|
||||
class Collision;
|
||||
|
||||
class TileParser {
|
||||
class TileParser : private util::noncopyable
|
||||
{
|
||||
public:
|
||||
TileParser(const std::string &data, VectorTileData &tile,
|
||||
const util::ptr<const Style> &style,
|
||||
const util::ptr<GlyphAtlas> &glyphAtlas,
|
||||
GlyphAtlas & glyphAtlas,
|
||||
const util::ptr<GlyphStore> &glyphStore,
|
||||
const util::ptr<SpriteAtlas> &spriteAtlas,
|
||||
SpriteAtlas & spriteAtlas,
|
||||
const util::ptr<Sprite> &sprite);
|
||||
~TileParser();
|
||||
|
||||
@@ -60,9 +61,9 @@ private:
|
||||
|
||||
// Cross-thread shared data.
|
||||
util::ptr<const Style> style;
|
||||
util::ptr<GlyphAtlas> glyphAtlas;
|
||||
GlyphAtlas & glyphAtlas;
|
||||
util::ptr<GlyphStore> glyphStore;
|
||||
util::ptr<SpriteAtlas> spriteAtlas;
|
||||
SpriteAtlas & spriteAtlas;
|
||||
util::ptr<Sprite> sprite;
|
||||
util::ptr<Texturepool> texturePool;
|
||||
|
||||
|
||||
@@ -3,14 +3,12 @@
|
||||
|
||||
#include <mbgl/util/time.hpp>
|
||||
#include <mbgl/map/transform_state.hpp>
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/uv.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cmath>
|
||||
#include <forward_list>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -80,7 +78,7 @@ private:
|
||||
private:
|
||||
View &view;
|
||||
|
||||
std::unique_ptr<uv::rwlock> mtx;
|
||||
mutable std::recursive_mutex mtx;
|
||||
|
||||
// This reflects the current state of the transform, representing the actual position of the
|
||||
// map. After calling a transform function with a timer, this will likely remain the same until
|
||||
@@ -91,7 +89,6 @@ private:
|
||||
TransformState final;
|
||||
|
||||
// Limit the amount of zooming possible on the map.
|
||||
// TODO: make these modifiable from outside.
|
||||
const double min_scale = std::pow(2, 0);
|
||||
const double max_scale = std::pow(2, 18);
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
float lngX(float lon) const;
|
||||
float latY(float lat) const;
|
||||
std::array<float, 2> locationCoordinate(float lon, float lat) const;
|
||||
void getLonLat(double &lon, double &lat) const;
|
||||
|
||||
// Zoom
|
||||
float getNormalizedZoom() const;
|
||||
@@ -69,7 +70,7 @@ private:
|
||||
// map position
|
||||
double x = 0, y = 0;
|
||||
double angle = 0;
|
||||
double scale = std::numeric_limits<double>::infinity();
|
||||
double scale = 1;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -28,12 +28,9 @@ class VectorTileData : public TileData {
|
||||
public:
|
||||
VectorTileData(Tile::ID id, Map &map, const util::ptr<SourceInfo> &source);
|
||||
~VectorTileData();
|
||||
|
||||
virtual void beforeParse();
|
||||
virtual void parse();
|
||||
virtual void afterParse();
|
||||
virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix);
|
||||
virtual bool hasData(util::ptr<StyleLayer> layer_desc) const;
|
||||
virtual bool hasData(StyleLayer const& layer_desc) const;
|
||||
|
||||
protected:
|
||||
// Holds the actual geometries in this tile.
|
||||
@@ -49,9 +46,6 @@ protected:
|
||||
// Holds the buckets of this tile.
|
||||
// They contain the location offsets in the buffers stored above
|
||||
std::unordered_map<std::string, std::unique_ptr<Bucket>> buckets;
|
||||
|
||||
std::unique_ptr<TileParser> parser;
|
||||
|
||||
public:
|
||||
const float depth;
|
||||
};
|
||||
|
||||
@@ -35,9 +35,12 @@ enum class RenderPass : bool { Opaque, Translucent };
|
||||
class Transform;
|
||||
class Style;
|
||||
class Tile;
|
||||
class Sprite;
|
||||
class SpriteAtlas;
|
||||
class GlyphAtlas;
|
||||
class Source;
|
||||
class StyleSource;
|
||||
class StyleLayerGroup;
|
||||
|
||||
class FillBucket;
|
||||
class LineBucket;
|
||||
@@ -53,10 +56,9 @@ class RasterTileData;
|
||||
|
||||
class Painter : private util::noncopyable {
|
||||
public:
|
||||
Painter(Map &map);
|
||||
Painter(SpriteAtlas&, GlyphAtlas&);
|
||||
~Painter();
|
||||
|
||||
|
||||
void setup();
|
||||
|
||||
// Perform cleanup tasks that prepare shutting down the app. This doesn't mean that the
|
||||
@@ -73,6 +75,14 @@ public:
|
||||
// Updates the default matrices to the current viewport dimensions.
|
||||
void changeMatrix();
|
||||
|
||||
void render(const Style& style,
|
||||
const std::set<util::ptr<StyleSource>>& sources,
|
||||
TransformState state,
|
||||
timestamp time);
|
||||
|
||||
void renderLayers(util::ptr<StyleLayerGroup> group);
|
||||
void renderLayer(util::ptr<StyleLayer> layer_desc, const Tile::ID* id = nullptr, const mat4* matrix = nullptr);
|
||||
|
||||
// Renders a particular layer from a tile.
|
||||
void renderTileLayer(const Tile& tile, util::ptr<StyleLayer> layer_desc, const mat4 &matrix);
|
||||
|
||||
@@ -167,9 +177,10 @@ public:
|
||||
}();
|
||||
|
||||
private:
|
||||
Map& map;
|
||||
TransformState state;
|
||||
|
||||
bool debug = false;
|
||||
int indent = 0;
|
||||
|
||||
uint32_t gl_program = 0;
|
||||
float gl_lineWidth = 0;
|
||||
@@ -183,6 +194,9 @@ private:
|
||||
public:
|
||||
FrameHistory frameHistory;
|
||||
|
||||
SpriteAtlas& spriteAtlas;
|
||||
GlyphAtlas& glyphAtlas;
|
||||
|
||||
std::unique_ptr<PlainShader> plainShader;
|
||||
std::unique_ptr<OutlineShader> outlineShader;
|
||||
std::unique_ptr<LineShader> lineShader;
|
||||
|
||||
Reference in New Issue
Block a user