Dali 3D User Interface Engine
test-application.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 #include "test-application.h"
19 
20 namespace Dali
21 {
22 
23 
24 TestApplication::TestApplication( size_t surfaceWidth,
25  size_t surfaceHeight,
26  float horizontalDpi,
27  float verticalDpi,
29 : mCore( NULL ),
30  mSurfaceWidth( surfaceWidth ),
31  mSurfaceHeight( surfaceHeight ),
32  mFrame( 0u ),
33  mDpi( horizontalDpi, verticalDpi ),
34  mLastVSyncTime(0u),
35  mDataRetentionPolicy( policy )
36 {
37  Initialize();
38 }
39 
41  size_t surfaceWidth,
42  size_t surfaceHeight,
43  float horizontalDpi,
44  float verticalDpi,
46 : mCore( NULL ),
47  mSurfaceWidth( surfaceWidth ),
48  mSurfaceHeight( surfaceHeight ),
49  mFrame( 0u ),
50  mDpi( horizontalDpi, verticalDpi ),
51  mLastVSyncTime(0u),
52  mDataRetentionPolicy( policy )
53 {
54  if ( initialize )
55  {
56  Initialize();
57  }
58 }
59 
61 {
62  // We always need the first update!
64 
72 
75  mCore->SetDpi( mDpi.x, mDpi.y );
76 
79 
81 }
82 
84 {
86  delete mCore;
87 }
88 
90 {
91  switch(level)
92  {
94  fprintf(stderr, "INFO: %s", message.c_str());
95  break;
97  fprintf(stderr, "WARN: %s", message.c_str());
98  break;
100  fprintf(stderr, "ERROR: %s", message.c_str());
101  break;
102  default:
103  fprintf(stderr, "DEFAULT: %s", message.c_str());
104  break;
105  }
106 }
107 
109 {
110  return *mCore;
111 }
112 
114 {
115  return mPlatformAbstraction;
116 }
117 
119 {
120  return mRenderController;
121 }
122 
124 {
125  return mGlAbstraction;
126 }
127 
129 {
130  return mGlSyncAbstraction;
131 }
132 
134 {
135  return mGestureManager;
136 }
137 
138 void TestApplication::ProcessEvent(const Integration::Event& event)
139 {
140  mCore->QueueEvent(event);
141  mCore->ProcessEvents();
142 }
143 
145 {
146  mCore->ProcessEvents();
147 }
148 
149 void TestApplication::SetSurfaceWidth( unsigned int width, unsigned height )
150 {
153 
155 }
156 
157 void TestApplication::DoUpdate( unsigned int intervalMilliseconds )
158 {
159  if( GetUpdateStatus() == 0 &&
160  mRenderStatus.NeedsUpdate() == false &&
162  {
163  fprintf(stderr, "WARNING - Update not required\n");
164  }
165 
166  unsigned int nextVSyncTime = mLastVSyncTime + intervalMilliseconds;
167  float elapsedSeconds = intervalMilliseconds / 1e3f;
168 
169  mCore->Update( elapsedSeconds, mLastVSyncTime, nextVSyncTime, mStatus );
170 
172 
173  mLastVSyncTime = nextVSyncTime;
174 }
175 
176 bool TestApplication::Render( unsigned int intervalMilliseconds )
177 {
178  DoUpdate( intervalMilliseconds );
180 
181  mFrame++;
182 
184 }
185 
187 {
188  return mStatus.KeepUpdating();
189 }
190 
191 bool TestApplication::UpdateOnly( unsigned int intervalMilliseconds )
192 {
193  DoUpdate( intervalMilliseconds );
194  return mStatus.KeepUpdating();
195 }
196 
198 {
199  return mRenderStatus.NeedsUpdate();
200 }
202 {
203  return mRenderStatus.HasRendered();
204 }
205 
207 {
208  // Update Time values
210 
211  mFrame++;
212 
213  return mRenderStatus.NeedsUpdate();
214 }
215 
217 {
220 }
221 
222 
223 } // Namespace dali
Dali Docs Home
Read more about Dali