Dali 3D User Interface Engine
notification-manager.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 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 
18 // CLASS HEADER
20 
21 // INTERNAL INCLUDES
28 
29 namespace Dali
30 {
31 
32 namespace Internal
33 {
34 
35 namespace
36 {
38 
44 void MoveElements( InterfaceContainer& from, InterfaceContainer& to )
45 {
46  // check if there's something in from
47  const InterfaceContainer::SizeType fromCount = from.Count();
48  if( fromCount > 0u )
49  {
50  // check if to has some elements
51  const InterfaceContainer::SizeType toCount = to.Count();
52  if( toCount == 0u )
53  {
54  // to is empty so we can swap with from
55  to.Swap( from );
56  }
57  else
58  {
59  to.Reserve( toCount + fromCount );
60  for( InterfaceContainer::SizeType i = 0; i < fromCount; ++i )
61  {
62  to.PushBack( from[ i ] );
63  }
64  from.Clear();
65  }
66  }
67 }
68 }
69 
72 
74 {
75  Impl()
76  {
77  // reserve space on the vectors to avoid reallocs
78  // applications typically have up-to 20-30 notifications at startup
82 
83  // only a few manager objects get complete notifications (animation, render list, property notifications, ...)
84  updateCompletedInterfaceQueue.Reserve( 4 );
85  updateWorkingInterfaceQueue.Reserve( 4 );
86  eventInterfaceQueue.Reserve( 4 );
87  }
88 
90  {
91  }
92 
93  // queueMutex must be locked whilst accessing queue
95  // three queues for objects owned by notification manager
99  // three queues for objects referenced by notification manager
103 };
104 
106 {
107  mImpl = new Impl();
108 }
109 
111 {
112  delete mImpl;
113 }
114 
116 {
117  // queueMutex must be locked whilst accessing queues
119 
120  mImpl->updateWorkingInterfaceQueue.PushBack( instance );
121 }
122 
124 {
125  DALI_ASSERT_DEBUG( NULL != message );
126 
127  // queueMutex must be locked whilst accessing queues
129 
131 }
132 
134 {
135  // queueMutex must be locked whilst accessing queues
137  // Move messages from update working queue to completed queue
138  // note that in theory its possible for update completed to have last frames
139  // events as well still hanging around. we need to keep them as well
141  // move pointers from interface queue
143  // finally the lock is released
144 }
145 
147 {
148  // queueMutex must be locked whilst accessing queues
150 
151  return ( 0u < mImpl->updateCompletedMessageQueue.Count() ||
152  ( 0u < mImpl->updateCompletedInterfaceQueue.Count() ) );
153 }
154 
156 {
157  // queueMutex must be locked whilst accessing queues
158  {
160 
161  // Move messages from update completed queue to event queue
162  // note that in theory its possible for event queue to have
163  // last frames events as well still hanging around so need to keep them
166  }
167  // end of scope, lock is released
168 
171  for( ; iter != end; ++iter )
172  {
173  (*iter)->Process( 0u/*ignored*/ );
174  }
175  // release the processed messages from event side queue
177 
178  InterfaceContainer::Iterator iter2 = mImpl->eventInterfaceQueue.Begin();
179  const InterfaceContainer::Iterator end2 = mImpl->eventInterfaceQueue.End();
180  for( ; iter2 != end2; ++iter2 )
181  {
182  CompleteNotificationInterface* interface = *iter2;
183  if( interface )
184  {
185  interface->NotifyCompleted();
186  }
187  }
188  // just clear the container, we dont own the objects
189  mImpl->eventInterfaceQueue.Clear();
190 }
191 
192 } // namespace Internal
193 
194 } // namespace Dali
Dali Docs Home
Read more about Dali