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
|
#include "drape_frontend/overlay_batcher.hpp"
#include "drape_frontend/map_shape.hpp"
#include "drape/batcher.hpp"
#include "drape/render_bucket.hpp"
#include "drape/texture_manager.hpp"
namespace df
{
uint32_t const kOverlayIndexBufferSize = 30000;
uint32_t const kOverlayVertexBufferSize = 20000;
OverlayBatcher::OverlayBatcher(TileKey const & key)
: m_batcher(kOverlayIndexBufferSize, kOverlayVertexBufferSize)
{
int const kAverageRenderDataCount = 5;
m_data.reserve(kAverageRenderDataCount);
m_batcher.SetBatcherHash(key.GetHashValue(BatcherBucket::Overlay));
m_batcher.StartSession([this, key](dp::RenderState const & state, drape_ptr<dp::RenderBucket> && bucket)
{
FlushGeometry(key, state, std::move(bucket));
});
}
void OverlayBatcher::Batch(ref_ptr<dp::GraphicsContext> context, drape_ptr<MapShape> const & shape,
ref_ptr<dp::TextureManager> texMng)
{
m_batcher.SetFeatureMinZoom(shape->GetFeatureMinZoom());
shape->Draw(context, make_ref(&m_batcher), texMng);
}
void OverlayBatcher::Finish(ref_ptr<dp::GraphicsContext> context, TOverlaysRenderData & data)
{
m_batcher.EndSession(context);
data.swap(m_data);
}
void OverlayBatcher::FlushGeometry(TileKey const & key, dp::RenderState const & state,
drape_ptr<dp::RenderBucket> && bucket)
{
m_data.emplace_back(key, state, std::move(bucket));
}
} // namespace df
|