diff options
author | Ansis Brammanis <ansis.brammanis@gmail.com> | 2019-04-02 12:57:45 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-02 12:57:45 -0400 |
commit | 2455275bf47e1671a92eb2c1296c6b48f11f6b2e (patch) | |
tree | ad027661edc899feae56ad8b50ebd208f7a36d12 /src/mbgl/tile | |
parent | 805b1402452da74042b995d693c48ee4b79ae337 (diff) | |
download | qtlocation-mapboxgl-2455275bf47e1671a92eb2c1296c6b48f11f6b2e.tar.gz |
add onStyleImageMissing to allow dynamically loaded or generated images (#14253)
Also make `Style#updateImage(...)` much faster when the image doesn't change size. This can be useful for asynchronously generating images.
Diffstat (limited to 'src/mbgl/tile')
-rw-r--r-- | src/mbgl/tile/geometry_tile.cpp | 8 | ||||
-rw-r--r-- | src/mbgl/tile/geometry_tile.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/tile/geometry_tile_worker.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/tile/geometry_tile_worker.hpp | 3 |
4 files changed, 12 insertions, 6 deletions
diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp index d0b55a17d4..9165c03267 100644 --- a/src/mbgl/tile/geometry_tile.cpp +++ b/src/mbgl/tile/geometry_tile.cpp @@ -156,8 +156,8 @@ void GeometryTile::getGlyphs(GlyphDependencies glyphDependencies) { glyphManager.getGlyphs(*this, std::move(glyphDependencies)); } -void GeometryTile::onImagesAvailable(ImageMap images, ImageMap patterns, uint64_t imageCorrelationID) { - worker.self().invoke(&GeometryTileWorker::onImagesAvailable, std::move(images), std::move(patterns), imageCorrelationID); +void GeometryTile::onImagesAvailable(ImageMap images, ImageMap patterns, ImageVersionMap versionMap, uint64_t imageCorrelationID) { + worker.self().invoke(&GeometryTileWorker::onImagesAvailable, std::move(images), std::move(patterns), std::move(versionMap), imageCorrelationID); } void GeometryTile::getImages(ImageRequestPair pair) { @@ -192,6 +192,10 @@ void GeometryTile::upload(gfx::Context& context) { iconAtlasTexture = context.createTexture(iconAtlas.image); iconAtlas.image = {}; } + + if (iconAtlasTexture) { + iconAtlas.patchUpdatedImages(context, *iconAtlasTexture, imageManager); + } } Bucket* GeometryTile::getBucket(const Layer::Impl& layer) const { diff --git a/src/mbgl/tile/geometry_tile.hpp b/src/mbgl/tile/geometry_tile.hpp index b652e7ba5d..53a8910c27 100644 --- a/src/mbgl/tile/geometry_tile.hpp +++ b/src/mbgl/tile/geometry_tile.hpp @@ -37,7 +37,7 @@ public: void setShowCollisionBoxes(const bool showCollisionBoxes) override; void onGlyphsAvailable(GlyphMap) override; - void onImagesAvailable(ImageMap, ImageMap, uint64_t imageCorrelationID) override; + void onImagesAvailable(ImageMap, ImageMap, ImageVersionMap versionMap, uint64_t imageCorrelationID) override; void getGlyphs(GlyphDependencies); void getImages(ImageRequestPair); diff --git a/src/mbgl/tile/geometry_tile_worker.cpp b/src/mbgl/tile/geometry_tile_worker.cpp index 943e782af1..0b703cd68b 100644 --- a/src/mbgl/tile/geometry_tile_worker.cpp +++ b/src/mbgl/tile/geometry_tile_worker.cpp @@ -278,12 +278,13 @@ void GeometryTileWorker::onGlyphsAvailable(GlyphMap newGlyphMap) { symbolDependenciesChanged(); } -void GeometryTileWorker::onImagesAvailable(ImageMap newIconMap, ImageMap newPatternMap, uint64_t imageCorrelationID_) { +void GeometryTileWorker::onImagesAvailable(ImageMap newIconMap, ImageMap newPatternMap, ImageVersionMap newVersionMap, uint64_t imageCorrelationID_) { if (imageCorrelationID != imageCorrelationID_) { return; // Ignore outdated image request replies. } imageMap = std::move(newIconMap); patternMap = std::move(newPatternMap); + versionMap = std::move(newVersionMap); pendingImageDependencies.clear(); symbolDependenciesChanged(); } @@ -441,7 +442,7 @@ void GeometryTileWorker::finalizeLayout() { MBGL_TIMING_START(watch) optional<AlphaImage> glyphAtlasImage; - ImageAtlas iconAtlas = makeImageAtlas(imageMap, patternMap); + ImageAtlas iconAtlas = makeImageAtlas(imageMap, patternMap, versionMap); if (!layouts.empty()) { GlyphAtlas glyphAtlas = makeGlyphAtlas(glyphMap); glyphAtlasImage = std::move(glyphAtlas.image); diff --git a/src/mbgl/tile/geometry_tile_worker.hpp b/src/mbgl/tile/geometry_tile_worker.hpp index 485d1315a6..706bac0154 100644 --- a/src/mbgl/tile/geometry_tile_worker.hpp +++ b/src/mbgl/tile/geometry_tile_worker.hpp @@ -44,7 +44,7 @@ public: void setShowCollisionBoxes(bool showCollisionBoxes_, uint64_t correlationID_); void onGlyphsAvailable(GlyphMap glyphs); - void onImagesAvailable(ImageMap icons, ImageMap patterns, uint64_t imageCorrelationID); + void onImagesAvailable(ImageMap icons, ImageMap patterns, ImageVersionMap versionMap, uint64_t imageCorrelationID); private: void coalesced(); @@ -96,6 +96,7 @@ private: GlyphMap glyphMap; ImageMap imageMap; ImageMap patternMap; + ImageVersionMap versionMap; bool showCollisionBoxes; bool firstLoad = true; |