summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer/image_atlas.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/renderer/image_atlas.hpp')
-rw-r--r--src/mbgl/renderer/image_atlas.hpp33
1 files changed, 10 insertions, 23 deletions
diff --git a/src/mbgl/renderer/image_atlas.hpp b/src/mbgl/renderer/image_atlas.hpp
index e5305b0e42..8be975e98c 100644
--- a/src/mbgl/renderer/image_atlas.hpp
+++ b/src/mbgl/renderer/image_atlas.hpp
@@ -22,24 +22,19 @@ public:
static constexpr const uint16_t padding = 1u;
float pixelRatio;
- Rect<uint16_t> textureRect;
+ Rect<uint16_t> paddedRect;
uint32_t version;
style::ImageStretches stretchX;
style::ImageStretches stretchY;
style::ImageContent content;
std::array<uint16_t, 2> tl() const {
- return {{
- textureRect.x,
- textureRect.y
- }};
+ return {{static_cast<uint16_t>(paddedRect.x + padding), static_cast<uint16_t>(paddedRect.y + padding)}};
}
std::array<uint16_t, 2> br() const {
- return {{
- static_cast<uint16_t>(textureRect.x + textureRect.w),
- static_cast<uint16_t>(textureRect.y + textureRect.h)
- }};
+ return {{static_cast<uint16_t>(paddedRect.x + paddedRect.w - padding),
+ static_cast<uint16_t>(paddedRect.y + paddedRect.h - padding)}};
}
std::array<uint16_t, 4> tlbr() const {
@@ -50,29 +45,21 @@ public:
std::array<float, 2> displaySize() const {
return {{
- textureRect.w / pixelRatio,
- textureRect.h / pixelRatio,
+ static_cast<float>(paddedRect.w - padding * 2) / pixelRatio,
+ static_cast<float>(paddedRect.h - padding * 2) / pixelRatio,
}};
}
-
- Rect<uint16_t> paddedTextureRect() const {
- return {static_cast<uint16_t>(textureRect.x - padding),
- static_cast<uint16_t>(textureRect.y - padding),
- static_cast<uint16_t>(textureRect.w + padding * 2),
- static_cast<uint16_t>(textureRect.h + padding * 2)};
- }
};
using ImagePositions = std::map<std::string, ImagePosition>;
class ImagePatch {
public:
- ImagePatch(Immutable<style::Image::Impl> image_,
- const Rect<uint16_t>& textureRect_)
- : image(std::move(image_))
- , textureRect(textureRect_) {}
+ ImagePatch(Immutable<style::Image::Impl> image_, const Rect<uint16_t>& paddedRect_)
+ : image(std::move(image_)), paddedRect(paddedRect_) {}
+
Immutable<style::Image::Impl> image;
- Rect<uint16_t> textureRect;
+ Rect<uint16_t> paddedRect;
};
class ImageAtlas {