diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-10-08 22:37:53 +0300 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-10-10 15:39:34 +0300 |
commit | 71047ab8534462def95537bc15ad7b726df5c1b3 (patch) | |
tree | d6097721fb1dc3be454de82eb373d25d344d7bf6 | |
parent | 76bbc42fa6fedbaef7fc1fdd9412049a62293fd2 (diff) | |
download | qtlocation-mapboxgl-71047ab8534462def95537bc15ad7b726df5c1b3.tar.gz |
[core] Disallow coalesced requests for patterns
Unlike icons, pattern changes are not caught with
style-diff meaning that the existing request could
be from the previous style and we cannot coalesce
requests for them.
-rw-r--r-- | src/mbgl/renderer/image_manager.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/mbgl/renderer/image_manager.cpp b/src/mbgl/renderer/image_manager.cpp index a776672edd..65defc54c8 100644 --- a/src/mbgl/renderer/image_manager.cpp +++ b/src/mbgl/renderer/image_manager.cpp @@ -170,20 +170,21 @@ void ImageManager::reduceMemoryUseIfCacheSizeExceedsLimit() { } void ImageManager::checkMissingAndNotify(ImageRequestor& requestor, const ImageRequestPair& pair) { - std::vector<std::string> missingImages; - missingImages.reserve(pair.first.size()); + ImageDependencies missingDependencies; + for (const auto& dependency : pair.first) { if (images.find(dependency.first) == images.end()) { - missingImages.push_back(dependency.first); + missingDependencies.emplace(dependency); } } - if (!missingImages.empty()) { + if (!missingDependencies.empty()) { ImageRequestor* requestorPtr = &requestor; assert(!missingImageRequestors.count(requestorPtr)); missingImageRequestors.emplace(requestorPtr, pair); - for (const auto& missingImage : missingImages) { + for (const auto& dependency : missingDependencies) { + const std::string& missingImage = dependency.first; assert(observer != nullptr); auto existingRequestorsIt = requestedImages.find(missingImage); @@ -191,8 +192,15 @@ void ImageManager::checkMissingAndNotify(ImageRequestor& requestor, const ImageR if (!existingRequestorsIt->second.empty()) { // Still waiting for the client response. existingRequestorsIt->second.emplace(requestorPtr); requestor.addPendingRequest(missingImage); + continue; + } + // Unlike icons, pattern changes are not caught + // with style-diff meaning that the existing request + // could be from the previous style and we cannot + // coalesce requests for them. + if (dependency.second != ImageType::Pattern) { + continue; } - continue; } requestedImages[missingImage].emplace(requestorPtr); requestor.addPendingRequest(missingImage); |