Dali 3D User Interface Engine
separate-update-render-controller.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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 Adaptor
36 {
37 
40  mAdaptorInterfaces( adaptorInterfaces ),
41  mUpdateThread( NULL ),
42  mRenderThread( NULL ),
43  mVSyncNotifier( NULL ),
44  mThreadSync( NULL ),
45  mNumberOfVSyncsPerRender( environmentOptions.GetRenderRefreshRate() )
46 {
48 
49  mUpdateThread = new UpdateThread( *mThreadSync, adaptorInterfaces, environmentOptions );
50 
51  mRenderThread = new RenderThread( *mThreadSync, adaptorInterfaces, environmentOptions );
52 
53  mVSyncNotifier = new VSyncNotifier( *mThreadSync, adaptorInterfaces, environmentOptions );
54 
55  // Set the thread-synchronization interface on the render-surface
56  RenderSurface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
57  if( currentSurface )
58  {
59  currentSurface->SetThreadSynchronization( *mThreadSync );
60  }
61 }
62 
64 {
65  delete mVSyncNotifier;
66  delete mRenderThread;
67  delete mUpdateThread;
68  delete mThreadSync;
69 }
70 
72 {
73  // Notify the synchronization object before starting the threads
75 
76  // We want to the threads to be set up before they start
80 }
81 
83 {
84  mThreadSync->Start();
85 }
86 
88 {
89  mThreadSync->Pause();
90 }
91 
93 {
95 }
96 
98 {
99  // Notify the synchronization object before stopping the threads
100  mThreadSync->Stop();
101 
102  mVSyncNotifier->Stop();
103  mUpdateThread->Stop();
104  mRenderThread->Stop();
105 }
106 
108 {
110 }
111 
113 {
114  // if we are paused, need to allow one update
116 }
117 
118 void SeparateUpdateRenderController::ReplaceSurface( RenderSurface* newSurface )
119 {
120  // Set the thread-syncronization on the new surface
121  newSurface->SetThreadSynchronization( *mThreadSync );
122 
123  // tell render thread to start the replace. This call will block until the replace
124  // has completed.
125  RenderSurface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
126 
127  // Ensure the current surface releases any locks to prevent deadlock.
128  currentSurface->StopRender();
129 
130  mThreadSync->ReplaceSurface( newSurface );
131 }
132 
133 void SeparateUpdateRenderController::SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender )
134 {
135  mNumberOfVSyncsPerRender = numberOfVSyncsPerRender;
136  mThreadSync->SetRenderRefreshRate(numberOfVSyncsPerRender);
137 }
138 
139 } // namespace Adaptor
140 
141 } // namespace Internal
142 
143 } // namespace Dali
Dali Docs Home
Read more about Dali