#pragma once #include #include #include #include namespace mbgl { namespace gfx { class UploadPass; class Texture; } // namespace gfx class ImageManager; class ImagePosition { public: ImagePosition(const mapbox::Bin&, const style::Image::Impl&, uint32_t version = 0); static constexpr const uint16_t padding = 1u; float pixelRatio; Rect textureRect; uint32_t version; style::ImageStretches stretchX; style::ImageStretches stretchY; style::ImageContent content; std::array tl() const { return {{ textureRect.x, textureRect.y }}; } std::array br() const { return {{ static_cast(textureRect.x + textureRect.w), static_cast(textureRect.y + textureRect.h) }}; } std::array tlbr() const { const auto _tl = tl(); const auto _br = br(); return {{ _tl[0], _tl[1], _br[0], _br[1] }}; } std::array displaySize() const { return {{ textureRect.w / pixelRatio, textureRect.h / pixelRatio, }}; } Rect paddedTextureRect() const { return {static_cast(textureRect.x - padding), static_cast(textureRect.y - padding), static_cast(textureRect.w + padding * 2), static_cast(textureRect.h + padding * 2)}; } }; using ImagePositions = std::map; class ImagePatch { public: ImagePatch(Immutable image_, const Rect& textureRect_) : image(std::move(image_)) , textureRect(textureRect_) {} Immutable image; Rect textureRect; }; class ImageAtlas { public: PremultipliedImage image; ImagePositions iconPositions; ImagePositions patternPositions; std::vector getImagePatchesAndUpdateVersions(const ImageManager&); }; ImageAtlas makeImageAtlas(const ImageMap&, const ImageMap&, const std::unordered_map& versionMap); } // namespace mbgl