#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); void InsertLineStrip(GLState const & state, ref_ptr params); IndicesRange InsertLineStrip(GLState const & state, ref_ptr params, drape_ptr && handle); void InsertLineRaw(GLState const & state, ref_ptr params, vector const & indices); IndicesRange InsertLineRaw(GLState const & state, ref_ptr params, vector const & indices, drape_ptr && handle); typedef function &&)> TFlushFn; void StartSession(TFlushFn const & flusher); void EndSession(); void SetFeatureMinZoom(int minZoom); private: template IndicesRange InsertPrimitives(GLState const & state, ref_ptr params, drape_ptr && transferHandle, uint8_t vertexStride, TArgs ... batcherArgs); class CallbacksWrapper; void ChangeBuffer(ref_ptr wrapper); ref_ptr GetBucket(GLState const & state); void FinalizeBucket(GLState const & state); void Flush(); TFlushFn m_flushInterface; using TBuckets = map>; TBuckets m_buckets; uint32_t m_indexBufferSize; uint32_t m_vertexBufferSize; int m_featureMinZoom = 0; }; class BatcherFactory { public: BatcherFactory(uint32_t indexBufferSize, uint32_t vertexBufferSize) : m_indexBufferSize(indexBufferSize) , m_vertexBufferSize(vertexBufferSize) {} Batcher * GetNew() const; private: uint32_t const m_indexBufferSize; uint32_t const m_vertexBufferSize; }; class SessionGuard { public: SessionGuard(Batcher & batcher, Batcher::TFlushFn const & flusher); ~SessionGuard(); DISALLOW_COPY_AND_MOVE(SessionGuard); private: Batcher & m_batcher; }; } // namespace dp