forked from organicmaps/organicmaps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase_renderer.hpp
60 lines (43 loc) · 1.43 KB
/
base_renderer.hpp
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
#pragma once
#include "drape_frontend/message_acceptor.hpp"
#include "drape_frontend/threads_commutator.hpp"
#include "drape_frontend/tile_utils.hpp"
#include "drape/oglcontextfactory.hpp"
#include "base/thread.hpp"
#include "std/atomic.hpp"
#include "std/condition_variable.hpp"
#include "std/function.hpp"
#include "std/mutex.hpp"
namespace df
{
class BaseRenderer : public MessageAcceptor
{
public:
using TCompletionHandler = function<void()>;
BaseRenderer(ThreadsCommutator::ThreadName name,
dp::RefPointer<ThreadsCommutator> commutator,
dp::RefPointer<dp::OGLContextFactory> oglcontextfactory);
void SetRenderingEnabled(bool const isEnabled);
protected:
dp::RefPointer<ThreadsCommutator> m_commutator;
dp::RefPointer<dp::OGLContextFactory> m_contextFactory;
void StartThread();
void StopThread();
void CheckRenderingEnabled();
void ProcessStopRenderingMessage();
virtual unique_ptr<threads::IRoutine> CreateRoutine() = 0;
private:
bool CanReceiveMessage() override;
private:
threads::Thread m_selfThread;
ThreadsCommutator::ThreadName m_threadName;
mutex m_renderingEnablingMutex;
condition_variable m_renderingEnablingCondition;
atomic<bool> m_isEnabled;
TCompletionHandler m_renderingEnablingCompletionHandler;
bool m_wasNotified;
void SetRenderingEnabled(bool const isEnabled, TCompletionHandler completionHandler);
void Notify();
void WakeUp();
};
} // namespace df