From cda418198f17df87962e1797e024714eaceadcd7 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Wed, 13 Sep 2017 11:07:38 -0400 Subject: [core] Clear atlasImage rect for a removed pattern --- include/mbgl/util/image.hpp | 26 ++++++++++++++++++++++++++ mapbox-gl-js | 2 +- platform/node/test/ignores.json | 1 + src/mbgl/renderer/image_manager.cpp | 7 +++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/include/mbgl/util/image.hpp b/include/mbgl/util/image.hpp index cb28f3da8d..4887058f79 100644 --- a/include/mbgl/util/image.hpp +++ b/include/mbgl/util/image.hpp @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -91,6 +92,31 @@ public: operator=(std::move(newImage)); } + // Clears the rect area specified by `pt` and `size` from `dstImage`. + static void clear(Image& dstImg, const Point& pt, const Size& size) { + if (size.isEmpty()) { + return; + } + + if (!dstImg.valid()) { + throw std::invalid_argument("invalid destination for image clear"); + } + + if (size.width > dstImg.size.width || + size.height > dstImg.size.height || + pt.x > dstImg.size.width - size.width || + pt.y > dstImg.size.height - size.height) { + throw std::out_of_range("out of range destination coordinates for image clear"); + } + + uint8_t* dstData = dstImg.data.get(); + + for (uint32_t y = 0; y < size.height; y++) { + const std::size_t dstOffset = (pt.y + y) * dstImg.stride() + pt.x * channels; + std::memset(dstData + dstOffset, 0, size.width * channels); + } + } + // Copy image data within `rect` from `src` to the rectangle of the same size at `pt` // in `dst`. If the specified bounds exceed the bounds of the source or destination, // throw `std::out_of_range`. Must not be used to move data within a single Image. diff --git a/mapbox-gl-js b/mapbox-gl-js index 991ab7d1a1..c346dec5e3 160000 --- a/mapbox-gl-js +++ b/mapbox-gl-js @@ -1 +1 @@ -Subproject commit 991ab7d1a190a5a54e1f8f54e179dd302ecae493 +Subproject commit c346dec5e3b55257820f1377a139579982bc95ff diff --git a/platform/node/test/ignores.json b/platform/node/test/ignores.json index a8f5a1c7b1..a6e43da0b3 100644 --- a/platform/node/test/ignores.json +++ b/platform/node/test/ignores.json @@ -41,6 +41,7 @@ "render-tests/regressions/mapbox-gl-js#3548": "skip - needs issue", "render-tests/regressions/mapbox-gl-js#3682": "https://github.com/mapbox/mapbox-gl-js/issues/3682", "render-tests/regressions/mapbox-gl-native#7357": "https://github.com/mapbox/mapbox-gl-native/issues/7357", + "render-tests/regressions/mapbox-gl-native#9900": "skip - https://github.com/mapbox/mapbox-gl-native/pull/9905", "render-tests/runtime-styling/image-add-sdf": "skip - https://github.com/mapbox/mapbox-gl-native/issues/9847", "render-tests/runtime-styling/paint-property-fill-flat-to-extrude": "skip - https://github.com/mapbox/mapbox-gl-native/issues/6745", "render-tests/runtime-styling/set-style-paint-property-fill-flat-to-extrude": "skip - needs issue", diff --git a/src/mbgl/renderer/image_manager.cpp b/src/mbgl/renderer/image_manager.cpp index 365a2742de..2ef6be0c4f 100644 --- a/src/mbgl/renderer/image_manager.cpp +++ b/src/mbgl/renderer/image_manager.cpp @@ -39,6 +39,13 @@ void ImageManager::removeImage(const std::string& id) { auto it = patterns.find(id); if (it != patterns.end()) { + // Clear pattern from the atlas image. + const uint32_t x = it->second.bin->x; + const uint32_t y = it->second.bin->y; + const uint32_t w = it->second.bin->w; + const uint32_t h = it->second.bin->h; + PremultipliedImage::clear(atlasImage, { x, y }, { w, h }); + shelfPack.unref(*it->second.bin); patterns.erase(it); } -- cgit v1.2.1