summaryrefslogtreecommitdiff
path: root/test/sprite
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-02-13 15:19:44 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-02-14 16:28:12 -0600
commit5524506abd7194456e187532201260b075ea4d93 (patch)
tree3590ca89d55cca8b798f369289f3838d0b5a5805 /test/sprite
parent3fa6a4f4ff148303a14a751009f5596aa3f7effc (diff)
downloadqtlocation-mapboxgl-5524506abd7194456e187532201260b075ea4d93.tar.gz
[core] Eliminate SpriteAtlas::updateDirty
Simplify internal datastructures. Properly remove rects from the bin pack when an image is removed.
Diffstat (limited to 'test/sprite')
-rw-r--r--test/sprite/sprite_atlas.test.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/test/sprite/sprite_atlas.test.cpp b/test/sprite/sprite_atlas.test.cpp
index 67db917602..e84f8a9249 100644
--- a/test/sprite/sprite_atlas.test.cpp
+++ b/test/sprite/sprite_atlas.test.cpp
@@ -133,12 +133,6 @@ TEST(SpriteAtlas, Updates) {
atlas.setSprite("one", newSprite);
ASSERT_EQ(newSprite, atlas.getSprite("one"));
- // Atlas texture hasn't changed yet.
- test::checkImage("test/fixtures/sprite_atlas/updates_before", atlas.getAtlasImage());
-
- atlas.updateDirty();
-
- // Now the atlas texture has changed.
test::checkImage("test/fixtures/sprite_atlas/updates_after", atlas.getAtlasImage());
}
@@ -187,6 +181,25 @@ TEST(SpriteAtlas, AddRemove) {
atlas.setSprite("three", sprite1);
}
+TEST(SpriteAtlas, RemoveReleasesBinPackRect) {
+ FixtureLog log;
+
+ SpriteAtlas atlas({ 36, 36 }, 1);
+
+ const auto big = std::make_shared<SpriteImage>(PremultipliedImage({ 32, 32 }), 1);
+
+ atlas.setSprite("big", big);
+ EXPECT_TRUE(atlas.getImage("big", SpritePatternMode::Single));
+
+ atlas.removeSprite("big");
+
+ atlas.setSprite("big", big);
+ EXPECT_TRUE(atlas.getImage("big", SpritePatternMode::Single));
+
+ EXPECT_EQ(big, atlas.getSprite("big"));
+ EXPECT_TRUE(log.empty());
+}
+
TEST(SpriteAtlas, OtherPixelRatio) {
FixtureLog log;