common: code refactoring
[platform/core/graphics/tizenvg.git] / src / lib / tvgScene.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_SCENE_CPP_
18 #define _TVG_SCENE_CPP_
19
20 #include "tvgCommon.h"
21
22 /************************************************************************/
23 /* External Class Implementation                                        */
24 /************************************************************************/
25
26 Scene::Scene() : pImpl(make_unique<Impl>())
27 {
28     _id = PAINT_ID_SCENE;
29
30     Paint::pImpl.get()->ts = pImpl.get()->transformMethod();
31 }
32
33
34 Scene::~Scene()
35 {
36 }
37
38
39 unique_ptr<Scene> Scene::gen() noexcept
40 {
41     return unique_ptr<Scene>(new Scene);
42 }
43
44
45 Result Scene::push(unique_ptr<Paint> paint) noexcept
46 {
47     auto p = paint.release();
48     if (!p) return Result::MemoryCorruption;
49     IMPL->paints.push_back(p);
50
51     return Result::Success;
52 }
53
54
55 Result Scene::reserve(uint32_t size) noexcept
56 {
57     IMPL->paints.reserve(size);
58
59     return Result::Success;
60 }
61
62
63 Result Scene::load(const std::string& path) noexcept
64 {
65     if (path.empty()) return Result::InvalidArguments;
66
67      return IMPL->load(path);
68 }
69
70 #endif /* _TVG_SCENE_CPP_ */