summaryrefslogtreecommitdiff
path: root/test/sprite
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2017-03-31 14:53:18 -0700
committerChris Loer <chris.loer@mapbox.com>2017-04-04 11:33:12 -0700
commit5cdf838a387cae446dba500ac49a1c5524bf7949 (patch)
tree3b438034a7842c36a7804096785fca1a6ad6fa80 /test/sprite
parent64beba3accb0f2088b2e01fad710f915c81d99c7 (diff)
downloadqtlocation-mapboxgl-5cdf838a387cae446dba500ac49a1c5524bf7949.tar.gz
[core] De-mutex GlyphAtlas and SpriteAtlas
- Expose glyph and icon information to workers via message interface. - Glyph/SpriteAtlas track which tiles have outstanding requests and send messages to them when glyphs/icons become available. - Remove obsolete "updateSymbolDependentTiles" pathway - Symbol preparation for a tile now depends on all glyphs becoming available before it can start. - Start tracking individual icons needed for a tile, although we don't do anything with the information yet. - Introduce typedef for GlyphID
Diffstat (limited to 'test/sprite')
-rw-r--r--test/sprite/sprite_atlas.test.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/test/sprite/sprite_atlas.test.cpp b/test/sprite/sprite_atlas.test.cpp
index 2c425a95d2..2335165715 100644
--- a/test/sprite/sprite_atlas.test.cpp
+++ b/test/sprite/sprite_atlas.test.cpp
@@ -29,15 +29,17 @@ TEST(SpriteAtlas, Basic) {
EXPECT_EQ(112u, atlas.getSize().height);
auto metro = *atlas.getIcon("metro");
+ float imagePixelRatio = metro.relativePixelRatio * atlas.getPixelRatio();
EXPECT_EQ(0, metro.pos.x);
EXPECT_EQ(0, metro.pos.y);
EXPECT_EQ(20, metro.pos.w);
EXPECT_EQ(20, metro.pos.h);
- EXPECT_EQ(18, metro.spriteImage->getWidth());
- EXPECT_EQ(18, metro.spriteImage->getHeight());
- EXPECT_EQ(18u, metro.spriteImage->image.size.width);
- EXPECT_EQ(18u, metro.spriteImage->image.size.height);
- EXPECT_EQ(1.0f, metro.spriteImage->pixelRatio);
+ EXPECT_EQ(18, metro.width);
+ EXPECT_EQ(18, metro.height);
+ EXPECT_EQ(18u, metro.width * imagePixelRatio);
+ EXPECT_EQ(18u, metro.height * imagePixelRatio);
+ EXPECT_EQ(1.0f, imagePixelRatio);
+
EXPECT_EQ(63u, atlas.getAtlasImage().size.width);
EXPECT_EQ(112u, atlas.getAtlasImage().size.height);
@@ -82,15 +84,16 @@ TEST(SpriteAtlas, Size) {
EXPECT_EQ(112u, atlas.getSize().height);
auto metro = *atlas.getIcon("metro");
+ float imagePixelRatio = metro.relativePixelRatio * atlas.getPixelRatio();
EXPECT_EQ(0, metro.pos.x);
EXPECT_EQ(0, metro.pos.y);
EXPECT_EQ(16, metro.pos.w);
EXPECT_EQ(16, metro.pos.h);
- EXPECT_EQ(18, metro.spriteImage->getWidth());
- EXPECT_EQ(18, metro.spriteImage->getHeight());
- EXPECT_EQ(18u, metro.spriteImage->image.size.width);
- EXPECT_EQ(18u, metro.spriteImage->image.size.height);
- EXPECT_EQ(1.0f, metro.spriteImage->pixelRatio);
+ EXPECT_EQ(18, metro.width);
+ EXPECT_EQ(18, metro.height);
+ EXPECT_EQ(18u, metro.width * imagePixelRatio);
+ EXPECT_EQ(18u, metro.height * imagePixelRatio);
+ EXPECT_EQ(1.0f, imagePixelRatio);
// Now the image was created lazily.
EXPECT_EQ(89u, atlas.getAtlasImage().size.width);
@@ -108,15 +111,16 @@ TEST(SpriteAtlas, Updates) {
atlas.setSprite("one", std::make_shared<SpriteImage>(PremultipliedImage({ 16, 12 }), 1));
auto one = *atlas.getIcon("one");
+ float imagePixelRatio = one.relativePixelRatio * atlas.getPixelRatio();
EXPECT_EQ(0, one.pos.x);
EXPECT_EQ(0, one.pos.y);
EXPECT_EQ(20, one.pos.w);
EXPECT_EQ(16, one.pos.h);
- EXPECT_EQ(16, one.spriteImage->getWidth());
- EXPECT_EQ(12, one.spriteImage->getHeight());
- EXPECT_EQ(16u, one.spriteImage->image.size.width);
- EXPECT_EQ(12u, one.spriteImage->image.size.height);
- EXPECT_EQ(1.0f, one.spriteImage->pixelRatio);
+ EXPECT_EQ(16, one.width);
+ EXPECT_EQ(12, one.height);
+ EXPECT_EQ(16u, one.width * imagePixelRatio);
+ EXPECT_EQ(12u, one.height * imagePixelRatio);
+ EXPECT_EQ(1.0f, imagePixelRatio);
// Now the image was created lazily.
EXPECT_EQ(32u, atlas.getAtlasImage().size.width);