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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
|
#include "coverage_generator.hpp"
#include "tile_renderer.hpp"
#include "tile_set.hpp"
#include "platform/settings.hpp"
#include "platform/platform.hpp"
#include "graphics/opengl/gl_render_context.hpp"
#include "graphics/display_list.hpp"
#include "base/logging.hpp"
#include "std/bind.hpp"
CoverageGenerator::CoverageGenerator(TileRenderer * tileRenderer,
shared_ptr<WindowHandle> const & windowHandle,
shared_ptr<graphics::RenderContext> const & primaryRC,
shared_ptr<graphics::ResourceManager> const & rm,
graphics::PacketsQueue * glQueue)
: m_coverageInfo(tileRenderer)
, m_queue(1)
, m_windowHandle(windowHandle)
{
shared_ptr<graphics::RenderContext> renderContext;
if (!glQueue)
renderContext.reset(primaryRC->createShared());
m_queue.AddInitCommand(bind(&CoverageGenerator::InitializeThreadGL, this, renderContext, rm, glQueue));
m_queue.AddFinCommand(bind(&CoverageGenerator::FinalizeThreadGL, this, renderContext, rm));
m_queue.Start();
Settings::Get("IsBenchmarking", m_benchmarkInfo.m_isBenchmarking);
m_currentCoverage = new CachedCoverageInfo();
m_backCoverage = new CachedCoverageInfo();
}
CoverageGenerator::~CoverageGenerator()
{
LOG(LDEBUG, ("cancelling coverage thread"));
ClearCoverage();
}
void CoverageGenerator::Shutdown()
{
LOG(LDEBUG, ("shutdown resources"));
m_stateInfo.SetSequenceID(numeric_limits<int>::max());
m_queue.CancelCommands();
m_queue.Cancel();
}
void CoverageGenerator::InitializeThreadGL(shared_ptr<graphics::RenderContext> context,
shared_ptr<graphics::ResourceManager> resourceManager,
graphics::PacketsQueue * glQueue)
{
threads::MutexGuard g(m_stateInfo.m_mutex);
LOG(LDEBUG, ("initializing CoverageGenerator on it's own thread."));
if (context)
{
context->makeCurrent();
context->startThreadDrawing(resourceManager->cacheThreadSlot());
}
graphics::Screen::Params params;
params.m_resourceManager = resourceManager;
params.m_renderQueue = glQueue;
params.m_threadSlot = resourceManager->cacheThreadSlot();
params.m_renderContext = context;
params.m_storageType = graphics::EMediumStorage;
params.m_textureType = graphics::EMediumTexture;
m_cacheScreen.reset(new graphics::Screen(params));
}
void CoverageGenerator::FinalizeThreadGL(shared_ptr<graphics::RenderContext> context,
shared_ptr<graphics::ResourceManager> resourceManager)
{
if (context)
context->endThreadDrawing(resourceManager->cacheThreadSlot());
}
void CoverageGenerator::Pause()
{
m_stateInfo.Pause();
m_queue.CancelCommands();
}
void CoverageGenerator::Resume()
{
m_stateInfo.Resume();
}
void CoverageGenerator::InvalidateTiles(m2::AnyRectD const & r, int startScale)
{
if (m_stateInfo.m_sequenceID == numeric_limits<int>::max())
return;
/// this automatically will skip the previous CoverScreen commands
/// and MergeTiles commands from previously generated ScreenCoverages
++m_stateInfo.m_sequenceID;
m_queue.AddCommand(bind(&CoverageGenerator::InvalidateTilesImpl, this, r, startScale));
}
void CoverageGenerator::CoverScreen(ScreenBase const & screen, bool doForce)
{
if (screen == m_stateInfo.m_currentScreen && !doForce)
return;
if (m_stateInfo.m_sequenceID == numeric_limits<int>::max())
return;
m_stateInfo.m_currentScreen = screen;
++m_stateInfo.m_sequenceID;
m_queue.AddCommand(bind(&CoverageGenerator::CoverScreenImpl, this, _1, screen, m_stateInfo.m_sequenceID));
}
void CoverageGenerator::MergeTile(Tiler::RectInfo const & rectInfo,
int sequenceID)
{
m_queue.AddCommand(bind(&CoverageGenerator::MergeTileImpl, this, _1, rectInfo, sequenceID));
}
void CoverageGenerator::FinishSequenceIfNeeded()
{
m_queue.AddCommand(bind(&CoverageGenerator::BenchmarkInfo::TryFinishSequence, &m_benchmarkInfo));
}
void CoverageGenerator::Lock()
{
m_stateInfo.m_mutex.Lock();
}
void CoverageGenerator::Unlock()
{
m_stateInfo.m_mutex.Unlock();
}
void CoverageGenerator::Draw(graphics::Screen * s, ScreenBase const & screen)
{
math::Matrix<double, 3, 3> m = m_currentCoverage->m_screen.PtoGMatrix() * screen.GtoPMatrix();
ASSERT(m_currentCoverage, ());
if (m_currentCoverage->m_mainElements)
s->drawDisplayList(m_currentCoverage->m_mainElements, m);
if (m_currentCoverage->m_sharpElements)
s->drawDisplayList(m_currentCoverage->m_sharpElements, m);
if (m_benchmarkInfo.m_isBenchmarking)
FinishSequenceIfNeeded();
}
graphics::Overlay * CoverageGenerator::GetOverlay() const
{
return m_coverageInfo.m_overlay;
}
bool CoverageGenerator::IsEmptyDrawing() const
{
return (m_currentCoverage->m_renderLeafTilesCount <= 0) && m_currentCoverage->m_isEmptyDrawing;
}
bool CoverageGenerator::IsBackEmptyDrawing() const
{
return (m_backCoverage->m_renderLeafTilesCount <= 0) && m_backCoverage->m_isEmptyDrawing;
}
bool CoverageGenerator::DoForceUpdate() const
{
return m_stateInfo.m_needForceUpdate;
}
////////////////////////////////////////////////////
/// Benchmark support
////////////////////////////////////////////////////
int CoverageGenerator::InsertBenchmarkFence()
{
return m_benchmarkInfo.InsertBenchmarkFence();
}
void CoverageGenerator::JoinBenchmarkFence(int fenceID)
{
m_benchmarkInfo.JoinBenchmarkFence(fenceID);
}
////////////////////////////////////////////////////
/// On Coverage generator thread methods
////////////////////////////////////////////////////
void CoverageGenerator::CoverScreenImpl(core::CommandsQueue::Environment const & env,
ScreenBase const & screen,
int sequenceID)
{
if (sequenceID < m_stateInfo.m_sequenceID)
return;
m_stateInfo.m_currentScreen = screen;
m_backCoverage->m_screen = screen;
m_coverageInfo.m_tiler.seed(screen, screen.GlobalRect().GlobalCenter(), m_coverageInfo.m_tileRenderer->TileSize());
ComputeCoverTasks();
bool const shouldSwap = !m_stateInfo.m_isPause && CacheCoverage(env);
if (shouldSwap)
{
{
threads::MutexGuard g(m_stateInfo.m_mutex);
swap(m_currentCoverage, m_backCoverage);
}
m_backCoverage->ResetDL();
}
else
{
// we should skip all the following MergeTile commands
++m_stateInfo.m_sequenceID;
}
m_stateInfo.SetForceUpdate(!shouldSwap);
m_windowHandle->invalidate();
}
void CoverageGenerator::MergeTileImpl(core::CommandsQueue::Environment const & env,
Tiler::RectInfo const & rectInfo,
int sequenceID)
{
if (sequenceID < m_stateInfo.m_sequenceID)
{
m_coverageInfo.m_tileRenderer->RemoveActiveTile(rectInfo, sequenceID);
return;
}
m_backCoverage->m_screen = m_stateInfo.m_currentScreen;
m_backCoverage->m_isEmptyDrawing = m_currentCoverage->m_isEmptyDrawing;
m_backCoverage->m_renderLeafTilesCount = m_currentCoverage->m_renderLeafTilesCount;
MergeSingleTile(rectInfo);
bool const shouldSwap = !m_stateInfo.m_isPause && CacheCoverage(env);
if (shouldSwap)
{
{
threads::MutexGuard g(m_stateInfo.m_mutex);
swap(m_currentCoverage, m_backCoverage);
}
m_backCoverage->ResetDL();
}
m_benchmarkInfo.DecrementTileCount(sequenceID);
m_stateInfo.SetForceUpdate(!shouldSwap);
m_windowHandle->invalidate();
}
void CoverageGenerator::InvalidateTilesImpl(m2::AnyRectD const & r, int startScale)
{
TileCache & tileCache = m_coverageInfo.m_tileRenderer->GetTileCache();
tileCache.Lock();
{
threads::MutexGuard g(m_stateInfo.m_mutex);
typedef buffer_vector<Tile const *, 8> vector8_t;
vector8_t toRemove;
for (CoverageInfo::TTileSet::const_iterator it = m_coverageInfo.m_tiles.begin();
it != m_coverageInfo.m_tiles.end();
++it)
{
Tiler::RectInfo const & ri = (*it)->m_rectInfo;
if (r.IsIntersect(m2::AnyRectD(ri.m_rect)) && (ri.m_tileScale >= startScale))
{
toRemove.push_back(*it);
tileCache.UnlockTile(ri);
}
}
for (vector8_t::const_iterator it = toRemove.begin();
it != toRemove.end();
++it)
{
m_coverageInfo.m_tiles.erase(*it);
}
}
/// here we should copy elements as we've delete some of them later
set<Tiler::RectInfo> k = tileCache.Keys();
for (set<Tiler::RectInfo>::const_iterator it = k.begin(); it != k.end(); ++it)
{
Tiler::RectInfo const & ri = *it;
if ((ri.m_tileScale >= startScale) && r.IsIntersect(m2::AnyRectD(ri.m_rect)))
{
ASSERT(tileCache.LockCount(ri) == 0, ());
tileCache.Remove(ri);
}
}
tileCache.Unlock();
MergeOverlay();
}
////////////////////////////////////////////////////////////
/// Support methods
////////////////////////////////////////////////////////////
void CoverageGenerator::ComputeCoverTasks()
{
m_backCoverage->m_isEmptyDrawing = false;
m_backCoverage->m_renderLeafTilesCount = 0;
vector<Tiler::RectInfo> allRects;
allRects.reserve(16);
buffer_vector<Tiler::RectInfo, 8> newRects;
m_coverageInfo.m_tiler.tiles(allRects, GetPlatform().PreCachingDepth());
TileCache & tileCache = m_coverageInfo.m_tileRenderer->GetTileCache();
tileCache.Lock();
int const step = GetPlatform().PreCachingDepth() - 1;
bool isEmptyDrawingBuf = true;
CoverageInfo::TTileSet tiles;
for (size_t i = 0; i < allRects.size(); ++i)
{
Tiler::RectInfo const & ri = allRects[i];
if (!((ri.m_tileScale == m_coverageInfo.m_tiler.tileScale() - step) ||
(ri.m_tileScale == m_coverageInfo.m_tiler.tileScale() )))
{
continue;
}
if (tileCache.HasTile(ri))
{
tileCache.TouchTile(ri);
Tile const * tile = &tileCache.GetTile(ri);
ASSERT(tiles.find(tile) == tiles.end(), ());
if (m_coverageInfo.m_tiler.isLeaf(ri))
isEmptyDrawingBuf &= tile->m_isEmptyDrawing;
tiles.insert(tile);
}
else
{
newRects.push_back(ri);
if (m_coverageInfo.m_tiler.isLeaf(ri))
++m_backCoverage->m_renderLeafTilesCount;
}
}
m_backCoverage->m_isEmptyDrawing = isEmptyDrawingBuf;
/// computing difference between current and previous coverage
/// tiles, that aren't in current coverage are unlocked to allow their deletion from TileCache
/// tiles, that are new to the current coverage are added into m_tiles and locked in TileCache
size_t firstTileForAdd = 0;
buffer_vector<const Tile *, 64> diff_tiles;
diff_tiles.reserve(m_coverageInfo.m_tiles.size() + tiles.size());
#ifdef _MSC_VER
vs_bug::
#endif
set_difference(m_coverageInfo.m_tiles.begin(), m_coverageInfo.m_tiles.end(),
tiles.begin(), tiles.end(),
back_inserter(diff_tiles), tiles.key_comp());
firstTileForAdd = diff_tiles.size();
#ifdef _MSC_VER
vs_bug::
#endif
set_difference(tiles.begin(), tiles.end(),
m_coverageInfo.m_tiles.begin(), m_coverageInfo.m_tiles.end(),
back_inserter(diff_tiles), tiles.key_comp());
for (size_t i = 0; i < firstTileForAdd; ++i)
tileCache.UnlockTile(diff_tiles[i]->m_rectInfo);
for (size_t i = firstTileForAdd; i < diff_tiles.size(); ++i)
tileCache.LockTile(diff_tiles[i]->m_rectInfo);
tileCache.Unlock();
m_coverageInfo.m_tiles = tiles;
MergeOverlay();
/// clearing all old commands
m_coverageInfo.m_tileRenderer->ClearCommands();
/// setting new sequenceID
m_coverageInfo.m_tileRenderer->SetSequenceID(m_stateInfo.m_sequenceID);
/// @todo After ClearCommands i think we have no commands to cancel.
m_coverageInfo.m_tileRenderer->CancelCommands();
m_benchmarkInfo.m_tilesCount = newRects.size();
m_benchmarkInfo.m_benchmarkSequenceID = m_stateInfo.m_sequenceID;
for (size_t i = 0; i < newRects.size(); ++i)
{
Tiler::RectInfo const & ri = newRects[i];
core::CommandsQueue::Chain chain;
chain.addCommand(bind(&CoverageGenerator::MergeTile,
this, ri, m_stateInfo.m_sequenceID));
m_coverageInfo.m_tileRenderer->AddCommand(ri, m_stateInfo.m_sequenceID, chain);
}
}
void CoverageGenerator::MergeOverlay()
{
m_coverageInfo.m_overlay->lock();
m_coverageInfo.m_overlay->clear();
for (Tile const * tile : m_coverageInfo.m_tiles)
{
Tiler::RectInfo const & ri = tile->m_rectInfo;
if (m_coverageInfo.m_tiler.isLeaf(ri))
m_coverageInfo.m_overlay->merge(tile->m_overlay,
tile->m_tileScreen.PtoGMatrix() * m_stateInfo.m_currentScreen.GtoPMatrix());
}
m_coverageInfo.m_overlay->unlock();
}
void CoverageGenerator::MergeSingleTile(Tiler::RectInfo const & rectInfo)
{
m_coverageInfo.m_tileRenderer->CacheActiveTile(rectInfo);
TileCache & tileCache = m_coverageInfo.m_tileRenderer->GetTileCache();
tileCache.Lock();
Tile const * tile = NULL;
if (tileCache.HasTile(rectInfo))
{
tileCache.LockTile(rectInfo);
tile = &tileCache.GetTile(rectInfo);
}
if (tile != NULL)
{
m_coverageInfo.m_tiles.insert(tile);
if (m_coverageInfo.m_tiler.isLeaf(rectInfo))
{
m_backCoverage->m_isEmptyDrawing &= tile->m_isEmptyDrawing;
m_backCoverage->m_renderLeafTilesCount--;
}
}
tileCache.Unlock();
if (tile != NULL && m_coverageInfo.m_tiler.isLeaf(rectInfo))
{
m_coverageInfo.m_overlay->lock();
m_coverageInfo.m_overlay->merge(tile->m_overlay,
tile->m_tileScreen.PtoGMatrix() * m_stateInfo.m_currentScreen.GtoPMatrix());
m_coverageInfo.m_overlay->unlock();
}
}
namespace
{
bool SharpnessComparator(shared_ptr<graphics::OverlayElement> const & e1,
shared_ptr<graphics::OverlayElement> const & e2)
{
return e1->hasSharpGeometry() && (!e2->hasSharpGeometry());
}
}
bool CoverageGenerator::CacheCoverage(core::CommandsQueue::Environment const & env)
{
if (m_cacheScreen->isCancelled())
return false;
ASSERT(m_backCoverage->m_mainElements == nullptr, ());
ASSERT(m_backCoverage->m_sharpElements == nullptr, ());
m_backCoverage->m_mainElements = m_cacheScreen->createDisplayList();
m_backCoverage->m_sharpElements = m_cacheScreen->createDisplayList();
m_cacheScreen->setEnvironment(&env);
m_cacheScreen->beginFrame();
m_cacheScreen->setDisplayList(m_backCoverage->m_mainElements);
vector<graphics::BlitInfo> infos;
infos.reserve(m_coverageInfo.m_tiles.size());
for (Tile const * tile : m_coverageInfo.m_tiles)
{
size_t tileWidth = tile->m_renderTarget->width();
size_t tileHeight = tile->m_renderTarget->height();
graphics::BlitInfo bi;
bi.m_matrix = tile->m_tileScreen.PtoGMatrix() * m_stateInfo.m_currentScreen.GtoPMatrix();
bi.m_srcRect = m2::RectI(0, 0, tileWidth - 2, tileHeight - 2);
bi.m_texRect = m2::RectU(1, 1, tileWidth - 1, tileHeight - 1);
bi.m_srcSurface = tile->m_renderTarget;
bi.m_depth = tile->m_rectInfo.m_tileScale * 100;
infos.push_back(bi);
}
if (!infos.empty())
m_cacheScreen->blit(infos.data(), infos.size(), true);
m_cacheScreen->clear(graphics::Color(), false);
math::Matrix<double, 3, 3> idM = math::Identity<double, 3>();
m_coverageInfo.m_overlay->lock();
vector<shared_ptr<graphics::OverlayElement> > overlayElements;
overlayElements.reserve(m_coverageInfo.m_overlay->getElementsCount());
m_coverageInfo.m_overlay->forEach(MakeBackInsertFunctor(overlayElements));
sort(overlayElements.begin(), overlayElements.end(), SharpnessComparator);
unsigned currentElement = 0;
for (; currentElement < overlayElements.size(); ++currentElement)
{
shared_ptr<graphics::OverlayElement> const & elem = overlayElements[currentElement];
if (elem->hasSharpGeometry())
break;
elem->draw(m_cacheScreen.get(), idM);
}
m_cacheScreen->applySharpStates();
m_cacheScreen->setDisplayList(m_backCoverage->m_sharpElements);
for (; currentElement < overlayElements.size(); ++currentElement)
overlayElements[currentElement]->draw(m_cacheScreen.get(), idM);
m_coverageInfo.m_overlay->unlock();
m_cacheScreen->setDisplayList(0);
m_cacheScreen->applyStates();
m_cacheScreen->endFrame();
/// completing commands that was immediately executed
/// while recording of displayList(for example UnlockStorage)
m_cacheScreen->completeCommands();
m_cacheScreen->setEnvironment(0);
return true;
}
void CoverageGenerator::ClearCoverage()
{
{
m_coverageInfo.m_overlay->lock();
m_coverageInfo.m_overlay->clear();
m_coverageInfo.m_overlay->unlock();
}
TileCache & tileCache = m_coverageInfo.m_tileRenderer->GetTileCache();
tileCache.Lock();
for (CoverageInfo::TTileSet::const_iterator it = m_coverageInfo.m_tiles.begin();
it != m_coverageInfo.m_tiles.end();
++it)
{
Tiler::RectInfo const & ri = (*it)->m_rectInfo;
tileCache.UnlockTile(ri);
}
tileCache.Unlock();
m_coverageInfo.m_tiles.clear();
delete m_currentCoverage;
m_currentCoverage = 0;
delete m_backCoverage;
m_backCoverage = 0;
}
////////////////////////////////////////////////////////////
/// BenchmarkInfo
////////////////////////////////////////////////////////////
CoverageGenerator::BenchmarkInfo::BenchmarkInfo()
: m_benchmarkSequenceID(numeric_limits<int>::max())
, m_tilesCount(-1)
, m_fenceManager(2)
, m_currentFenceID(-1)
, m_isBenchmarking(false)
{
}
void CoverageGenerator::BenchmarkInfo::DecrementTileCount(int sequenceID)
{
if (!m_isBenchmarking)
return;
if (sequenceID < m_benchmarkSequenceID)
{
m_tilesCount = -1;
return;
}
m_tilesCount -= 1;
}
int CoverageGenerator::BenchmarkInfo::InsertBenchmarkFence()
{
ASSERT(m_isBenchmarking, ("Only for benchmark mode"));
m_currentFenceID = m_fenceManager.insertFence();
return m_currentFenceID;
}
void CoverageGenerator::BenchmarkInfo::JoinBenchmarkFence(int fenceID)
{
ASSERT(m_isBenchmarking, ("Only for benchmark mode"));
CHECK(fenceID == m_currentFenceID, ("InsertBenchmarkFence without corresponding SignalBenchmarkFence detected"));
m_fenceManager.joinFence(fenceID);
}
void CoverageGenerator::BenchmarkInfo::SignalBenchmarkFence()
{
ASSERT(m_isBenchmarking, ("Only for benchmark mode"));
if (m_currentFenceID != -1)
m_fenceManager.signalFence(m_currentFenceID);
}
void CoverageGenerator::BenchmarkInfo::TryFinishSequence()
{
if (m_tilesCount == 0)
{
m_tilesCount = -1;
SignalBenchmarkFence();
}
}
////////////////////////////////////////////////////////////
/// StateInfo
////////////////////////////////////////////////////////////
CoverageGenerator::StateInfo::StateInfo()
: m_isPause(false)
, m_needForceUpdate(false)
, m_sequenceID(0)
{
}
void CoverageGenerator::StateInfo::SetSequenceID(int sequenceID)
{
m_sequenceID = sequenceID;
}
void CoverageGenerator::StateInfo::SetForceUpdate(bool needForceUpdate)
{
m_needForceUpdate = needForceUpdate;
}
void CoverageGenerator::StateInfo::Pause()
{
m_isPause = true;
}
void CoverageGenerator::StateInfo::Resume()
{
m_isPause = false;
m_needForceUpdate = true;
}
////////////////////////////////////////////////////////////
/// CoverageGenerator
////////////////////////////////////////////////////////////
CoverageGenerator::CoverageInfo::CoverageInfo(TileRenderer *tileRenderer)
: m_tileRenderer(tileRenderer)
, m_overlay(new graphics::Overlay())
{
}
CoverageGenerator::CoverageInfo::~CoverageInfo()
{
delete m_overlay;
}
CoverageGenerator::CachedCoverageInfo::CachedCoverageInfo()
: m_mainElements(nullptr)
, m_sharpElements(nullptr)
, m_renderLeafTilesCount(0)
, m_isEmptyDrawing(false)
{
}
CoverageGenerator::CachedCoverageInfo::~CachedCoverageInfo()
{
delete m_mainElements;
delete m_sharpElements;
}
void CoverageGenerator::CachedCoverageInfo::ResetDL()
{
delete m_mainElements;
m_mainElements = nullptr;
delete m_sharpElements;
m_sharpElements = nullptr;
}
|