-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLayerStack.cpp
52 lines (45 loc) · 1001 Bytes
/
LayerStack.cpp
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
#include "LayerStack.h"
#include "logging.h"
namespace CC
{
LayerStack::LayerStack()
{
}
LayerStack::~LayerStack()
{
for (Layers* layer : m_Layers)
{
layer->OnDetach();
delete layer;
}
}
void LayerStack::PushLayer(Layers* layer)
{
m_Layers.emplace(m_Layers.begin() + m_LayerInsertIndex, layer);
m_LayerInsertIndex++;
}
void LayerStack::PushOverlay(Layers* overlay)
{
m_Layers.emplace_back(overlay);
LOGI("PushOverlay {}", m_Layers.size());
}
void LayerStack::PopLayer(Layers* layer)
{
auto it = std::find(m_Layers.begin(), m_Layers.begin() + m_LayerInsertIndex, layer);
if (it != m_Layers.begin() + m_LayerInsertIndex)
{
layer->OnDetach();
m_Layers.erase(it);
m_LayerInsertIndex--;
}
}
void LayerStack::PopOverlay(Layers* overlay)
{
auto it = std::find(m_Layers.begin() + m_LayerInsertIndex, m_Layers.end(), overlay);
if (it != m_Layers.end())
{
overlay->OnDetach();
m_Layers.erase(it);
}
}
}