Fixed SVACE and related issues in dali-scene-loader.
[platform/core/uifw/dali-toolkit.git] / dali-scene-loader / public-api / matrix-stack.cpp
1 /*
2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17 #include "dali-scene-loader/public-api/matrix-stack.h"
18 #include "dali-scene-loader/public-api/utils.h"
19
20 namespace Dali
21 {
22 namespace SceneLoader
23 {
24
25 MatrixStack::MatrixStack()
26 {
27   mStack.reserve(16);
28 }
29
30 bool MatrixStack::IsEmpty() const
31 {
32   return mStack.empty();
33 }
34
35 void MatrixStack::Push(const Matrix& model)
36 {
37   if (mStack.empty())
38   {
39     mStack.push_back(model);
40   }
41   else
42   {
43     Matrix m{ false };
44     Matrix::Multiply(m, model, mStack.back());
45     mStack.push_back(m);
46   }
47 }
48
49 const Matrix& MatrixStack::Top() const
50 {
51   return mStack.back();
52 }
53
54 void MatrixStack::Pop()
55 {
56   DALI_ASSERT_ALWAYS(mStack.size() > 0);
57   mStack.pop_back();
58 }
59
60 void MatrixStack::PopAll()
61 {
62   mStack.clear();
63 }
64
65 }
66 }