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 )
37 TestApplication::TestApplication( bool initialize,
43 mSurfaceWidth( surfaceWidth ),
44 mSurfaceHeight( surfaceHeight ),
46 mDpi( horizontalDpi, verticalDpi )
54 void TestApplication::Initialize()
56 mCore = Dali::Integration::Core::New(
63 mCore->ContextCreated();
64 mCore->SurfaceResized( mSurfaceWidth, mSurfaceHeight );
65 mCore->SetDpi( mDpi.x, mDpi.y );
67 Dali::Integration::Log::LogFunction logFunction(&TestApplication::LogMessage);
68 Dali::Integration::Log::InstallLogFunction(logFunction);
71 TestApplication::~TestApplication()
73 Dali::Integration::Log::UninstallLogFunction();
77 void TestApplication::LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message)
81 case Dali::Integration::Log::DebugInfo:
82 fprintf(stderr, "INFO: %s", message.c_str());
84 case Dali::Integration::Log::DebugWarning:
85 fprintf(stderr, "WARN: %s", message.c_str());
87 case Dali::Integration::Log::DebugError:
88 fprintf(stderr, "ERROR: %s", message.c_str());
91 fprintf(stderr, "DEFAULT: %s", message.c_str());
96 Dali::Integration::Core& TestApplication::GetCore()
101 TestPlatformAbstraction& TestApplication::GetPlatform()
103 return mPlatformAbstraction;
106 TestRenderController& TestApplication::GetRenderController()
108 return mRenderController;
111 TestGlAbstraction& TestApplication::GetGlAbstraction()
113 return mGlAbstraction;
116 TestGlSyncAbstraction& TestApplication::GetGlSyncAbstraction()
118 return mGlSyncAbstraction;
121 TestGestureManager& TestApplication::GetGestureManager()
123 return mGestureManager;
126 void TestApplication::ProcessEvent(const Integration::Event& event)
128 mCore->QueueEvent(event);
129 mCore->ProcessEvents();
132 void TestApplication::SendNotification()
134 mCore->ProcessEvents();
137 void TestApplication::SetSurfaceWidth( unsigned int width, unsigned height )
139 mSurfaceWidth = width;
140 mSurfaceHeight = height;
142 mCore->SurfaceResized( mSurfaceWidth, mSurfaceHeight );
145 bool TestApplication::Render( unsigned int intervalMilliseconds )
147 // Update Time values
148 mPlatformAbstraction.IncrementGetTimeResult( intervalMilliseconds );
149 unsigned int seconds(0u), microseconds(0u);
150 mPlatformAbstraction.GetTimeMicroseconds( seconds, microseconds );
152 mCore->VSync( mFrame, seconds, microseconds );
153 mCore->Update( mStatus );
154 mCore->Render( mRenderStatus );
158 return mStatus.KeepUpdating() || mRenderStatus.NeedsUpdate();
161 unsigned int TestApplication::GetUpdateStatus()
163 return mStatus.KeepUpdating();
166 bool TestApplication::UpdateOnly( unsigned int intervalMilliseconds )
168 // Update Time values
169 mPlatformAbstraction.IncrementGetTimeResult( intervalMilliseconds );
170 unsigned int seconds(0u), microseconds(0u);
171 mPlatformAbstraction.GetTimeMicroseconds( seconds, microseconds );
173 mCore->VSync( mFrame, seconds, microseconds );
174 mCore->Update( mStatus );
176 return mStatus.KeepUpdating();
179 bool TestApplication::RenderOnly( )
181 // Update Time values
182 mCore->Render( mRenderStatus );
186 return mRenderStatus.NeedsUpdate();
189 void TestApplication::ResetContext()
191 mCore->ContextToBeDestroyed();
192 mCore->ContextCreated();