From 306f1a685c8fb090d7937c6ac3ac89888749ef21 Mon Sep 17 00:00:00 2001 From: ExMix Date: Tue, 17 Dec 2013 15:59:33 +0300 Subject: [PATCH] [drape]batcher know nothing about in witch tile stored geometry that he processed. Because of it we use batcher by session. --- drape/batcher.cpp | 20 ++++++++++++++------ drape/batcher.hpp | 19 ++++++++----------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/drape/batcher.cpp b/drape/batcher.cpp index 3e1d77edb7..f8c44b4b38 100644 --- a/drape/batcher.cpp +++ b/drape/batcher.cpp @@ -91,8 +91,7 @@ namespace }; } -Batcher::Batcher(RefPointer flushInterface) - : m_flushInterface(flushInterface) +Batcher::Batcher() { } @@ -167,6 +166,17 @@ void Batcher::InsertTriangleFan(const GLState & state, RefPointer Batcher::GetBuffer(const GLState & state) { buckets_t::iterator it = m_buckets.find(state); @@ -180,17 +190,15 @@ RefPointer Batcher::GetBuffer(const GLState & state) void Batcher::FinalizeBuffer(const GLState & state) { - ///@TODO ASSERT(m_buckets.find(state) != m_buckets.end(), ("Have no bucket for finalize with given state")); - m_flushInterface->FlushFullBucket(state, m_buckets[state].Move()); + m_flushInterface(state, m_buckets[state].Move()); m_buckets.erase(state); } void Batcher::Flush() { - ///@TODO for (buckets_t::iterator it = m_buckets.begin(); it != m_buckets.end(); ++it) - m_flushInterface->FlushFullBucket(it->first, it->second.Move()); + m_flushInterface(it->first, it->second.Move()); m_buckets.clear(); } diff --git a/drape/batcher.hpp b/drape/batcher.hpp index c94c7eb4d1..bbfb1797a3 100644 --- a/drape/batcher.hpp +++ b/drape/batcher.hpp @@ -6,25 +6,21 @@ #include "attribute_provider.hpp" #include "../std/map.hpp" - -class IBatchFlush -{ -public: - virtual ~IBatchFlush() {} - - virtual void FlushFullBucket(const GLState & state, TransferPointer backet) = 0; -}; +#include "../std/function.hpp" class Batcher { public: - Batcher(RefPointer flushInterface); + Batcher(); ~Batcher(); void InsertTriangleList(const GLState & state, RefPointer params); void InsertTriangleStrip(const GLState & state, RefPointer params); void InsertTriangleFan(const GLState & state, RefPointer params); - void Flush(); + + typedef function )> flush_fn; + void StartSession(const flush_fn & flusher); + void EndSession(); private: template @@ -34,9 +30,10 @@ private: /// return true if GLBuffer is finished bool UploadBufferData(RefPointer vertexBuffer, RefPointer params); void FinalizeBuffer(const GLState & state); + void Flush(); private: - RefPointer m_flushInterface; + flush_fn m_flushInterface; private: typedef map > buckets_t;