$(base_adaptor_src_dir)/fps-tracker.cpp \
$(base_adaptor_src_dir)/render-helper.cpp \
$(base_adaptor_src_dir)/thread-controller.cpp \
+ $(base_adaptor_src_dir)/time-service.cpp \
$(base_adaptor_src_dir)/update-status-logger.cpp \
$(base_adaptor_src_dir)/performance-logging/frame-time-stamp.cpp \
$(base_adaptor_src_dir)/performance-logging/frame-time-stats.cpp \
// CLASS HEADER
#include "frame-time-stamp.h"
-namespace
-{
-const unsigned int MICROSECONDS_PER_SECOND = 1000000; ///< 1000000 microseconds per second
-}
-
namespace Dali
{
FrameTimeStamp::FrameTimeStamp()
: frame(0),
- seconds(0),
microseconds(0),
bufferIndex(0)
{
}
FrameTimeStamp::FrameTimeStamp(unsigned int frame,
- unsigned int seconds,
- unsigned int microseconds,
+ uint64_t microseconds,
unsigned int bufferIndex)
: frame( frame ),
- seconds( seconds ),
microseconds( microseconds ),
bufferIndex( bufferIndex )
{
}
-FrameTimeStamp::FrameTimeStamp(unsigned int bufferIndex )
+FrameTimeStamp::FrameTimeStamp( unsigned int bufferIndex )
: frame( 0 ),
- seconds( 0 ),
microseconds( 0 ),
bufferIndex( bufferIndex )
{
unsigned int FrameTimeStamp::MicrosecondDiff( const FrameTimeStamp& start,const FrameTimeStamp& end )
{
- int microDiff = end.microseconds - start.microseconds;
- unsigned int secDiff = ( end.seconds - start.seconds ) * MICROSECONDS_PER_SECOND;
- return ( microDiff + secDiff);
+ return end.microseconds - start.microseconds;
}
} // namespace Adaptor
*
*/
+// EXTERNAL INCLUDES
+#include <stdint.h>
+
namespace Dali
{
/**
* Constructor
* @param frame the frame number
- * @param second the seconds from a monotonic clock
- * @param microseconds the microseconds from a monotonic clock
+ * @param microseconds the time from a monotonic clock
* @param bufferIndex double buffered index used for performing an update / render
*/
- FrameTimeStamp( unsigned int frame, unsigned int seconds,unsigned int microseconds, unsigned int bufferIndex = BUFFER_NOT_USED );
+ FrameTimeStamp( unsigned int frame, uint64_t microseconds, unsigned int bufferIndex = BUFFER_NOT_USED );
/**
* Constructor
static unsigned int MicrosecondDiff( const FrameTimeStamp& start,const FrameTimeStamp& end );
unsigned int frame; ///< Frame number ( not always available)
- unsigned int seconds; ///< Second time stamp
- unsigned int microseconds; ///< Microsecond time stamp
+ uint64_t microseconds; ///< Microsecond time stamp
unsigned int bufferIndex; ///< The double buffered index used for performing an update / render
};
} // namespace Adaptor
namespace
{
+const float MICROSECONDS_TO_SECOND = 1e-6;
const char UNKNOWN_CMD[]= "Command or parameter invalid, type help for list of commands\n";
{
// write out the time stamp
char buffer[64];
- int size = snprintf( buffer, sizeof(buffer),"%d.%06d (seconds), %s\n",
- marker.GetTimeStamp().seconds,
- marker.GetTimeStamp().microseconds,
+ int size = snprintf( buffer, sizeof(buffer),"%.6f (seconds), %s\n",
+ (float)( marker.GetTimeStamp().microseconds * MICROSECONDS_TO_SECOND ),
description );
return mSocket->Write( buffer, size );
// INTERNAL INCLUDES
#include <base/environment-options.h>
+#include <base/time-service.h>
namespace Dali
{
namespace Adaptor
{
+namespace
+{
+const unsigned int NANOSECONDS_PER_MICROSECOND = 1000u;
+const float MICROSECONDS_TO_SECOND = 1e-6;
+} // unnamed namespace
+
PerformanceServer::PerformanceServer( AdaptorInternalServices& adaptorServices,
const EnvironmentOptions& environmentOptions)
-:mPlatformAbstraction( adaptorServices.GetPlatformAbstractionInterface() ),
- mEnvironmentOptions( environmentOptions ),
- mKernelTrace( adaptorServices.GetKernelTraceInterface() ),
- mSystemTrace( adaptorServices.GetSystemTraceInterface() ),
- mNetworkServer( adaptorServices, environmentOptions ),
- mStatContextManager( *this ),
- mStatisticsLogBitmask( 0 ),
- mNetworkControlEnabled( mEnvironmentOptions.GetNetworkControlMode()),
- mLoggingEnabled( false ),
- mLogFunctionInstalled( false )
+: mEnvironmentOptions( environmentOptions ),
+ mKernelTrace( adaptorServices.GetKernelTraceInterface() ),
+ mSystemTrace( adaptorServices.GetSystemTraceInterface() ),
+ mNetworkServer( adaptorServices, environmentOptions ),
+ mStatContextManager( *this ),
+ mStatisticsLogBitmask( 0 ),
+ mNetworkControlEnabled( mEnvironmentOptions.GetNetworkControlMode()),
+ mLoggingEnabled( false ),
+ mLogFunctionInstalled( false )
{
SetLogging( mEnvironmentOptions.GetPerformanceStatsLoggingOptions(),
mEnvironmentOptions.GetPerformanceTimeStampOutput(),
}
// Get the time stamp
- unsigned int seconds = 0;
- unsigned int microseconds = 0;
- mPlatformAbstraction.GetTimeMicroseconds( seconds, microseconds );
+ uint64_t timeStamp = 0;
+ TimeService::GetNanoseconds( timeStamp );
+ timeStamp /= NANOSECONDS_PER_MICROSECOND; // Convert to microseconds
// Create a marker
- PerformanceMarker marker( markerType, FrameTimeStamp( 0, seconds, microseconds ) );
+ PerformanceMarker marker( markerType, FrameTimeStamp( 0, timeStamp ) );
// get the marker description for this context, e.g SIZE_NEGOTIATION_START
const char* const description = mStatContextManager.GetMarkerDescription( markerType, contextId );
}
// Get the time
- unsigned int seconds = 0;
- unsigned int microseconds = 0;
- mPlatformAbstraction.GetTimeMicroseconds( seconds, microseconds );
+ uint64_t timeStamp = 0;
+ TimeService::GetNanoseconds( timeStamp );
+ timeStamp /= NANOSECONDS_PER_MICROSECOND; // Convert to microseconds
// Create a marker
- PerformanceMarker marker( markerType, FrameTimeStamp( 0, seconds, microseconds ) );
+ PerformanceMarker marker( markerType, FrameTimeStamp( 0, timeStamp ) );
// log it
LogMarker(marker, marker.GetName() );
if ( mPerformanceOutputBitmask & OUTPUT_DALI_LOG )
{
Integration::Log::LogMessage( Dali::Integration::Log::DebugInfo,
- "%d.%06d (seconds), %s\n",
- marker.GetTimeStamp().seconds,
- marker.GetTimeStamp().microseconds,
+ "%.6f (seconds), %s\n",
+ (float)( marker.GetTimeStamp().microseconds * MICROSECONDS_TO_SECOND ),
description);
}
}
private:
- Integration::PlatformAbstraction& mPlatformAbstraction; ///< platform abstraction
const EnvironmentOptions& mEnvironmentOptions; ///< environment options
TraceInterface& mKernelTrace; ///< kernel trace interface
TraceInterface& mSystemTrace; ///< system trace interface
#include <dali/integration-api/debug.h>
#include <dali/integration-api/platform-abstraction.h>
+// INTERNAL INCLUDES
+#include <base/time-service.h>
+
namespace Dali
{
} // unnamed namespace
-FrameTime::FrameTime( PlatformAbstraction& platform )
-: mPlatform( platform ),
- mMinimumFrameTimeInterval( DEFAULT_MINIMUM_FRAME_TIME_INTERVAL ),
+FrameTime::FrameTime()
+: mMinimumFrameTimeInterval( DEFAULT_MINIMUM_FRAME_TIME_INTERVAL ),
mLastSyncTime( 0u ),
mLastSyncTimeAtUpdate( 0u ),
mLastSyncFrameNumber( 0u ),
inline void FrameTime::SetLastSyncTime()
{
- uint64_t seconds( 0u );
uint64_t nanoseconds( 0u );
+ TimeService::GetNanoseconds( nanoseconds );
- mPlatform.GetTimeNanoseconds( seconds, nanoseconds );
-
- mLastSyncTime = seconds * MICROSECONDS_PER_SECOND;
- mLastSyncTime += nanoseconds / NANOSECONDS_PER_MICROSECOND;
+ mLastSyncTime = nanoseconds / NANOSECONDS_PER_MICROSECOND;
}
} // namespace Adaptor
/**
* Constructor
- * @param[in] platform The platform used to retrieve the current time
*/
- FrameTime( Integration::PlatformAbstraction& platform );
+ FrameTime();
/**
* Destructor, non virtual
private:
- Integration::PlatformAbstraction& mPlatform; ///< The platform abstraction.
-
unsigned int mMinimumFrameTimeInterval; ///< The minimum frame time interval, set by Adaptor.
uint64_t mLastSyncTime; ///< The last Sync time (in microseconds).
} // unnamed namespace
ThreadSynchronization::ThreadSynchronization( AdaptorInternalServices& adaptorInterfaces, unsigned int numberOfVSyncsPerRender)
-: mFrameTime( adaptorInterfaces.GetPlatformAbstractionInterface() ),
+: mFrameTime(),
mNotificationTrigger( adaptorInterfaces.GetProcessCoreEventsTrigger() ),
mPerformanceInterface( adaptorInterfaces.GetPerformanceInterface() ),
mReplaceSurfaceRequest(),
#include <base/interfaces/adaptor-internal-services.h>
#include <base/separate-update-render/thread-synchronization.h>
#include <base/environment-options.h>
+#include <base/time-service.h>
namespace Dali
{
namespace
{
+const unsigned int NANOSECONDS_PER_SECOND( 1e+9 );
const unsigned int NANOSECONDS_PER_MICROSECOND( 1000u );
const unsigned int MICROSECONDS_PER_SECOND( 1000000u );
const unsigned int TIME_PER_FRAME_IN_MICROSECONDS( 16667u );
const EnvironmentOptions& environmentOptions )
: mThreadSynchronization( sync ),
mCore( adaptorInterfaces.GetCore() ),
- mPlatformAbstraction( adaptorInterfaces.GetPlatformAbstractionInterface() ),
mVSyncMonitor( adaptorInterfaces.GetVSyncMonitorInterface() ),
mThread( NULL ),
mEnvironmentOptions( environmentOptions ),
else
{
// No..use software timer
- mPlatformAbstraction.GetTimeNanoseconds( seconds, microseconds );
- microseconds /= NANOSECONDS_PER_MICROSECOND; // Convert to microseconds
+ uint64_t nanoseconds = 0;
+ TimeService::GetNanoseconds( nanoseconds );
+
+ seconds = nanoseconds / NANOSECONDS_PER_SECOND; // Convert to seconds
+ nanoseconds -= seconds * NANOSECONDS_PER_SECOND; // Only want remainder nanoseconds
+ microseconds = nanoseconds / NANOSECONDS_PER_MICROSECOND; // Convert to microseconds
unsigned int timeDelta( MICROSECONDS_PER_SECOND * (seconds - currentSeconds) );
if( microseconds < currentMicroseconds)
ThreadSynchronization& mThreadSynchronization; ///< Used to synchronize all the threads
Dali::Integration::Core& mCore; ///< Dali core reference
- Integration::PlatformAbstraction& mPlatformAbstraction; ///< The platform abstraction for retrieving the current time etc.
VSyncMonitorInterface* mVSyncMonitor; ///< VSyncMonitor interface
pthread_t* mThread; ///< The actual thread.
const EnvironmentOptions& mEnvironmentOptions; ///< Environment options
// INTERNAL INCLUDES
#include <base/interfaces/adaptor-internal-services.h>
#include <base/environment-options.h>
+#include <base/time-service.h>
namespace Dali
{
const float SECONDS_PER_FRAME = MILLISECONDS_PER_FRAME * 0.001f;
const unsigned int NANOSECONDS_PER_MICROSECOND( 1000u );
-const unsigned int MICROSECONDS_PER_SECOND( 1000000u );
-const float MICROSECONDS_TO_SECONDS( 0.000001f );
+const float NANOSECONDS_TO_SECONDS( 1e-9f );
#if defined(DEBUG_ENABLED)
Integration::Log::Filter* gLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_THREAD_SYNC");
mUpdateStatusLogger( environmentOptions ),
mRenderHelper( adaptorInterfaces ),
mCore( adaptorInterfaces.GetCore()),
- mPlatformAbstraction( adaptorInterfaces.GetPlatformAbstractionInterface() ),
mPerformanceInterface( adaptorInterfaces.GetPerformanceInterface() ),
mLastUpdateRenderTime( 0 ),
mSystemTime( 0 ),
// No need calculating if FPS tracking is NOT enabled
if( mFpsTracker.Enabled() )
{
- uint64_t seconds = 0;
- uint64_t microSeconds = 0;
-
- mPlatformAbstraction.GetTimeNanoseconds( seconds, microSeconds );
- microSeconds /= NANOSECONDS_PER_MICROSECOND;
-
- uint64_t currentTime = ( seconds * MICROSECONDS_PER_SECOND ) + microSeconds;
+ uint64_t currentTime = 0;
+ TimeService::GetNanoseconds( currentTime );
uint64_t delta = currentTime - mSystemTime;
mSystemTime = currentTime;
- timeSinceLastRender = delta * MICROSECONDS_TO_SECONDS;
+ timeSinceLastRender = delta * NANOSECONDS_TO_SECONDS;
}
return timeSinceLastRender;
RenderHelper mRenderHelper; ///< Helper class for EGL, pre & post rendering
Integration::Core& mCore; ///< DALi core reference
- Integration::PlatformAbstraction& mPlatformAbstraction; ///< To get the current time
PerformanceInterface* mPerformanceInterface; ///< The performance logging interface
uint64_t mLastUpdateRenderTime; ///< Last time we did an update and render
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// HEADER
+#include "base/time-service.h"
+
+// EXTERNAL INCLUDES
+#include <ctime>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace TimeService
+{
+
+namespace
+{
+const uint64_t NANOSECONDS_PER_SECOND = 1e+9;
+}
+
+void GetNanoseconds( uint64_t& time )
+{
+ timespec timeSpec;
+ clock_gettime( CLOCK_MONOTONIC, &timeSpec );
+
+ // Convert all values to uint64_t to match our return type
+ time = ( static_cast< uint64_t >( timeSpec.tv_sec ) * NANOSECONDS_PER_SECOND ) + static_cast< uint64_t >( timeSpec.tv_nsec );
+}
+
+} // namespace TimeService
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_TIME_SERVICE_H__
+#define __DALI_INTERNAL_TIME_SERVICE_H__
+
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdint.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace TimeService
+{
+
+/**
+ * @brief Get the monotonic time since some unspecified starting point (usually the boot time).
+ *
+ * @param[out] nanoseconds The time in nanoseconds since the reference point.
+ *
+ * @note The maximum value this can hold is 0xFFFFFFFFFFFFFFFF which is 1.844674407e+19. Therefore, this can overflow after approximately 584 years.
+ */
+void GetNanoseconds( uint64_t& time );
+
+} // namespace TimeService
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_TIME_SERVICE_H__
void TestApplication::DoUpdate( unsigned int intervalMilliseconds )
{
- uint64_t seconds(0u), nanoseconds(0u);
- mPlatformAbstraction.GetTimeNanoseconds( seconds, nanoseconds );
- mLastVSyncTime = ( seconds * 1e3 ) + ( nanoseconds / 1e6 );
- unsigned int nextVSyncTime = mLastVSyncTime + 16;
-
- // Update Time values
- mPlatformAbstraction.IncrementGetTimeResult( intervalMilliseconds );
-
+ unsigned int nextVSyncTime = mLastVSyncTime + intervalMilliseconds;
float elapsedSeconds = intervalMilliseconds / 1e3f;
+
mCore->Update( elapsedSeconds, mLastVSyncTime, nextVSyncTime, mStatus );
+
+ mLastVSyncTime = nextVSyncTime;
}
bool TestApplication::Render( unsigned int intervalMilliseconds )
namespace Dali
{
-namespace
-{
-const unsigned int NANOSECONDS_PER_MILLISECOND = 1000000u;
-const unsigned int NANOSECONDS_PER_SECOND = 1000000000u;
-}
-
TestPlatformAbstraction::TestPlatformAbstraction()
: mTrace(),
- mSeconds( 0u ),
- mNanoSeconds( 0u ),
mIsLoadingResult( false ),
mGetDefaultFontSizeResult( 0 ),
mResources(),
{
}
-void TestPlatformAbstraction::GetTimeNanoseconds( uint64_t& seconds, uint64_t& nanoseconds )
-{
- seconds = mSeconds;
- nanoseconds = mNanoSeconds;
- mTrace.PushCall("GetTimeNanoseconds", "");
-}
-
void TestPlatformAbstraction::Suspend()
{
mTrace.PushCall("Suspend", "");
mTrace.Reset();
mTrace.Enable(true);
memset(&mResources, 0, sizeof(Resources));
- mSeconds=0;
- mNanoSeconds=0;
mIsLoadingResult=false;
if(mRequest)
{
switch(func)
{
- case GetTimeNanosecondsFunc: return mTrace.FindMethod("GetTimeNanoseconds");
case SuspendFunc: return mTrace.FindMethod("Suspend");
case ResumeFunc: return mTrace.FindMethod("Resume");
case LoadResourceFunc: return mTrace.FindMethod("LoadResource");
return false;
}
-void TestPlatformAbstraction::SetGetTimeNanosecondsResult(size_t sec, size_t nsec)
-{
- mSeconds = sec;
- mNanoSeconds = nsec;
-}
-
-void TestPlatformAbstraction::IncrementGetTimeResult(size_t milliseconds)
-{
- mNanoSeconds += milliseconds * NANOSECONDS_PER_MILLISECOND;
- unsigned int additionalSeconds = mNanoSeconds / NANOSECONDS_PER_SECOND;
-
- mSeconds += additionalSeconds;
- mNanoSeconds -= additionalSeconds * NANOSECONDS_PER_SECOND;
-}
-
void TestPlatformAbstraction::SetIsLoadingResult(bool result)
{
mIsLoadingResult = result;
virtual ~TestPlatformAbstraction();
/**
- * @copydoc PlatformAbstraction::GetTimeNanoseconds()
- */
- virtual void GetTimeNanoseconds( uint64_t& seconds, uint64_t& nanoseconds );
-
- /**
* @copydoc PlatformAbstraction::Suspend()
*/
virtual void Suspend();
// Enumeration of Platform Abstraction methods
typedef enum
{
- GetTimeNanosecondsFunc,
SuspendFunc,
ResumeFunc,
LoadResourceFunc,
bool WasCalled(TestFuncEnum func);
- void SetGetTimeNanosecondsResult(size_t sec, size_t nsec);
-
- void IncrementGetTimeResult(size_t milliseconds);
-
void SetIsLoadingResult(bool result);
void SetGetDefaultFontSizeResult(float result);
private:
mutable TraceCallStack mTrace;
- uint64_t mSeconds;
- uint64_t mNanoSeconds;
bool mIsLoadingResult;
int mGetDefaultFontSizeResult;
Resources mResources;
#include <unistd.h>
#include <iostream>
#include <stdlib.h>
+#include <ctime>
#include <dali/dali.h>
#include <dali-test-suite-utils.h>
#include "tizen-platform-abstraction.h"
/** Returns elapsed milliseconds. */
double GetTimeMilliseconds( Integration::PlatformAbstraction& abstraction )
{
- uint64_t seconds;
- uint64_t microseconds;
- abstraction.GetTimeNanoseconds( seconds, microseconds );
- microseconds /= 1000u;
- double milliseconds = seconds * 1000.0 + microseconds / 1000.0;
- return milliseconds;
+ timespec timeSpec;
+ clock_gettime( CLOCK_MONOTONIC, &timeSpec );
+ return ( timeSpec.tv_sec * 1e3 ) + ( timeSpec.tv_nsec / 1e6 );
}
} // anon namespace
delete mResourceLoader;
}
-void TizenPlatformAbstraction::GetTimeNanoseconds( uint64_t& seconds, uint64_t& nanoseconds )
-{
- timespec time;
- clock_gettime( CLOCK_MONOTONIC, &time );
- seconds = time.tv_sec;
- nanoseconds = time.tv_nsec;
-}
-
void TizenPlatformAbstraction::Suspend()
{
if (mResourceLoader)
public: // PlatformAbstraction overrides
/**
- * @copydoc PlatformAbstraction::GetTimeNanoseconds()
- */
- virtual void GetTimeNanoseconds( uint64_t& seconds, uint64_t& nanoseconds );
-
- /**
* @copydoc PlatformAbstraction::Suspend()
*/
virtual void Suspend();