#pragma once #include #include #include #include #include #include #include namespace mbgl { namespace gfx { class UploadPass; } // namespace gfx class LinePatternPos { public: float width; float height; float y; }; enum class LinePatternCap : bool { Square = false, Round = true, }; struct DashRange { float left; float right; bool isDash; bool isZeroLength; }; class DashPatternTexture { public: DashPatternTexture(const std::vector& from, const std::vector& to, LinePatternCap); // Uploads the texture to the GPU to be available when we need it. This is a lazy operation; // the texture is only bound when the data is uploaded for the first time. void upload(gfx::UploadPass&); // Binds the atlas texture to the GPU, and uploads data if it is out of date. gfx::TextureBinding textureBinding() const; // Returns the size of the texture image. Size getSize() const; const LinePatternPos& getFrom() const { return from; } const LinePatternPos& getTo() const { return to; } private: LinePatternPos from, to; variant texture; }; class LineAtlas { public: LineAtlas(); ~LineAtlas(); // Obtains or creates a texture that has both line patterns in it DashPatternTexture& getDashPatternTexture(const std::vector& from, const std::vector& to, LinePatternCap); // Uploads the textures to the GPU to be available when we need it. void upload(gfx::UploadPass&); bool isEmpty() const { return textures.empty(); } private: std::map textures; // Stores a list of hashes of texture objcts that need uploading. std::vector needsUpload; }; } // namespace mbgl