2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include "test-application.h"
24 TestApplication::TestApplication( size_t surfaceWidth,
29 mSurfaceWidth( surfaceWidth ),
30 mSurfaceHeight( surfaceHeight ),
32 mDpi( horizontalDpi, verticalDpi ),
38 TestApplication::TestApplication( bool initialize,
44 mSurfaceWidth( surfaceWidth ),
45 mSurfaceHeight( surfaceHeight ),
47 mDpi( horizontalDpi, verticalDpi )
55 void TestApplication::Initialize()
57 mCore = Dali::Integration::Core::New(
64 mCore->ContextCreated();
65 mCore->SurfaceResized( mSurfaceWidth, mSurfaceHeight );
66 mCore->SetDpi( mDpi.x, mDpi.y );
68 Dali::Integration::Log::LogFunction logFunction(&TestApplication::LogMessage);
69 Dali::Integration::Log::InstallLogFunction(logFunction);
72 TestApplication::~TestApplication()
74 Dali::Integration::Log::UninstallLogFunction();
78 void TestApplication::LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message)
82 case Dali::Integration::Log::DebugInfo:
83 fprintf(stderr, "INFO: %s", message.c_str());
85 case Dali::Integration::Log::DebugWarning:
86 fprintf(stderr, "WARN: %s", message.c_str());
88 case Dali::Integration::Log::DebugError:
89 fprintf(stderr, "ERROR: %s", message.c_str());
92 fprintf(stderr, "DEFAULT: %s", message.c_str());
97 Dali::Integration::Core& TestApplication::GetCore()
102 TestPlatformAbstraction& TestApplication::GetPlatform()
104 return mPlatformAbstraction;
107 TestRenderController& TestApplication::GetRenderController()
109 return mRenderController;
112 TestGlAbstraction& TestApplication::GetGlAbstraction()
114 return mGlAbstraction;
117 TestGlSyncAbstraction& TestApplication::GetGlSyncAbstraction()
119 return mGlSyncAbstraction;
122 TestGestureManager& TestApplication::GetGestureManager()
124 return mGestureManager;
127 void TestApplication::ProcessEvent(const Integration::Event& event)
129 mCore->QueueEvent(event);
130 mCore->ProcessEvents();
133 void TestApplication::SendNotification()
135 mCore->ProcessEvents();
138 void TestApplication::SetSurfaceWidth( unsigned int width, unsigned height )
140 mSurfaceWidth = width;
141 mSurfaceHeight = height;
143 mCore->SurfaceResized( mSurfaceWidth, mSurfaceHeight );
146 void TestApplication::DoUpdate( unsigned int intervalMilliseconds )
148 unsigned int seconds(0u), microseconds(0u);
149 mPlatformAbstraction.GetTimeMicroseconds( seconds, microseconds );
150 mLastVSyncTime = ( seconds * 1e3 ) + ( microseconds / 1e3 );
151 unsigned int nextVSyncTime = mLastVSyncTime + 16;
153 // Update Time values
154 mPlatformAbstraction.IncrementGetTimeResult( intervalMilliseconds );
156 float elapsedSeconds = intervalMilliseconds / 1e3f;
157 mCore->Update( elapsedSeconds, mLastVSyncTime, nextVSyncTime, mStatus );
160 bool TestApplication::Render( unsigned int intervalMilliseconds )
162 DoUpdate( intervalMilliseconds );
163 mCore->Render( mRenderStatus );
167 return mStatus.KeepUpdating() || mRenderStatus.NeedsUpdate();
170 unsigned int TestApplication::GetUpdateStatus()
172 return mStatus.KeepUpdating();
175 bool TestApplication::UpdateOnly( unsigned int intervalMilliseconds )
177 DoUpdate( intervalMilliseconds );
178 return mStatus.KeepUpdating();
181 bool TestApplication::RenderOnly( )
183 // Update Time values
184 mCore->Render( mRenderStatus );
188 return mRenderStatus.NeedsUpdate();
191 void TestApplication::ResetContext()
193 mCore->ContextToBeDestroyed();
194 mCore->ContextCreated();