1 #pragma once 2 3 #include <mbgl/style/image_impl.hpp> 4 #include <mbgl/util/rect.hpp> 5 6 #include <mapbox/shelf-pack.hpp> 7 8 #include <array> 9 10 namespace mbgl { 11 12 class ImagePosition { 13 public: 14 ImagePosition(const mapbox::Bin&, const style::Image::Impl&); 15 16 float pixelRatio; 17 Rect<uint16_t> textureRect; 18 tl() const19 std::array<uint16_t, 2> tl() const { 20 return {{ 21 textureRect.x, 22 textureRect.y 23 }}; 24 } 25 br() const26 std::array<uint16_t, 2> br() const { 27 return {{ 28 static_cast<uint16_t>(textureRect.x + textureRect.w), 29 static_cast<uint16_t>(textureRect.y + textureRect.h) 30 }}; 31 } 32 displaySize() const33 std::array<float, 2> displaySize() const { 34 return {{ 35 textureRect.w / pixelRatio, 36 textureRect.h / pixelRatio, 37 }}; 38 } 39 }; 40 41 using ImagePositions = std::map<std::string, ImagePosition>; 42 43 class ImageAtlas { 44 public: 45 PremultipliedImage image; 46 ImagePositions positions; 47 }; 48 49 ImageAtlas makeImageAtlas(const ImageMap&); 50 51 } // namespace mbgl 52