From: Adeel Kazmi Date: Wed, 1 Jul 2015 16:51:34 +0000 (+0100) Subject: Replaced UpdateRender with Thread for Controller and Sync X-Git-Tag: dali_1.1.0~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fd5059e695d2b94284c0612a281e8a546849d39b;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Replaced UpdateRender with Thread for Controller and Sync Change-Id: I1d3dfaf38526223cf7284892c5ab02e60d146020 --- diff --git a/adaptors/base/file.list b/adaptors/base/file.list index f787a18..2c73f0e 100644 --- a/adaptors/base/file.list +++ b/adaptors/base/file.list @@ -2,15 +2,15 @@ base_adaptor_src_files = \ $(base_adaptor_src_dir)/conditional-wait.cpp \ - $(base_adaptor_src_dir)/frame-time.cpp \ $(base_adaptor_src_dir)/display-connection.cpp \ + $(base_adaptor_src_dir)/environment-options.cpp \ + $(base_adaptor_src_dir)/frame-time.cpp \ $(base_adaptor_src_dir)/render-thread.cpp \ + $(base_adaptor_src_dir)/thread-controller.cpp \ + $(base_adaptor_src_dir)/thread-synchronization.cpp \ $(base_adaptor_src_dir)/update-thread.cpp \ - $(base_adaptor_src_dir)/update-render-synchronization.cpp \ - $(base_adaptor_src_dir)/update-render-controller.cpp \ $(base_adaptor_src_dir)/vsync-notifier.cpp \ $(base_adaptor_src_dir)/performance-logging/frame-time-stamp.cpp \ - $(base_adaptor_src_dir)/environment-options.cpp \ $(base_adaptor_src_dir)/performance-logging/networking/network-performance-protocol.cpp \ $(base_adaptor_src_dir)/performance-logging/networking/network-performance-client.cpp \ $(base_adaptor_src_dir)/performance-logging/networking/network-performance-server.cpp \ diff --git a/adaptors/base/render-thread.cpp b/adaptors/base/render-thread.cpp index 0c2962b..2b4b350 100644 --- a/adaptors/base/render-thread.cpp +++ b/adaptors/base/render-thread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * 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. @@ -23,7 +23,7 @@ // INTERNAL INCLUDES #include -#include +#include #include #include @@ -81,10 +81,10 @@ bool ReplaceSurfaceRequest::GetReplaceCompleted() } -RenderThread::RenderThread( UpdateRenderSynchronization& sync, +RenderThread::RenderThread( ThreadSynchronization& sync, AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions ) -: mUpdateRenderSync( sync ), +: mThreadSync( sync ), mCore( adaptorInterfaces.GetCore() ), mGLES( adaptorInterfaces.GetGlesInterface() ), mEglFactory( &adaptorInterfaces.GetEGLFactoryInterface()), @@ -175,10 +175,10 @@ bool RenderThread::Run() // render loop, we stay inside here when rendering while( running ) { - // Sync with update thread and get any outstanding requests from UpdateRenderSynchronization + // Sync with update thread and get any outstanding requests from ThreadSynchronization DALI_LOG_INFO( gRenderLogFilter, Debug::Verbose, "RenderThread::Run. 1 - RenderSyncWithUpdate()\n"); RenderRequest* request = NULL; - running = mUpdateRenderSync.RenderSyncWithUpdate( request ); + running = mThreadSync.RenderSyncWithUpdate( request ); DALI_LOG_INFO( gRenderLogFilter, Debug::Verbose, "RenderThread::Run. 2 - Process requests\n"); @@ -201,8 +201,8 @@ bool RenderThread::Run() } else { - // Block until new surface... - cleared by ReplaceSurface code in UpdateRenderController - running = mUpdateRenderSync.RenderSyncWithRequest(request); + // Block until new surface... - cleared by ReplaceSurface code in ThreadController + running = mThreadSync.RenderSyncWithRequest(request); } } @@ -214,9 +214,9 @@ bool RenderThread::Run() // Notify the update-thread that a render has completed DALI_LOG_INFO( gRenderLogFilter, Debug::Verbose, "RenderThread::Run. 5 - Sync.RenderFinished()\n"); - mUpdateRenderSync.RenderFinished( renderStatus.NeedsUpdate(), requestProcessed ); + mThreadSync.RenderFinished( renderStatus.NeedsUpdate(), requestProcessed ); - uint64_t newTime( mUpdateRenderSync.GetTimeMicroseconds() ); + uint64_t newTime( mThreadSync.GetTimeMicroseconds() ); // perform any post-render operations if ( renderStatus.HasRendered() ) diff --git a/adaptors/base/render-thread.h b/adaptors/base/render-thread.h index 09ba5b6..174e505 100644 --- a/adaptors/base/render-thread.h +++ b/adaptors/base/render-thread.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_RENDER_THREAD_H__ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * 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. @@ -43,7 +43,7 @@ namespace Adaptor { class AdaptorInternalServices; -class UpdateRenderSynchronization; +class ThreadSynchronization; class EglFactoryInterface; class EnvironmentOptions; @@ -115,11 +115,11 @@ public: /** * Create the render-thread; this will not do anything until Start() is called. - * @param[in] sync update-render synchronization object + * @param[in] sync thread synchronization object * @param[in] adaptorInterfaces base adaptor interface * @param[in] environmentOptions environment options */ - RenderThread( UpdateRenderSynchronization& sync, + RenderThread( ThreadSynchronization& sync, AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions ); @@ -202,7 +202,7 @@ private: // Render thread side helpers private: // Data - UpdateRenderSynchronization& mUpdateRenderSync; ///< Used to synchronize the update & render threads + ThreadSynchronization& mThreadSync; ///< Used to synchronize the all threads Dali::Integration::Core& mCore; ///< Dali core reference Integration::GlAbstraction& mGLES; ///< GL abstraction reference EglFactoryInterface* mEglFactory; ///< Factory class to create EGL implementation diff --git a/adaptors/base/update-render-controller.cpp b/adaptors/base/thread-controller.cpp similarity index 57% rename from adaptors/base/update-render-controller.cpp rename to adaptors/base/thread-controller.cpp index dd80495..d612b2b 100644 --- a/adaptors/base/update-render-controller.cpp +++ b/adaptors/base/thread-controller.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * 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. @@ -16,12 +16,12 @@ */ // CLASS HEADER -#include "update-render-controller.h" +#include "thread-controller.h" // INTERNAL INCLUDES #include #include -#include +#include #include #include #include @@ -35,84 +35,84 @@ namespace Internal namespace Adaptor { -UpdateRenderController::UpdateRenderController( AdaptorInternalServices& adaptorInterfaces, +ThreadController::ThreadController( AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions ) : mAdaptorInterfaces( adaptorInterfaces ), mUpdateThread( NULL ), mRenderThread( NULL ), mVSyncNotifier( NULL ), - mUpdateRenderSync( NULL ), + mThreadSync( NULL ), mNumberOfVSyncsPerRender( 1 ) { - mUpdateRenderSync = new UpdateRenderSynchronization( adaptorInterfaces, mNumberOfVSyncsPerRender ); + mThreadSync = new ThreadSynchronization( adaptorInterfaces, mNumberOfVSyncsPerRender ); - mUpdateThread = new UpdateThread( *mUpdateRenderSync, adaptorInterfaces, environmentOptions ); + mUpdateThread = new UpdateThread( *mThreadSync, adaptorInterfaces, environmentOptions ); - mRenderThread = new RenderThread( *mUpdateRenderSync, adaptorInterfaces, environmentOptions ); + mRenderThread = new RenderThread( *mThreadSync, adaptorInterfaces, environmentOptions ); - mVSyncNotifier = new VSyncNotifier( *mUpdateRenderSync, adaptorInterfaces, environmentOptions ); + mVSyncNotifier = new VSyncNotifier( *mThreadSync, adaptorInterfaces, environmentOptions ); } -UpdateRenderController::~UpdateRenderController() +ThreadController::~ThreadController() { delete mVSyncNotifier; delete mRenderThread; delete mUpdateThread; - delete mUpdateRenderSync; + delete mThreadSync; } -void UpdateRenderController::Start() +void ThreadController::Start() { // Notify the synchronization object before starting the threads - mUpdateRenderSync->Start(); + mThreadSync->Start(); mUpdateThread->Start(); mRenderThread->Start(); mVSyncNotifier->Start(); } -void UpdateRenderController::Pause() +void ThreadController::Pause() { - mUpdateRenderSync->Pause(); + mThreadSync->Pause(); // if update thread is napping, wake it up to get it to pause in correct place - mUpdateRenderSync->UpdateRequested(); + mThreadSync->UpdateRequested(); } -void UpdateRenderController::ResumeFrameTime() +void ThreadController::ResumeFrameTime() { - mUpdateRenderSync->ResumeFrameTime(); + mThreadSync->ResumeFrameTime(); } -void UpdateRenderController::Resume() +void ThreadController::Resume() { - mUpdateRenderSync->Resume(); + mThreadSync->Resume(); } -void UpdateRenderController::Stop() +void ThreadController::Stop() { // Notify the synchronization object before stopping the threads - mUpdateRenderSync->Stop(); + mThreadSync->Stop(); mVSyncNotifier->Stop(); mUpdateThread->Stop(); mRenderThread->Stop(); } -void UpdateRenderController::RequestUpdate() +void ThreadController::RequestUpdate() { - mUpdateRenderSync->UpdateRequested(); + mThreadSync->UpdateRequested(); } -void UpdateRenderController::RequestUpdateOnce() +void ThreadController::RequestUpdateOnce() { // we may be sleeping - mUpdateRenderSync->UpdateRequested(); + mThreadSync->UpdateRequested(); // if we are paused, need to allow one update - mUpdateRenderSync->UpdateWhilePaused(); + mThreadSync->UpdateWhilePaused(); } -void UpdateRenderController::ReplaceSurface( RenderSurface* newSurface ) +void ThreadController::ReplaceSurface( RenderSurface* newSurface ) { // tell render thread to start the replace. This call will block until the replace // has completed. @@ -121,10 +121,10 @@ void UpdateRenderController::ReplaceSurface( RenderSurface* newSurface ) // Ensure the current surface releases any locks to prevent deadlock. currentSurface->StopRender(); - mUpdateRenderSync->ReplaceSurface( newSurface ); + mThreadSync->ReplaceSurface( newSurface ); } -void UpdateRenderController::NewSurface( RenderSurface* newSurface ) +void ThreadController::NewSurface( RenderSurface* newSurface ) { // This API shouldn't be used when there is a current surface, but check anyway. RenderSurface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface(); @@ -133,13 +133,13 @@ void UpdateRenderController::NewSurface( RenderSurface* newSurface ) currentSurface->StopRender(); } - mUpdateRenderSync->NewSurface( newSurface ); + mThreadSync->NewSurface( newSurface ); } -void UpdateRenderController::SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender ) +void ThreadController::SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender ) { mNumberOfVSyncsPerRender = numberOfVSyncsPerRender; - mUpdateRenderSync->SetRenderRefreshRate(numberOfVSyncsPerRender); + mThreadSync->SetRenderRefreshRate(numberOfVSyncsPerRender); } diff --git a/adaptors/base/update-render-controller.h b/adaptors/base/thread-controller.h similarity index 79% rename from adaptors/base/update-render-controller.h rename to adaptors/base/thread-controller.h index a8ed9d1..df29660 100644 --- a/adaptors/base/update-render-controller.h +++ b/adaptors/base/thread-controller.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_UPDATE_RENDER_CONTROLLER_H__ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * 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. @@ -32,26 +32,26 @@ namespace Adaptor class UpdateThread; class RenderThread; class VSyncNotifier; -class UpdateRenderSynchronization; +class ThreadSynchronization; class AdaptorInternalServices; class EnvironmentOptions; /** - * Class to control the update and render threads. + * Class to control all the threads. */ -class UpdateRenderController +class ThreadController { public: /** * Constructor */ - UpdateRenderController( AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions ); + ThreadController( AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions ); /** * Non virtual destructor. Not intended as base class. */ - ~UpdateRenderController(); + ~ThreadController(); /** * @copydoc Dali::Adaptor::Start() @@ -111,17 +111,17 @@ public: private: // Undefined copy constructor. - UpdateRenderController( const UpdateRenderController& ); + ThreadController( const ThreadController& ); // Undefined assignment operator. - UpdateRenderController& operator=( const UpdateRenderController& ); + ThreadController& operator=( const ThreadController& ); AdaptorInternalServices& mAdaptorInterfaces; - UpdateThread* mUpdateThread; ///< The update-thread owned by UpdateRenderController - RenderThread* mRenderThread; ///< The render-thread owned by UpdateRenderController - VSyncNotifier* mVSyncNotifier; ///< The vsync-thread owned by UpdateRenderController - UpdateRenderSynchronization* mUpdateRenderSync; ///< Used to synchronize the update & render threads; also owned by UpdateRenderController + UpdateThread* mUpdateThread; ///< The update-thread owned by ThreadController + RenderThread* mRenderThread; ///< The render-thread owned by ThreadController + VSyncNotifier* mVSyncNotifier; ///< The vsync-thread owned by ThreadController + ThreadSynchronization* mThreadSync; ///< Used to synchronize all the threads; owned by ThreadController unsigned int mNumberOfVSyncsPerRender; ///< Frame skipping count }; diff --git a/adaptors/base/update-render-synchronization.cpp b/adaptors/base/thread-synchronization.cpp similarity index 85% rename from adaptors/base/update-render-synchronization.cpp rename to adaptors/base/thread-synchronization.cpp index dbff252..07b2b65 100644 --- a/adaptors/base/update-render-synchronization.cpp +++ b/adaptors/base/thread-synchronization.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * 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. @@ -16,7 +16,7 @@ */ // CLASS HEADER -#include "update-render-synchronization.h" +#include "thread-synchronization.h" // EXTERNAL INCLUDES #include @@ -41,7 +41,7 @@ const unsigned int INPUT_EVENT_UPDATE_PERIOD( MICROSECONDS_PER_SECOND / 90 ); // } // unnamed namespace -UpdateRenderSynchronization::UpdateRenderSynchronization( AdaptorInternalServices& adaptorInterfaces, +ThreadSynchronization::ThreadSynchronization( AdaptorInternalServices& adaptorInterfaces, unsigned int numberOfVSyncsPerRender) : mMaximumUpdateCount( adaptorInterfaces.GetCore().GetMaximumUpdateCount()), mNumberOfVSyncsPerRender( numberOfVSyncsPerRender ), @@ -63,17 +63,17 @@ UpdateRenderSynchronization::UpdateRenderSynchronization( AdaptorInternalService { } -UpdateRenderSynchronization::~UpdateRenderSynchronization() +ThreadSynchronization::~ThreadSynchronization() { } -void UpdateRenderSynchronization::Start() +void ThreadSynchronization::Start() { mFrameTime.SetMinimumFrameTimeInterval( mNumberOfVSyncsPerRender * TIME_PER_FRAME_IN_MICROSECONDS ); mRunning = true; } -void UpdateRenderSynchronization::Stop() +void ThreadSynchronization::Stop() { mRunning = false; @@ -94,7 +94,7 @@ void UpdateRenderSynchronization::Stop() mFrameTime.Suspend(); } -void UpdateRenderSynchronization::Pause() +void ThreadSynchronization::Pause() { mPaused = true; @@ -102,12 +102,12 @@ void UpdateRenderSynchronization::Pause() mFrameTime.Suspend(); } -void UpdateRenderSynchronization::ResumeFrameTime() +void ThreadSynchronization::ResumeFrameTime() { mFrameTime.Resume(); } -void UpdateRenderSynchronization::Resume() +void ThreadSynchronization::Resume() { mPaused = false; mVSyncSleep = false; @@ -118,7 +118,7 @@ void UpdateRenderSynchronization::Resume() AddPerformanceMarker( PerformanceInterface::RESUME); } -void UpdateRenderSynchronization::UpdateRequested() +void ThreadSynchronization::UpdateRequested() { mUpdateRequested = true; @@ -126,7 +126,7 @@ void UpdateRenderSynchronization::UpdateRequested() mUpdateSleepCondition.notify_one(); } -void UpdateRenderSynchronization::UpdateWhilePaused() +void ThreadSynchronization::UpdateWhilePaused() { { boost::unique_lock< boost::mutex > lock( mMutex ); @@ -142,7 +142,7 @@ void UpdateRenderSynchronization::UpdateWhilePaused() mPausedCondition.notify_one(); } -bool UpdateRenderSynchronization::ReplaceSurface( RenderSurface* newSurface ) +bool ThreadSynchronization::ReplaceSurface( RenderSurface* newSurface ) { bool result=false; @@ -163,7 +163,7 @@ bool UpdateRenderSynchronization::ReplaceSurface( RenderSurface* newSurface ) return result; } -bool UpdateRenderSynchronization::NewSurface( RenderSurface* newSurface ) +bool ThreadSynchronization::NewSurface( RenderSurface* newSurface ) { bool result=false; @@ -189,7 +189,7 @@ bool UpdateRenderSynchronization::NewSurface( RenderSurface* newSurface ) } -void UpdateRenderSynchronization::UpdateReadyToRun() +void ThreadSynchronization::UpdateReadyToRun() { bool wokenFromPause( false ); @@ -217,7 +217,7 @@ void UpdateRenderSynchronization::UpdateReadyToRun() AddPerformanceMarker( PerformanceInterface::UPDATE_START ); } -bool UpdateRenderSynchronization::UpdateSyncWithRender( bool notifyEvent, bool& renderNeedsUpdate ) +bool ThreadSynchronization::UpdateSyncWithRender( bool notifyEvent, bool& renderNeedsUpdate ) { AddPerformanceMarker( PerformanceInterface::UPDATE_END ); @@ -251,7 +251,7 @@ bool UpdateRenderSynchronization::UpdateSyncWithRender( bool notifyEvent, bool& return mRunning; } -void UpdateRenderSynchronization::UpdateWaitForAllRenderingToFinish() +void ThreadSynchronization::UpdateWaitForAllRenderingToFinish() { boost::unique_lock< boost::mutex > lock( mMutex ); @@ -264,7 +264,7 @@ void UpdateRenderSynchronization::UpdateWaitForAllRenderingToFinish() } } -bool UpdateRenderSynchronization::UpdateTryToSleep() +bool ThreadSynchronization::UpdateTryToSleep() { if ( !mUpdateRequired && !mUpdateRequested ) { @@ -307,7 +307,7 @@ bool UpdateRenderSynchronization::UpdateTryToSleep() return mRunning; } -bool UpdateRenderSynchronization::RenderSyncWithRequest(RenderRequest*& requestPtr) +bool ThreadSynchronization::RenderSyncWithRequest(RenderRequest*& requestPtr) { boost::unique_lock< boost::mutex > lock( mMutex ); @@ -323,7 +323,7 @@ bool UpdateRenderSynchronization::RenderSyncWithRequest(RenderRequest*& requestP return mRunning; } -bool UpdateRenderSynchronization::RenderSyncWithUpdate(RenderRequest*& requestPtr) +bool ThreadSynchronization::RenderSyncWithUpdate(RenderRequest*& requestPtr) { boost::unique_lock< boost::mutex > lock( mMutex ); @@ -351,7 +351,7 @@ bool UpdateRenderSynchronization::RenderSyncWithUpdate(RenderRequest*& requestPt return mRunning; } -void UpdateRenderSynchronization::RenderFinished( bool updateRequired, bool requestProcessed ) +void ThreadSynchronization::RenderFinished( bool updateRequired, bool requestProcessed ) { { boost::unique_lock< boost::mutex > lock( mMutex ); @@ -376,7 +376,7 @@ void UpdateRenderSynchronization::RenderFinished( bool updateRequired, bool requ AddPerformanceMarker( PerformanceInterface::RENDER_END ); } -void UpdateRenderSynchronization::WaitSync() +void ThreadSynchronization::WaitSync() { // Block until the start of a new sync. // If we're experiencing slowdown and are behind by more than a frame @@ -397,7 +397,7 @@ void UpdateRenderSynchronization::WaitSync() mAllowUpdateWhilePaused = false; } -bool UpdateRenderSynchronization::VSyncNotifierSyncWithUpdateAndRender( bool validSync, unsigned int frameNumber, unsigned int seconds, unsigned int microseconds, unsigned int& numberOfVSyncsPerRender ) +bool ThreadSynchronization::VSyncNotifierSyncWithUpdateAndRender( bool validSync, unsigned int frameNumber, unsigned int seconds, unsigned int microseconds, unsigned int& numberOfVSyncsPerRender ) { // This may have changed since the last sync. Update VSyncNotifier's copy here if so. if( numberOfVSyncsPerRender != mNumberOfVSyncsPerRender ) @@ -433,12 +433,12 @@ bool UpdateRenderSynchronization::VSyncNotifierSyncWithUpdateAndRender( bool val return mRunning; } -unsigned int UpdateRenderSynchronization::GetFrameNumber() const +unsigned int ThreadSynchronization::GetFrameNumber() const { return mSyncFrameNumber; } -uint64_t UpdateRenderSynchronization::GetTimeMicroseconds() +uint64_t ThreadSynchronization::GetTimeMicroseconds() { uint64_t currentTime(0); @@ -453,12 +453,12 @@ uint64_t UpdateRenderSynchronization::GetTimeMicroseconds() return currentTime; } -void UpdateRenderSynchronization::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender ) +void ThreadSynchronization::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender ) { mNumberOfVSyncsPerRender = numberOfVSyncsPerRender; } -inline void UpdateRenderSynchronization::AddPerformanceMarker( PerformanceInterface::MarkerType type ) +inline void ThreadSynchronization::AddPerformanceMarker( PerformanceInterface::MarkerType type ) { if( mPerformanceInterface ) { @@ -466,7 +466,7 @@ inline void UpdateRenderSynchronization::AddPerformanceMarker( PerformanceInterf } } -void UpdateRenderSynchronization::PredictNextSyncTime( +void ThreadSynchronization::PredictNextSyncTime( float& lastFrameDeltaSeconds, unsigned int& lastSyncTimeMilliseconds, unsigned int& nextSyncTimeMilliseconds ) diff --git a/adaptors/base/update-render-synchronization.h b/adaptors/base/thread-synchronization.h similarity index 96% rename from adaptors/base/update-render-synchronization.h rename to adaptors/base/thread-synchronization.h index 1f0ba13..18f59ba 100644 --- a/adaptors/base/update-render-synchronization.h +++ b/adaptors/base/thread-synchronization.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_UPDATE_RENDER_SYNCHRONIZATION_H__ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * 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. @@ -57,7 +57,7 @@ class AdaptorInternalServices; * However the Core::Update() for frame N+2 may not be called, until the Core::Render() method for frame N has returned. * */ -class UpdateRenderSynchronization +class ThreadSynchronization { public: @@ -66,12 +66,12 @@ public: * @param[in] adaptorInterfaces base adaptor interface * @param[in] numberOfVSyncsPerRender The number of frames per render */ - UpdateRenderSynchronization( AdaptorInternalServices& adaptorInterfaces, unsigned int numberOfVSyncsPerRender ); + ThreadSynchronization( AdaptorInternalServices& adaptorInterfaces, unsigned int numberOfVSyncsPerRender ); /** * Non virtual destructor. Not intended as base class. */ - ~UpdateRenderSynchronization(); + ~ThreadSynchronization(); /** * Start the threads @@ -238,10 +238,10 @@ public: private: // Undefined copy constructor. - UpdateRenderSynchronization( const UpdateRenderSynchronization& ); + ThreadSynchronization( const ThreadSynchronization& ); // Undefined assignment operator. - UpdateRenderSynchronization& operator=( const UpdateRenderSynchronization& ); + ThreadSynchronization& operator=( const ThreadSynchronization& ); /** * Helper to add a performance marker to the performance server (if its active) @@ -284,7 +284,7 @@ private: ReplaceSurfaceRequest mReplaceSurfaceRequest; ///< Holder for a replace surface request bool mReplaceSurfaceRequested; ///< True if there is a new replace surface request -}; // class UpdateRenderSynchronization +}; // class ThreadSynchronization } // namespace Adaptor diff --git a/adaptors/base/update-thread.cpp b/adaptors/base/update-thread.cpp index 7a157fd..a1b6a00 100644 --- a/adaptors/base/update-thread.cpp +++ b/adaptors/base/update-thread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * 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. @@ -24,7 +24,7 @@ // INTERNAL INCLUDES #include #include -#include +#include #include namespace Dali @@ -45,10 +45,10 @@ Integration::Log::Filter* gUpdateLogFilter = Integration::Log::Filter::New(Debug #endif } // unnamed namespace -UpdateThread::UpdateThread( UpdateRenderSynchronization& sync, +UpdateThread::UpdateThread( ThreadSynchronization& sync, AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions ) -: mUpdateRenderSync( sync ), +: mThreadSync( sync ), mCore( adaptorInterfaces.GetCore()), mFpsTrackingSeconds( fabsf( environmentOptions.GetFrameRateLoggingFrequency() ) ), mFrameCount( 0.0f ), @@ -110,14 +110,14 @@ bool UpdateThread::Run() DALI_LOG_INFO( gUpdateLogFilter, Debug::Verbose, "UpdateThread::Run. 1 - Sync()\n"); // Inform synchronization object update is ready to run, this will pause update thread if required. - mUpdateRenderSync.UpdateReadyToRun(); + mThreadSync.UpdateReadyToRun(); DALI_LOG_INFO( gUpdateLogFilter, Debug::Verbose, "UpdateThread::Run. 2 - Ready()\n"); // get the last delta and the predict when this update will be rendered float lastFrameDelta( 0.0f ); unsigned int lastSyncTime( 0 ); unsigned int nextSyncTime( 0 ); - mUpdateRenderSync.PredictNextSyncTime( lastFrameDelta, lastSyncTime, nextSyncTime ); + mThreadSync.PredictNextSyncTime( lastFrameDelta, lastSyncTime, nextSyncTime ); DALI_LOG_INFO( gUpdateLogFilter, Debug::Verbose, "UpdateThread::Run. 3 - Update(delta:%f, lastSync:%u, nextSync:%u)\n", lastFrameDelta, lastSyncTime, nextSyncTime); @@ -132,7 +132,7 @@ bool UpdateThread::Run() // tell the synchronisation class that a buffer has been written to, // and to wait until there is a free buffer to write to - running = mUpdateRenderSync.UpdateSyncWithRender( status.NeedsNotification(), renderNeedsUpdate ); + running = mThreadSync.UpdateSyncWithRender( status.NeedsNotification(), renderNeedsUpdate ); DALI_LOG_INFO( gUpdateLogFilter, Debug::Verbose, "UpdateThread::Run. 4 - UpdateSyncWithRender complete\n"); if( running ) @@ -154,7 +154,7 @@ bool UpdateThread::Run() { DALI_LOG_INFO( gUpdateLogFilter, Debug::Verbose, "UpdateThread::Run. 5 - Nothing to update, trying to sleep\n"); - running = mUpdateRenderSync.UpdateTryToSleep(); + running = mThreadSync.UpdateTryToSleep(); } } } diff --git a/adaptors/base/update-thread.h b/adaptors/base/update-thread.h index 2b2b77e..faa512e 100644 --- a/adaptors/base/update-thread.h +++ b/adaptors/base/update-thread.h @@ -35,7 +35,7 @@ namespace Internal namespace Adaptor { -class UpdateRenderSynchronization; +class ThreadSynchronization; class AdaptorInternalServices; class EnvironmentOptions; @@ -53,7 +53,7 @@ public: * @param[in] adaptorInterfaces base adaptor interface * @param[in] environmentOptions environment options */ - UpdateThread(UpdateRenderSynchronization& sync, + UpdateThread(ThreadSynchronization& sync, AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions ); @@ -111,7 +111,7 @@ private: private: // Data - UpdateRenderSynchronization& mUpdateRenderSync; ///< Used to synchronize the update & render threads + ThreadSynchronization& mThreadSync; ///< Used to synchronize all the threads Dali::Integration::Core& mCore; ///< Dali core reference diff --git a/adaptors/base/vsync-notifier.cpp b/adaptors/base/vsync-notifier.cpp index 2511e7b..109a9df 100644 --- a/adaptors/base/vsync-notifier.cpp +++ b/adaptors/base/vsync-notifier.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * 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. @@ -23,7 +23,7 @@ // INTERNAL INCLUDES #include -#include +#include #include namespace Dali @@ -47,10 +47,10 @@ Integration::Log::Filter* gSyncLogFilter = Integration::Log::Filter::New(Debug:: } // unnamed namespace -VSyncNotifier::VSyncNotifier( UpdateRenderSynchronization& sync, +VSyncNotifier::VSyncNotifier( ThreadSynchronization& sync, AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions ) -: mUpdateRenderSync( sync ), +: mThreadSync( sync ), mCore( adaptorInterfaces.GetCore() ), mPlatformAbstraction( adaptorInterfaces.GetPlatformAbstractionInterface() ), mVSyncMonitor( adaptorInterfaces.GetVSyncMonitorInterface() ), @@ -165,7 +165,7 @@ void VSyncNotifier::Run() DALI_LOG_INFO( gSyncLogFilter, Debug::General, "VSyncNotifier::Run. 3 SyncWithUpdateAndRender(frame#:%d, current Sec:%u current uSec:%u)\n", frameNumber+1, currentSeconds, currentMicroseconds); - running = mUpdateRenderSync.VSyncNotifierSyncWithUpdateAndRender( validSync, ++frameNumber, currentSeconds, currentMicroseconds, mNumberOfVSyncsPerRender ); + running = mThreadSync.VSyncNotifierSyncWithUpdateAndRender( validSync, ++frameNumber, currentSeconds, currentMicroseconds, mNumberOfVSyncsPerRender ); // The number of vsyncs per render may have been modified by this call. } diff --git a/adaptors/base/vsync-notifier.h b/adaptors/base/vsync-notifier.h index c1c632d..725ce6c 100644 --- a/adaptors/base/vsync-notifier.h +++ b/adaptors/base/vsync-notifier.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_VSYNC_NOTIFIER_H__ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * 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. @@ -39,7 +39,7 @@ namespace Adaptor { class VSyncMonitorInterface; -class UpdateRenderSynchronization; +class ThreadSynchronization; class EnvironmentOptions; class AdaptorInternalServices; @@ -58,7 +58,7 @@ public: * @param[in] adaptorInterfaces base adaptor interface * @param[in] environmentOptions environment options */ - VSyncNotifier( UpdateRenderSynchronization& sync, + VSyncNotifier( ThreadSynchronization& sync, AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions); @@ -97,13 +97,13 @@ private: private: - UpdateRenderSynchronization& mUpdateRenderSync; ///< Used to synchronize the update, render & vsync 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 - unsigned int mNumberOfVSyncsPerRender;///< How many frames for each update/render cycle. + ThreadSynchronization& mThreadSync; ///< 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 + unsigned int mNumberOfVSyncsPerRender; ///< How many frames for each update/render cycle. }; // class VSyncNotifier diff --git a/adaptors/common/adaptor-impl.cpp b/adaptors/common/adaptor-impl.cpp index fef4bdc..db6189b 100644 --- a/adaptors/common/adaptor-impl.cpp +++ b/adaptors/common/adaptor-impl.cpp @@ -28,7 +28,7 @@ #include // INTERNAL INCLUDES -#include +#include #include #include @@ -148,7 +148,7 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration ) mVSyncMonitor = new VSyncMonitor; - mUpdateRenderController = new UpdateRenderController( *this, *mEnvironmentOptions ); + mThreadController = new ThreadController( *this, *mEnvironmentOptions ); // Should be called after Core creation if( mEnvironmentOptions->GetPanGestureLoggingLevel() ) @@ -198,7 +198,7 @@ Adaptor::~Adaptor() (*iter)->OnDestroy(); } - delete mUpdateRenderController; // this will shutdown render thread, which will call Core::ContextDestroyed before exit + delete mThreadController; // this will shutdown render thread, which will call Core::ContextDestroyed before exit delete mVSyncMonitor; delete mEventHandler; delete mObjectProfiler; @@ -257,8 +257,8 @@ void Adaptor::Start() PositionSize size = mSurface->GetPositionSize(); mCore->SurfaceResized( size.width, size.height ); - // Start the update & render threads - mUpdateRenderController->Start(); + // Start all the threads + mThreadController->Start(); mState = RUNNING; @@ -288,7 +288,7 @@ void Adaptor::Pause() mEventHandler->Pause(); } - mUpdateRenderController->Pause(); + mThreadController->Pause(); mCore->Suspend(); mState = PAUSED; } @@ -303,14 +303,14 @@ void Adaptor::Resume() // We put ResumeFrameTime first, as this was originally called at the start of mCore->Resume() // If there were events pending, mCore->Resume() will call // RenderController->RequestUpdate() - // UpdateRenderController->RequestUpdate() - // UpdateRenderSynchronization->RequestUpdate() + // ThreadController->RequestUpdate() + // ThreadSynchronization->RequestUpdate() // and we should have reset the frame timers before allowing Core->Update() to be called. - //@todo Should we call UpdateRenderController->Resume before mCore->Resume()? + //@todo Should we call ThreadController->Resume before mCore->Resume()? - mUpdateRenderController->ResumeFrameTime(); + mThreadController->ResumeFrameTime(); mCore->Resume(); - mUpdateRenderController->Resume(); + mThreadController->Resume(); mState = RUNNING; @@ -341,7 +341,7 @@ void Adaptor::Stop() (*iter)->OnStop(); } - mUpdateRenderController->Stop(); + mThreadController->Stop(); mCore->Suspend(); // Delete the TTS player @@ -438,7 +438,7 @@ void Adaptor::ReplaceSurface( Any nativeWindow, RenderSurface& surface ) ProcessCoreEvents(); // this method blocks until the render thread has completed the replace. - mUpdateRenderController->ReplaceSurface(mSurface); + mThreadController->ReplaceSurface(mSurface); } RenderSurface& Adaptor::GetSurface() const @@ -499,7 +499,7 @@ Dali::Integration::Core& Adaptor::GetCore() void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender ) { - mUpdateRenderController->SetRenderRefreshRate( numberOfVSyncsPerRender ); + mThreadController->SetRenderRefreshRate( numberOfVSyncsPerRender ); } void Adaptor::SetUseHardwareVSync( bool useHardware ) @@ -677,7 +677,7 @@ void Adaptor::RequestUpdate() if ( PAUSED == mState || RUNNING == mState ) { - mUpdateRenderController->RequestUpdate(); + mThreadController->RequestUpdate(); } } @@ -745,9 +745,9 @@ void Adaptor::RequestUpdateOnce() { if( PAUSED_WHILE_HIDDEN != mState ) { - if( mUpdateRenderController ) + if( mThreadController ) { - mUpdateRenderController->RequestUpdateOnce(); + mThreadController->RequestUpdateOnce(); } } } @@ -766,7 +766,7 @@ Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surfac mAdaptor(adaptor), mState(READY), mCore(NULL), - mUpdateRenderController(NULL), + mThreadController(NULL), mVSyncMonitor(NULL), mGLES( NULL ), mEglFactory( NULL ), diff --git a/adaptors/common/adaptor-impl.h b/adaptors/common/adaptor-impl.h index 2e4ddb5..e920459 100644 --- a/adaptors/common/adaptor-impl.h +++ b/adaptors/common/adaptor-impl.h @@ -66,7 +66,7 @@ class EglFactory; class GestureManager; class GlImplementation; class GlSyncImplementation; -class UpdateRenderController; +class ThreadController; class TriggerEvent; class CallbackManager; class FeedbackPluginProxy; @@ -529,7 +529,7 @@ private: // Data Dali::Adaptor& mAdaptor; ///< Reference to public adaptor instance. State mState; ///< Current state of the adaptor Dali::Integration::Core* mCore; ///< Dali Core - UpdateRenderController* mUpdateRenderController; ///< Controls update/render threads + ThreadController* mThreadController; ///< Controls the threads VSyncMonitor* mVSyncMonitor; ///< Monitors VSync events GlImplementation* mGLES; ///< GL implementation GlSyncImplementation* mGlSync; ///< GL Sync implementation