From 59055cf403cab60496fcc8e7cbf06874fa55bb8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Thu, 20 Apr 2017 12:28:35 +0200 Subject: [PATCH] [core] Move Sprite parsing to thread pool --- cmake/core-files.cmake | 2 ++ src/mbgl/annotation/annotation_manager.cpp | 16 ++------- src/mbgl/map/map.cpp | 4 +-- src/mbgl/sprite/sprite_atlas.cpp | 42 ++++++++++++++-------- src/mbgl/sprite/sprite_atlas.hpp | 11 +++++- src/mbgl/sprite/sprite_atlas_worker.cpp | 29 +++++++++++++++ src/mbgl/sprite/sprite_atlas_worker.hpp | 23 ++++++++++++ src/mbgl/sprite/sprite_parser.cpp | 20 ++++------- src/mbgl/sprite/sprite_parser.hpp | 7 +--- src/mbgl/style/style.cpp | 7 ++-- src/mbgl/style/style.hpp | 4 ++- test/sprite/sprite_atlas.test.cpp | 8 +++-- test/sprite/sprite_parser.test.cpp | 24 +++++++------ test/style/source.test.cpp | 2 +- test/style/style.test.cpp | 13 ++++--- test/style/style_layer.test.cpp | 4 ++- test/tile/annotation_tile.test.cpp | 2 +- test/tile/geojson_tile.test.cpp | 2 +- test/tile/raster_tile.test.cpp | 2 +- test/tile/vector_tile.test.cpp | 2 +- 20 files changed, 147 insertions(+), 77 deletions(-) create mode 100644 src/mbgl/sprite/sprite_atlas_worker.cpp create mode 100644 src/mbgl/sprite/sprite_atlas_worker.hpp diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake index 0ea01992d..e8c168df4 100644 --- a/cmake/core-files.cmake +++ b/cmake/core-files.cmake @@ -221,6 +221,8 @@ set(MBGL_CORE_FILES src/mbgl/sprite/sprite_atlas.cpp src/mbgl/sprite/sprite_atlas.hpp src/mbgl/sprite/sprite_atlas_observer.hpp + src/mbgl/sprite/sprite_atlas_worker.cpp + src/mbgl/sprite/sprite_atlas_worker.hpp src/mbgl/sprite/sprite_image.cpp src/mbgl/sprite/sprite_parser.cpp src/mbgl/sprite/sprite_parser.hpp diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp index 537ac7015..f2b2b1837 100644 --- a/src/mbgl/annotation/annotation_manager.cpp +++ b/src/mbgl/annotation/annotation_manager.cpp @@ -21,19 +21,9 @@ const std::string AnnotationManager::PointLayerID = "com.mapbox.annotations.poin AnnotationManager::AnnotationManager(float pixelRatio) : spriteAtlas({ 1024, 1024 }, pixelRatio) { - - struct NullFileSource : public FileSource { - std::unique_ptr request(const Resource&, Callback) override { - assert(false); - return nullptr; - } - }; - - NullFileSource nullFileSource; - - // This is a special atlas, holding only images added via addIcon. But we need its isLoaded() - // method to return true. - spriteAtlas.load("", nullFileSource); + // This is a special atlas, holding only images added via addIcon, so we always treat it as + // loaded. + spriteAtlas.markAsLoaded(); } AnnotationManager::~AnnotationManager() = default; diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index c2844f87f..40be7c374 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -359,7 +359,7 @@ void Map::setStyleURL(const std::string& url) { impl->styleJSON.clear(); impl->styleMutated = false; - impl->style = std::make_unique