#pragma once #include "drape/attribute_provider.hpp" #include "drape/glstate.hpp" #include "drape/overlay_handle.hpp" #include "drape/pointers.hpp" #include "drape/render_bucket.hpp" #include "drape/vertex_array_buffer.hpp" #include "base/macros.hpp" #include "std/map.hpp" #include "std/function.hpp" namespace dp { class RenderBucket; class AttributeProvider; class OverlayHandle; class Batcher { public: static uint32_t const IndexPerTriangle = 3; static uint32_t const IndexPerQuad = 6; static uint32_t const VertexPerQuad = 4; Batcher(uint32_t indexBufferSize, uint32_t vertexBufferSize); ~Batcher(); void InsertTriangleList(GLState const & state, ref_ptr params); IndicesRange InsertTriangleList(GLState const & state, ref_ptr params, drape_ptr && handle); void InsertTriangleStrip(GLState const & state, ref_ptr params); IndicesRange InsertTriangleStrip(GLState const & state, ref_ptr params, drape_ptr && handle); void InsertTriangleFan(GLState const & state, ref_ptr params); IndicesRange InsertTriangleFan(GLState const & state, ref_ptr params, drape_ptr && handle); void InsertListOfStrip(GLState const & state, ref_ptr params, uint8_t vertexStride); IndicesRange InsertListOfStrip(GLState const & state, ref_ptr params, drape_ptr && handle, uint8_t vertexStride); typedef function &&)> TFlushFn; void StartSession(TFlushFn const & flusher); void EndSession(); void SetFeatureMinZoom(int minZoom); private: template IndicesRange InsertTriangles(GLState const & state, ref_ptr params, drape_ptr && handle, uint8_t vertexStride = 0); class CallbacksWrapper; void ChangeBuffer(ref_ptr wrapper); ref_ptr GetBucket(GLState const & state); void FinalizeBucket(GLState const & state); void Flush(); private: TFlushFn m_flushInterface; private: using TBuckets = map>; TBuckets m_buckets; uint32_t m_indexBufferSize; uint32_t m_vertexBufferSize; int m_featureMinZoom = 0; }; class BatcherFactory { public: Batcher * GetNew() const; }; class SessionGuard { public: SessionGuard(Batcher & batcher, Batcher::TFlushFn const & flusher); ~SessionGuard(); DISALLOW_COPY_AND_MOVE(SessionGuard); private: Batcher & m_batcher; }; } // namespace dp