857698d267bf4c0c76809d36ac20076f9fabf7e1
[platform/core/graphics/tizenvg.git] / src / lib / tvgInitializer.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
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 #ifndef _TVG_INITIALIZER_CPP_
18 #define _TVG_INITIALIZER_CPP_
19
20 #include "tvgCommon.h"
21 #include "tvgSwRenderer.h"
22 #include "tvgGlRenderer.h"
23 #include "tvgLoaderMgr.h"
24
25 /************************************************************************/
26 /* Internal Class Implementation                                        */
27 /************************************************************************/
28
29 /************************************************************************/
30 /* External Class Implementation                                        */
31 /************************************************************************/
32
33 Result Initializer::init(CanvasEngine engine) noexcept
34 {
35     if (engine == CanvasEngine::Sw) {
36         if (!SwRenderer::init()) return Result::InsufficientCondition;
37     } else if (engine == CanvasEngine::Gl) {
38         if (!GlRenderer::init()) return Result::InsufficientCondition;
39     } else {
40         return Result::InvalidArguments;
41     }
42
43     if (!LoaderMgr::init()) return Result::Unknown;
44
45     return Result::Success;
46 }
47
48
49 Result Initializer::term(CanvasEngine engine) noexcept
50 {
51     //TODO: deinitialize modules
52
53     if (engine == CanvasEngine::Sw) {
54         if (!SwRenderer::term()) return Result::InsufficientCondition;
55     } else if (engine == CanvasEngine::Gl) {
56         if (!GlRenderer::term()) return Result::InsufficientCondition;
57     } else {
58         return Result::InvalidArguments;
59     }
60
61     if (!LoaderMgr::term()) return Result::Unknown;
62
63     return Result::Success;
64 }
65
66 #endif /* _TVG_INITIALIZER_CPP_ */