#pragma once #include #include #include #include namespace mbgl { namespace gfx { class Texture; class Context; } // namespace gfx class ImageManager; class ImagePosition { public: ImagePosition(const mapbox::Bin&, const style::Image::Impl&, uint32_t version = 0); float pixelRatio; Rect textureRect; uint32_t version; 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, }}; } }; using ImagePositions = std::map; class ImageAtlas { public: PremultipliedImage image; ImagePositions iconPositions; ImagePositions patternPositions; void patchUpdatedImages(gfx::Context&, gfx::Texture&, const ImageManager&); private: void patchUpdatedImage(gfx::Context&, gfx::Texture&, ImagePosition& position, const ImageManager& imageManager, const std::string& name, uint16_t version); }; ImageAtlas makeImageAtlas(const ImageMap&, const ImageMap&, const std::unordered_map& versionMap); } // namespace mbgl