Dali 3D User Interface Engine
combined-update-render-controller.h
Go to the documentation of this file.
1 #ifndef __DALI_INTERNAL_COMBINED_UPDATE_RENDER_CONTROLLER_H__
2 #define __DALI_INTERNAL_COMBINED_UPDATE_RENDER_CONTROLLER_H__
3 
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20 
21 // EXTERNAL INCLUDES
22 #include <semaphore.h>
23 #include <stdint.h>
26 
27 // INTERNAL INCLUDES
28 #include <integration-api/thread-synchronization-interface.h>
30 #include <base/fps-tracker.h>
31 #include <base/render-helper.h>
34 
35 namespace Dali
36 {
37 
38 class RenderSurface;
39 class TriggerEventInterface;
40 
41 namespace Internal
42 {
43 
44 namespace Adaptor
45 {
46 
47 class AdaptorInternalServices;
48 class EnvironmentOptions;
49 
74  public ThreadSynchronizationInterface
75 {
76 public:
77 
81  CombinedUpdateRenderController( AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions );
82 
87 
91  virtual void Initialize();
92 
96  virtual void Start();
97 
101  virtual void Pause();
102 
106  virtual void Resume();
107 
111  virtual void Stop();
112 
116  virtual void RequestUpdate();
117 
121  virtual void RequestUpdateOnce();
122 
126  virtual void ReplaceSurface( RenderSurface* surface );
127 
131  virtual void SetRenderRefreshRate( unsigned int numberOfFramesPerRender );
132 
133 private:
134 
135  // Undefined copy constructor.
137 
138  // Undefined assignment operator.
140 
142  // EventThread
144 
152  inline void RunUpdateRenderThread( int numberOfCycles, bool useElapsedTimeAfterWait );
153 
158  inline void PauseUpdateRenderThread();
159 
166  inline void StopUpdateRenderThread();
167 
174  inline bool IsUpdateRenderThreadPaused();
175 
181  void ProcessSleepRequest();
182 
184  // UpdateRenderThread
186 
190  void UpdateRenderThread();
191 
200  bool UpdateRenderReady( bool& useElapsedTime, bool updateRequired );
201 
208  RenderSurface* ShouldSurfaceBeReplaced();
209 
215  void SurfaceReplaced();
216 
221  static void* InternalUpdateRenderThreadEntryFunc( void* This )
222  {
223  ( static_cast<CombinedUpdateRenderController*>( This ) )->UpdateRenderThread();
224  return NULL;
225  }
226 
228  // ALL Threads
230 
237 
243 
245  // POST RENDERING - ThreadSynchronizationInterface overrides
247 
251 
255  virtual void PostRenderComplete();
256 
260 
264  virtual void PostRenderStarted();
265 
269  virtual void PostRenderWaitForCompletion();
270 
271 private:
272 
275 
277 
279 
281 
286  TriggerEventInterface& mNotificationTrigger;
287  TriggerEventInterface* mSleepTrigger;
288 
289  pthread_t* mUpdateRenderThread;
290 
295 
296  unsigned int mUpdateRequestCount;
297  unsigned int mRunning;
298 
299  //
300  // NOTE: cannot use booleans as these are used from multiple threads, must use variable with machine word size for atomic read/write
301  //
302 
303  volatile int mUpdateRenderRunCount;
304  volatile unsigned int mDestroyUpdateRenderThread;
305  volatile unsigned int mUpdateRenderThreadCanSleep;
306  volatile unsigned int mPendingRequestUpdate;
307 
308 
309  volatile unsigned int mUseElapsedTimeAfterWait;
310 
311  RenderSurface* volatile mNewSurface;
312 
313  volatile unsigned int mPostRendering;
314 };
315 
316 } // namespace Adaptor
317 
318 } // namespace Internal
319 
320 } // namespace Dali
321 
322 #endif // __DALI_INTERNAL_COMBINED_UPDATE_RENDER_CONTROLLER_H__
Dali Docs Home
Read more about Dali