1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#pragma once
#include "drape/pointers.hpp"
#include "drape/glstate.hpp"
#include "drape/render_bucket.hpp"
#include "drape/attribute_provider.hpp"
#include "drape/overlay_handle.hpp"
#include "std/map.hpp"
#include "std/function.hpp"
namespace dp
{
class RenderBucket;
class AttributeProvider;
class OverlayHandle;
class Batcher
{
public:
Batcher(uint32_t indexBufferSize = 9000, uint32_t vertexBufferSize = 10000);
~Batcher();
void InsertTriangleList(GLState const & state, RefPointer<AttributeProvider> params);
void InsertTriangleList(GLState const & state, RefPointer<AttributeProvider> params,
TransferPointer<OverlayHandle> handle);
void InsertTriangleStrip(GLState const & state, RefPointer<AttributeProvider> params);
void InsertTriangleStrip(GLState const & state, RefPointer<AttributeProvider> params,
TransferPointer<OverlayHandle> handle);
void InsertTriangleFan(GLState const & state, RefPointer<AttributeProvider> params);
void InsertTriangleFan(GLState const & state, RefPointer<AttributeProvider> params,
TransferPointer<OverlayHandle> handle);
void InsertListOfStrip(GLState const & state, RefPointer<AttributeProvider> params, uint8_t vertexStride);
void InsertListOfStrip(GLState const & state, RefPointer<AttributeProvider> params,
TransferPointer<OverlayHandle> handle, uint8_t vertexStride);
typedef function<void (GLState const &, TransferPointer<RenderBucket> )> flush_fn;
void StartSession(flush_fn const & flusher);
void EndSession();
private:
template<typename TBacher>
void InsertTriangles(GLState const & state,
RefPointer<AttributeProvider> params,
TransferPointer<OverlayHandle> handle,
uint8_t vertexStride = 0);
class CallbacksWrapper;
void ChangeBuffer(RefPointer<CallbacksWrapper> wrapper, bool checkFilledBuffer);
RefPointer<RenderBucket> GetBucket(GLState const & state);
void FinalizeBucket(GLState const & state);
void Flush();
private:
flush_fn m_flushInterface;
private:
typedef map<GLState, MasterPointer<RenderBucket> > buckets_t;
buckets_t m_buckets;
uint32_t m_indexBufferSize;
uint32_t m_vertexBufferSize;
};
class BatcherFactory
{
public:
Batcher * GetNew() const { return new Batcher(); }
};
} // namespace dp
|