2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 #include "tvgCommon.h"
23 #include "tvgLoaderMgr.h"
25 #ifdef THORVG_SW_RASTER_SUPPORT
26 #include "tvgSwRenderer.h"
29 #ifdef THORVG_GL_RASTER_SUPPORT
30 #include "tvgGlRenderer.h"
34 /************************************************************************/
35 /* Internal Class Implementation */
36 /************************************************************************/
39 /************************************************************************/
40 /* External Class Implementation */
41 /************************************************************************/
43 Result Initializer::init(CanvasEngine engine, uint32_t threads) noexcept
45 auto nonSupport = true;
47 if (engine == CanvasEngine::Sw) {
48 #ifdef THORVG_SW_RASTER_SUPPORT
49 if (!SwRenderer::init()) return Result::InsufficientCondition;
52 } else if (engine == CanvasEngine::Gl) {
53 #ifdef THORVG_GL_RASTER_SUPPORT
54 if (!GlRenderer::init()) return Result::InsufficientCondition;
58 return Result::InvalidArguments;
61 if (nonSupport) return Result::NonSupport;
63 if (!LoaderMgr::init()) return Result::Unknown;
65 TaskScheduler::init(threads);
67 return Result::Success;
71 Result Initializer::term(CanvasEngine engine) noexcept
73 auto nonSupport = true;
75 if (engine == CanvasEngine::Sw) {
76 #ifdef THORVG_SW_RASTER_SUPPORT
77 if (!SwRenderer::term()) return Result::InsufficientCondition;
80 } else if (engine == CanvasEngine::Gl) {
81 #ifdef THORVG_GL_RASTER_SUPPORT
82 if (!GlRenderer::term()) return Result::InsufficientCondition;
86 return Result::InvalidArguments;
89 if (nonSupport) return Result::NonSupport;
91 TaskScheduler::term();
93 if (!LoaderMgr::term()) return Result::Unknown;
95 return Result::Success;