common: fix compile warnings.
[platform/core/graphics/tizenvg.git] / src / lib / tvgSceneImpl.h
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_IMPL_H_
18 #define _TVG_SCENE_IMPL_H_
19
20 #include "tvgCommon.h"
21
22 /************************************************************************/
23 /* Internal Class Implementation                                        */
24 /************************************************************************/
25
26 struct Scene::Impl
27 {
28     vector<Paint*> paints;
29
30     bool dispose(RenderMethod& renderer)
31     {
32         for (auto paint : paints) {
33             paint->IMPL->dispose(renderer);
34             delete(paint);
35         }
36         paints.clear();
37
38         return true;
39     }
40
41     bool update(RenderMethod &renderer, const RenderTransform* transform, RenderUpdateFlag flag)
42     {
43         for(auto paint: paints) {
44             if (!paint->IMPL->update(renderer, transform, static_cast<uint32_t>(flag))) return false;
45         }
46         return true;
47     }
48
49     bool render(RenderMethod &renderer)
50     {
51         for(auto paint: paints) {
52             if(!paint->IMPL->render(renderer)) return false;
53         }
54         return true;
55     }
56
57     bool bounds(float* px, float* py, float* pw, float* ph)
58     {
59         auto x = FLT_MAX;
60         auto y = FLT_MAX;
61         auto w = 0.0f;
62         auto h = 0.0f;
63
64         for(auto paint: paints) {
65             auto x2 = FLT_MAX;
66             auto y2 = FLT_MAX;
67             auto w2 = 0.0f;
68             auto h2 = 0.0f;
69
70             if (paint->IMPL->bounds(&x2, &y2, &w2, &h2)) return false;
71
72             //Merge regions
73             if (x2 < x) x = x2;
74             if (x + w < x2 + w2) w = (x2 + w2) - x;
75             if (y2 < y) y = x2;
76             if (y + h < y2 + h2) h = (y2 + h2) - y;
77         }
78
79         if (px) *px = x;
80         if (py) *py = y;
81         if (pw) *pw = w;
82         if (ph) *ph = h;
83
84         return true;
85     }
86 };
87
88 #endif //_TVG_SCENE_IMPL_H_