summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-05-16 15:53:59 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-05-17 11:23:47 -0700
commite7154adac3985b8d877c40d16c7d4b3916c7246b (patch)
treed68c579d078488b5ace871eb8d540d5c6f630de4
parent786707649a2efcddd24fb976150b044097d74219 (diff)
downloadqtlocation-mapboxgl-e7154adac3985b8d877c40d16c7d4b3916c7246b.tar.gz
[core] Remove redundant SpriteAtlasElement members
-rw-r--r--src/mbgl/sprite/sprite_atlas.cpp6
-rw-r--r--src/mbgl/sprite/sprite_atlas.hpp2
-rw-r--r--src/mbgl/text/shaping.cpp8
-rw-r--r--test/sprite/sprite_atlas.test.cpp24
4 files changed, 18 insertions, 22 deletions
diff --git a/src/mbgl/sprite/sprite_atlas.cpp b/src/mbgl/sprite/sprite_atlas.cpp
index 20c062a779..cc69bccdbe 100644
--- a/src/mbgl/sprite/sprite_atlas.cpp
+++ b/src/mbgl/sprite/sprite_atlas.cpp
@@ -22,14 +22,12 @@ SpriteAtlasElement::SpriteAtlasElement(Rect<uint16_t> rect_,
: pos(std::move(rect_)),
sdf(image.sdf),
relativePixelRatio(image.pixelRatio / pixelRatio),
- width(image.image.size.width / image.pixelRatio),
- height(image.image.size.height / image.pixelRatio) {
-
+ size{{image.image.size.width / image.pixelRatio,
+ image.image.size.height / image.pixelRatio}} {
const float w = image.image.size.width / pixelRatio;
const float h = image.image.size.height / pixelRatio;
- size = {{ width, height }};
tl = {{ float(pos.x + padding) / size_.width, float(pos.y + padding) / size_.height }};
br = {{ float(pos.x + padding + w) / size_.width, float(pos.y + padding + h) / size_.height }};
}
diff --git a/src/mbgl/sprite/sprite_atlas.hpp b/src/mbgl/sprite/sprite_atlas.hpp
index bcec26b7ba..f1681608d1 100644
--- a/src/mbgl/sprite/sprite_atlas.hpp
+++ b/src/mbgl/sprite/sprite_atlas.hpp
@@ -29,8 +29,6 @@ public:
std::array<float, 2> size;
std::array<float, 2> tl;
std::array<float, 2> br;
- float width;
- float height;
};
using IconMap = std::unordered_map<std::string, SpriteAtlasElement>;
diff --git a/src/mbgl/text/shaping.cpp b/src/mbgl/text/shaping.cpp
index 78aa142c61..5c99a49133 100644
--- a/src/mbgl/text/shaping.cpp
+++ b/src/mbgl/text/shaping.cpp
@@ -17,10 +17,10 @@ optional<PositionedIcon> PositionedIcon::shapeIcon(const SpriteAtlasElement& ima
float dx = iconOffset[0];
float dy = iconOffset[1];
- float x1 = dx - image.width/ 2.0f;
- float x2 = x1 + image.width;
- float y1 = dy - image.height / 2.0f;
- float y2 = y1 + image.height;
+ float x1 = dx - image.size[0] / 2.0f;
+ float x2 = x1 + image.size[0];
+ float y1 = dy - image.size[1] / 2.0f;
+ float y2 = y1 + image.size[1];
return { PositionedIcon { image, y1, y2, x1, x2, iconRotation } };
}
diff --git a/test/sprite/sprite_atlas.test.cpp b/test/sprite/sprite_atlas.test.cpp
index 269e5b4b62..f6953e61f7 100644
--- a/test/sprite/sprite_atlas.test.cpp
+++ b/test/sprite/sprite_atlas.test.cpp
@@ -36,10 +36,10 @@ TEST(SpriteAtlas, Basic) {
EXPECT_EQ(0, metro.pos.y);
EXPECT_EQ(20, metro.pos.w);
EXPECT_EQ(20, metro.pos.h);
- EXPECT_EQ(18, metro.width);
- EXPECT_EQ(18, metro.height);
- EXPECT_EQ(18u, metro.width * imagePixelRatio);
- EXPECT_EQ(18u, metro.height * imagePixelRatio);
+ EXPECT_EQ(18, metro.size[0]);
+ EXPECT_EQ(18, metro.size[1]);
+ EXPECT_EQ(18u, metro.size[0] * imagePixelRatio);
+ EXPECT_EQ(18u, metro.size[1] * imagePixelRatio);
EXPECT_EQ(1.0f, imagePixelRatio);
@@ -93,10 +93,10 @@ TEST(SpriteAtlas, Size) {
EXPECT_EQ(0, metro.pos.y);
EXPECT_EQ(15, metro.pos.w);
EXPECT_EQ(15, metro.pos.h);
- EXPECT_EQ(18, metro.width);
- EXPECT_EQ(18, metro.height);
- EXPECT_EQ(18u, metro.width * imagePixelRatio);
- EXPECT_EQ(18u, metro.height * imagePixelRatio);
+ EXPECT_EQ(18, metro.size[0]);
+ EXPECT_EQ(18, metro.size[1]);
+ EXPECT_EQ(18u, metro.size[0] * imagePixelRatio);
+ EXPECT_EQ(18u, metro.size[1] * imagePixelRatio);
EXPECT_EQ(1.0f, imagePixelRatio);
// Now the image was created lazily.
@@ -120,10 +120,10 @@ TEST(SpriteAtlas, Updates) {
EXPECT_EQ(0, one.pos.y);
EXPECT_EQ(18, one.pos.w);
EXPECT_EQ(14, one.pos.h);
- EXPECT_EQ(16, one.width);
- EXPECT_EQ(12, one.height);
- EXPECT_EQ(16u, one.width * imagePixelRatio);
- EXPECT_EQ(12u, one.height * imagePixelRatio);
+ EXPECT_EQ(16, one.size[0]);
+ EXPECT_EQ(12, one.size[1]);
+ EXPECT_EQ(16u, one.size[0] * imagePixelRatio);
+ EXPECT_EQ(12u, one.size[1] * imagePixelRatio);
EXPECT_EQ(1.0f, imagePixelRatio);
// Now the image was created lazily.