From ed2ccda0e911b3305bb0f587c00c01bad3bd31d2 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 | 36 +++++++++++++++------- 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, 144 insertions(+), 74 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 61bc79c33..e49e32fc5 100644 --- a/cmake/core-files.cmake +++ b/cmake/core-files.cmake @@ -226,6 +226,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 ed1518fb7..ed36e217b 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 62be4f50c..b2a609895 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -354,7 +354,7 @@ void Map::setStyleURL(const std::string& url) { impl->styleJSON.clear(); impl->styleMutated = false; - impl->style = std::make_unique