(Partial Update) Change damaged rect calcutation
[platform/core/uifw/dali-core.git] / dali / internal / update / common / collected-uniform-map.cpp
1 /*
2  * Copyright (c) 2022 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 // CLASS HEADER
18 #include <dali/internal/update/common/collected-uniform-map.h>
19
20 // INTERNAL HEADERS
21 #include <dali/devel-api/common/hash.h>
22 #include <dali/internal/render/data-providers/uniform-map-data-provider.h>
23
24 // EXTERNAL HEADERS
25 #include <algorithm>
26
27 namespace Dali
28 {
29 namespace Internal
30 {
31 namespace SceneGraph
32 {
33 void CollectedUniformMap::AddMappings(const UniformMap& uniformMap)
34 {
35   // Iterate thru uniformMap.
36   // Any maps that aren't in localMap should be added in a single step
37
38   // keep a static vector to avoid temporary heap allocation.
39   // As this function gets called only from update thread we don't have to
40   // make it thread safe (so no need to keep a thread_local variable).
41   static Dali::Vector<UniformPropertyMapping> newUniformMappings;
42
43   newUniformMappings.Clear();
44
45   for(UniformMap::SizeType i = 0, iCount = uniformMap.Count(); i < iCount; ++i)
46   {
47     bool found = false;
48
49     for(UniformMap::SizeType j = 0, jCount = mUniformMap.Count(); j < jCount; ++j)
50     {
51       if(mUniformMap[j].uniformName == uniformMap[i].uniformName)
52       {
53         found = true;
54         break;
55       }
56     }
57     if(!found)
58     {
59       newUniformMappings.PushBack(uniformMap[i]);
60     }
61   }
62
63   if(newUniformMappings.Count() > 0)
64   {
65     mUniformMap.Reserve(mUniformMap.Count() + newUniformMappings.Count());
66
67     for(UniformMap::SizeType i = 0, iCount = newUniformMappings.Count(); i < iCount; ++i)
68     {
69       mUniformMap.PushBack(newUniformMappings[i]);
70     }
71   }
72 }
73
74 } // namespace SceneGraph
75 } // namespace Internal
76 } // namespace Dali