2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
17 #include "test-application.h"
23 TestApplication::TestApplication( size_t surfaceWidth,
28 mSurfaceWidth( surfaceWidth ),
29 mSurfaceHeight( surfaceHeight ),
31 mDpi( horizontalDpi, verticalDpi )
36 TestApplication::TestApplication( bool initialize,
42 mSurfaceWidth( surfaceWidth ),
43 mSurfaceHeight( surfaceHeight ),
45 mDpi( horizontalDpi, verticalDpi )
53 void TestApplication::Initialize()
55 mCore = Dali::Integration::Core::New(
62 mCore->ContextCreated();
63 mCore->SurfaceResized( mSurfaceWidth, mSurfaceHeight );
64 mCore->SetDpi( mDpi.x, mDpi.y );
66 Dali::Integration::Log::LogFunction logFunction(&TestApplication::LogMessage);
67 Dali::Integration::Log::InstallLogFunction(logFunction);
70 TestApplication::~TestApplication()
72 Dali::Integration::Log::UninstallLogFunction();
76 void TestApplication::LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message)
80 case Dali::Integration::Log::DebugInfo:
81 fprintf(stderr, "INFO: %s", message.c_str());
83 case Dali::Integration::Log::DebugWarning:
84 fprintf(stderr, "WARN: %s", message.c_str());
86 case Dali::Integration::Log::DebugError:
87 fprintf(stderr, "ERROR: %s", message.c_str());
90 fprintf(stderr, "DEFAULT: %s", message.c_str());
95 Dali::Integration::Core& TestApplication::GetCore()
100 TestPlatformAbstraction& TestApplication::GetPlatform()
102 return mPlatformAbstraction;
105 TestRenderController& TestApplication::GetRenderController()
107 return mRenderController;
110 TestGlAbstraction& TestApplication::GetGlAbstraction()
112 return mGlAbstraction;
115 TestGlSyncAbstraction& TestApplication::GetGlSyncAbstraction()
117 return mGlSyncAbstraction;
120 TestGestureManager& TestApplication::GetGestureManager()
122 return mGestureManager;
125 void TestApplication::ProcessEvent(const Integration::Event& event)
127 mCore->QueueEvent(event);
128 mCore->ProcessEvents();
131 void TestApplication::SendNotification()
133 mCore->ProcessEvents();
136 void TestApplication::SetSurfaceWidth( unsigned int width, unsigned height )
138 mSurfaceWidth = width;
139 mSurfaceHeight = height;
141 mCore->SurfaceResized( mSurfaceWidth, mSurfaceHeight );
144 bool TestApplication::Render( unsigned int intervalMilliseconds )
146 // Update Time values
147 mPlatformAbstraction.IncrementGetTimeResult( intervalMilliseconds );
148 unsigned int seconds(0u), microseconds(0u);
149 mPlatformAbstraction.GetTimeMicroseconds( seconds, microseconds );
151 mCore->VSync( mFrame, seconds, microseconds );
152 mCore->Update( mStatus );
153 mCore->Render( mRenderStatus );
157 return mStatus.KeepUpdating() || mRenderStatus.NeedsUpdate();
160 unsigned int TestApplication::GetUpdateStatus()
162 return mStatus.KeepUpdating();
165 bool TestApplication::UpdateOnly( unsigned int intervalMilliseconds )
167 // Update Time values
168 mPlatformAbstraction.IncrementGetTimeResult( intervalMilliseconds );
169 unsigned int seconds(0u), microseconds(0u);
170 mPlatformAbstraction.GetTimeMicroseconds( seconds, microseconds );
172 mCore->VSync( mFrame, seconds, microseconds );
173 mCore->Update( mStatus );
175 return mStatus.KeepUpdating();
178 bool TestApplication::RenderOnly( )
180 // Update Time values
181 mCore->Render( mRenderStatus );
185 return mRenderStatus.NeedsUpdate();
188 void TestApplication::ResetContext()
190 mCore->ContextToBeDestroyed();
191 mCore->ContextCreated();