diff --git a/Makefile b/Makefile index 2431f7be7..c4d42bfd4 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ endif PLATFORM ?= linux -all: mbgl +all: mbgl-core mbgl-platform mbgl-headless config.gypi: configure ./configure @@ -18,9 +18,17 @@ config-ios.gypi: configure MASON_PLATFORM=ios ./configure config-ios.gypi # Builds the regular library -mbgl: config.gypi mapboxgl.gyp +mbgl-core: config.gypi mapboxgl.gyp deps/run_gyp mapboxgl.gyp -Iconfig.gypi -Dplatform=$(PLATFORM) --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make - $(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mbgl + $(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mbgl-core + +mbgl-platform: config.gypi mapboxgl.gyp + deps/run_gyp mapboxgl.gyp -Iconfig.gypi -Dplatform=$(PLATFORM) --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make + $(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mbgl-$(PLATFORM) + +mbgl-headless: config.gypi mapboxgl.gyp + deps/run_gyp mapboxgl.gyp -Iconfig.gypi -Dplatform=$(PLATFORM) --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make + $(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mbgl-headless install: config.gypi mapboxgl.gyp deps/run_gyp mapboxgl.gyp -Iconfig.gypi -Dplatform=$(PLATFORM) -Dinstall_prefix=$(PREFIX) --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make @@ -104,10 +112,11 @@ lproj: config.gypi linux/mapboxgl-app.gyp clear_xcode_cache clean: clear_xcode_cache -find ./deps/gyp -name "*.pyc" -exec rm {} \; -rm -rf ./build/ + -rm -rf ./macosx/build/ -rm -rf ./config.gypi ./config-ios.gypi distclean: clean -rm -rf ./mason_packages -.PHONY: mbgl install test linux clear_xcode_cache build/test/Makefile clean distclean +.PHONY: mbgl-core install test linux clear_xcode_cache build/test/Makefile clean distclean # DO NOT DELETE diff --git a/configure b/configure index ef289ac5d..afb94d479 100755 --- a/configure +++ b/configure @@ -69,7 +69,7 @@ PYTHON=`which python || abort 'Cannot find python'` >&2 echo -en "\033[0m"; function quote_flags { - ${PYTHON} -c "import sys, re; print re.split('(? #include +#include #include #include @@ -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); // 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 getImage(const std::string &name, const Sprite &sprite); + Rect 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 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 allocateImage(size_t width, size_t height); - void copy(const Rect &dst, const SpritePosition &src, const Sprite &sprite); - -public: const dimension width = 0; const dimension height = 0; private: - std::mutex mtx; + void allocate(); + Rect allocateImage(size_t width, size_t height); + void copy(const Rect& dst, const SpritePosition& src); + + std::recursive_mutex mtx; float pixelRatio = 1.0f; BinPack bin; + util::ptr sprite; std::map> images; std::set uninitialized; uint32_t *data = nullptr; diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index bc67e5b35..6aa86fcc8 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -3,12 +3,12 @@ #include #include - +#include +#include #include #include #include #include - #include #include #include @@ -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 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 getFileSource() const { return fileSource; } inline util::ptr