From: Adeel Kazmi Date: Thu, 29 Oct 2015 10:23:44 +0000 (+0000) Subject: Moved thread control functionality into a separate folder & added threading mode... X-Git-Tag: dali_1.1.9~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F95%2F50195%2F14;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Moved thread control functionality into a separate folder & added threading mode environment variable Use DALI_THREADING_MODE to control which threading mode to use: - 0: SeparateUpdateRender: Event, VSync, Update & Render ALL on separate threads. - 1: SingleThreaded: ALL functionality on the SAME thread. - 2: CombinedUpdateRender: Three threads: Event, VSync & Combined Update/Render Only Mode 0 supported in this patch, modes 1 & 2 activated in later patches. Change-Id: Ib45e7f5305ae56e9bd79def81a61503998e34824 --- diff --git a/adaptors/base/environment-options.cpp b/adaptors/base/environment-options.cpp index 8344e05..64c99e3 100644 --- a/adaptors/base/environment-options.cpp +++ b/adaptors/base/environment-options.cpp @@ -103,7 +103,8 @@ EnvironmentOptions::EnvironmentOptions() mPanMinimumEvents(-1), mGlesCallTime(0), mWindowWidth( 0 ), - mWindowHeight( 0 ) + mWindowHeight( 0 ), + mThreadingMode( ThreadingMode::SEPARATE_UPDATE_RENDER ) { ParseEnvironmentOptions(); } @@ -234,6 +235,11 @@ const std::string& EnvironmentOptions::GetWindowClassName() const return mWindowClassName; } +ThreadingMode::Type EnvironmentOptions::GetThreadingMode() const +{ + return mThreadingMode; +} + bool EnvironmentOptions::PerformanceServerRequired() const { return ( ( GetPerformanceStatsLoggingOptions() > 0) || @@ -346,6 +352,21 @@ void EnvironmentOptions::ParseEnvironmentOptions() { mWindowClassName = windowClassName; } + + int threadingMode(0); + if ( GetIntegerEnvironmentVariable( DALI_THREADING_MODE, threadingMode ) ) + { + switch( threadingMode ) + { + case ThreadingMode::SEPARATE_UPDATE_RENDER: + case ThreadingMode::COMBINED_UPDATE_RENDER: + case ThreadingMode::SINGLE_THREADED: + { + mThreadingMode = static_cast< ThreadingMode::Type >( threadingMode ); + break; + } + } + } } } // Adaptor diff --git a/adaptors/base/environment-options.h b/adaptors/base/environment-options.h index 29aa9bf..7f0f771 100644 --- a/adaptors/base/environment-options.h +++ b/adaptors/base/environment-options.h @@ -21,6 +21,9 @@ // EXTERNAL INCLUDES #include +// INTERNAL INCLUDES +#include + namespace Dali { namespace Internal @@ -185,6 +188,11 @@ public: */ const std::string& GetWindowClassName() const; + /** + * @return The thread mode that DALi should use. + */ + ThreadingMode::Type GetThreadingMode() const; + private: // Internal /** @@ -217,6 +225,7 @@ private: // Data int mGlesCallTime; ///< time in seconds between status updates unsigned int mWindowWidth; ///< width of the window unsigned int mWindowHeight; ///< height of the window + ThreadingMode::Type mThreadingMode; ///< threading mode Dali::Integration::Log::LogFunction mLogFunction; diff --git a/adaptors/base/environment-variables.h b/adaptors/base/environment-variables.h index ea7dc1e..627ee59 100644 --- a/adaptors/base/environment-variables.h +++ b/adaptors/base/environment-variables.h @@ -87,6 +87,8 @@ namespace Adaptor #define DALI_WINDOW_CLASS_NAME "DALI_WINDOW_CLASS_NAME" +#define DALI_THREADING_MODE "DALI_THREADING_MODE" + } // namespace Adaptor } // namespace Internal diff --git a/adaptors/base/file.list b/adaptors/base/file.list index 8f1140e..f940b67 100644 --- a/adaptors/base/file.list +++ b/adaptors/base/file.list @@ -4,20 +4,21 @@ base_adaptor_src_files = \ $(base_adaptor_src_dir)/display-connection.cpp \ $(base_adaptor_src_dir)/environment-options.cpp \ $(base_adaptor_src_dir)/fps-tracker.cpp \ - $(base_adaptor_src_dir)/frame-time.cpp \ $(base_adaptor_src_dir)/render-helper.cpp \ - $(base_adaptor_src_dir)/render-request.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-status-logger.cpp \ - $(base_adaptor_src_dir)/update-thread.cpp \ - $(base_adaptor_src_dir)/vsync-notifier.cpp \ $(base_adaptor_src_dir)/performance-logging/frame-time-stamp.cpp \ $(base_adaptor_src_dir)/performance-logging/frame-time-stats.cpp \ $(base_adaptor_src_dir)/performance-logging/performance-marker.cpp \ $(base_adaptor_src_dir)/performance-logging/statistics/stat-context.cpp \ - $(base_adaptor_src_dir)/performance-logging/statistics/stat-context-manager.cpp + $(base_adaptor_src_dir)/performance-logging/statistics/stat-context-manager.cpp \ + $(base_adaptor_src_dir)/separate-update-render/frame-time.cpp \ + $(base_adaptor_src_dir)/separate-update-render/separate-update-render-controller.cpp \ + $(base_adaptor_src_dir)/separate-update-render/render-request.cpp \ + $(base_adaptor_src_dir)/separate-update-render/render-thread.cpp \ + $(base_adaptor_src_dir)/separate-update-render/thread-synchronization.cpp \ + $(base_adaptor_src_dir)/separate-update-render/update-thread.cpp \ + $(base_adaptor_src_dir)/separate-update-render/vsync-notifier.cpp base_adaptor_networking_src_files = \ $(base_adaptor_src_dir)/performance-logging/networking/network-performance-protocol.cpp \ diff --git a/adaptors/base/frame-time.cpp b/adaptors/base/separate-update-render/frame-time.cpp similarity index 100% rename from adaptors/base/frame-time.cpp rename to adaptors/base/separate-update-render/frame-time.cpp diff --git a/adaptors/base/frame-time.h b/adaptors/base/separate-update-render/frame-time.h similarity index 100% rename from adaptors/base/frame-time.h rename to adaptors/base/separate-update-render/frame-time.h diff --git a/adaptors/base/render-request.cpp b/adaptors/base/separate-update-render/render-request.cpp similarity index 100% rename from adaptors/base/render-request.cpp rename to adaptors/base/separate-update-render/render-request.cpp diff --git a/adaptors/base/render-request.h b/adaptors/base/separate-update-render/render-request.h similarity index 100% rename from adaptors/base/render-request.h rename to adaptors/base/separate-update-render/render-request.h diff --git a/adaptors/base/render-thread.cpp b/adaptors/base/separate-update-render/render-thread.cpp similarity index 98% rename from adaptors/base/render-thread.cpp rename to adaptors/base/separate-update-render/render-thread.cpp index f80a6a7..4231106 100644 --- a/adaptors/base/render-thread.cpp +++ b/adaptors/base/separate-update-render/render-thread.cpp @@ -23,7 +23,7 @@ // INTERNAL INCLUDES #include -#include +#include #include namespace Dali diff --git a/adaptors/base/render-thread.h b/adaptors/base/separate-update-render/render-thread.h similarity index 98% rename from adaptors/base/render-thread.h rename to adaptors/base/separate-update-render/render-thread.h index b138a24..ad0a97e 100644 --- a/adaptors/base/render-thread.h +++ b/adaptors/base/separate-update-render/render-thread.h @@ -23,7 +23,7 @@ // INTERNAL INCLUDES #include -#include +#include #include #include // needed for Dali::RenderSurface diff --git a/adaptors/base/separate-update-render/separate-update-render-controller.cpp b/adaptors/base/separate-update-render/separate-update-render-controller.cpp new file mode 100644 index 0000000..91d56c9 --- /dev/null +++ b/adaptors/base/separate-update-render/separate-update-render-controller.cpp @@ -0,0 +1,143 @@ +/* + * 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. + * + */ + +// CLASS HEADER +#include "separate-update-render-controller.h" + +// INTERNAL INCLUDES +#include +#include +#include +#include +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +SeparateUpdateRenderController::SeparateUpdateRenderController( AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions ) +: ThreadControllerInterface(), + mAdaptorInterfaces( adaptorInterfaces ), + mUpdateThread( NULL ), + mRenderThread( NULL ), + mVSyncNotifier( NULL ), + mThreadSync( NULL ), + mNumberOfVSyncsPerRender( 1 ) +{ + mThreadSync = new ThreadSynchronization( adaptorInterfaces, mNumberOfVSyncsPerRender ); + + mUpdateThread = new UpdateThread( *mThreadSync, adaptorInterfaces, environmentOptions ); + + mRenderThread = new RenderThread( *mThreadSync, adaptorInterfaces, environmentOptions ); + + mVSyncNotifier = new VSyncNotifier( *mThreadSync, adaptorInterfaces, environmentOptions ); + + // Set the thread-synchronization interface on the render-surface + RenderSurface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface(); + if( currentSurface ) + { + currentSurface->SetThreadSynchronization( *mThreadSync ); + } +} + +SeparateUpdateRenderController::~SeparateUpdateRenderController() +{ + delete mVSyncNotifier; + delete mRenderThread; + delete mUpdateThread; + delete mThreadSync; +} + +void SeparateUpdateRenderController::Initialize() +{ + // Notify the synchronization object before starting the threads + mThreadSync->Initialise(); + + // We want to the threads to be set up before they start + mUpdateThread->Start(); + mRenderThread->Start(); + mVSyncNotifier->Start(); +} + +void SeparateUpdateRenderController::Start() +{ + mThreadSync->Start(); +} + +void SeparateUpdateRenderController::Pause() +{ + mThreadSync->Pause(); +} + +void SeparateUpdateRenderController::Resume() +{ + mThreadSync->Resume(); +} + +void SeparateUpdateRenderController::Stop() +{ + // Notify the synchronization object before stopping the threads + mThreadSync->Stop(); + + mVSyncNotifier->Stop(); + mUpdateThread->Stop(); + mRenderThread->Stop(); +} + +void SeparateUpdateRenderController::RequestUpdate() +{ + mThreadSync->UpdateRequest(); +} + +void SeparateUpdateRenderController::RequestUpdateOnce() +{ + // if we are paused, need to allow one update + mThreadSync->UpdateOnce(); +} + +void SeparateUpdateRenderController::ReplaceSurface( RenderSurface* newSurface ) +{ + // Set the thread-syncronization on the new surface + newSurface->SetThreadSynchronization( *mThreadSync ); + + // tell render thread to start the replace. This call will block until the replace + // has completed. + RenderSurface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface(); + + // Ensure the current surface releases any locks to prevent deadlock. + currentSurface->StopRender(); + + mThreadSync->ReplaceSurface( newSurface ); +} + +void SeparateUpdateRenderController::SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender ) +{ + mNumberOfVSyncsPerRender = numberOfVSyncsPerRender; + mThreadSync->SetRenderRefreshRate(numberOfVSyncsPerRender); +} + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali diff --git a/adaptors/base/separate-update-render/separate-update-render-controller.h b/adaptors/base/separate-update-render/separate-update-render-controller.h new file mode 100644 index 0000000..19d3b3c --- /dev/null +++ b/adaptors/base/separate-update-render/separate-update-render-controller.h @@ -0,0 +1,131 @@ +#ifndef __DALI_INTERNAL_MULTI_THREAD_CONTROLLER_H__ +#define __DALI_INTERNAL_MULTI_THREAD_CONTROLLER_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. + * + */ + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +class RenderSurface; + +namespace Internal +{ + +namespace Adaptor +{ + +class UpdateThread; +class RenderThread; +class VSyncNotifier; +class ThreadSynchronization; +class AdaptorInternalServices; +class EnvironmentOptions; + +/** + * Class to control multiple threads: + * - Main Event Thread + * - VSync Thread + * - Update Thread + * - Render Thread + */ +class SeparateUpdateRenderController : public ThreadControllerInterface +{ +public: + + /** + * Constructor + */ + SeparateUpdateRenderController( AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions ); + + /** + * Non virtual destructor. Not intended as base class. + */ + ~SeparateUpdateRenderController(); + + /** + * @copydoc ThreadControllerInterface::Initialize() + */ + void Initialize(); + + /** + * @copydoc ThreadControllerInterface::Start() + */ + void Start(); + + /** + * @copydoc ThreadControllerInterface::Pause() + */ + void Pause(); + + /** + * @copydoc ThreadControllerInterface::Resume() + */ + void Resume(); + + /** + * @copydoc ThreadControllerInterface::Stop() + */ + void Stop(); + + /** + * @copydoc ThreadControllerInterface::RequestUpdate() + */ + void RequestUpdate(); + + /** + * @copydoc ThreadControllerInterface::RequestUpdateOnce() + */ + void RequestUpdateOnce(); + + /** + * @copydoc ThreadControllerInterface::ReplaceSurface() + */ + void ReplaceSurface( RenderSurface* surface ); + + /** + * @copydoc ThreadControllerInterface::SetRenderRefreshRate() + */ + void SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender ); + +private: + + // Undefined copy constructor. + SeparateUpdateRenderController( const SeparateUpdateRenderController& ); + + // Undefined assignment operator. + SeparateUpdateRenderController& operator=( const SeparateUpdateRenderController& ); + + AdaptorInternalServices& mAdaptorInterfaces; + + UpdateThread* mUpdateThread; ///< The update-thread owned by SeparateUpdateRenderController + RenderThread* mRenderThread; ///< The render-thread owned by SeparateUpdateRenderController + VSyncNotifier* mVSyncNotifier; ///< The vsync-thread owned by SeparateUpdateRenderController + ThreadSynchronization* mThreadSync; ///< Used to synchronize all the threads; owned by SeparateUpdateRenderController + unsigned int mNumberOfVSyncsPerRender; ///< Frame skipping count +}; + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali + +#endif // __DALI_INTERNAL_MULTI_THREAD_CONTROLLER_H__ diff --git a/adaptors/base/thread-synchronization-debug.h b/adaptors/base/separate-update-render/thread-synchronization-debug.h similarity index 100% rename from adaptors/base/thread-synchronization-debug.h rename to adaptors/base/separate-update-render/thread-synchronization-debug.h diff --git a/adaptors/base/thread-synchronization.cpp b/adaptors/base/separate-update-render/thread-synchronization.cpp similarity index 99% rename from adaptors/base/thread-synchronization.cpp rename to adaptors/base/separate-update-render/thread-synchronization.cpp index fdd8021..f6484ae 100644 --- a/adaptors/base/thread-synchronization.cpp +++ b/adaptors/base/separate-update-render/thread-synchronization.cpp @@ -20,7 +20,7 @@ // INTERNAL INCLUDES #include -#include +#include namespace Dali { diff --git a/adaptors/base/thread-synchronization.h b/adaptors/base/separate-update-render/thread-synchronization.h similarity index 99% rename from adaptors/base/thread-synchronization.h rename to adaptors/base/separate-update-render/thread-synchronization.h index 54f1f31..e5068fd 100644 --- a/adaptors/base/thread-synchronization.h +++ b/adaptors/base/separate-update-render/thread-synchronization.h @@ -25,8 +25,8 @@ #include #include #include -#include -#include +#include +#include namespace Dali { diff --git a/adaptors/base/update-thread.cpp b/adaptors/base/separate-update-render/update-thread.cpp similarity index 98% rename from adaptors/base/update-thread.cpp rename to adaptors/base/separate-update-render/update-thread.cpp index d37528c..a0bcd97 100644 --- a/adaptors/base/update-thread.cpp +++ b/adaptors/base/separate-update-render/update-thread.cpp @@ -24,7 +24,7 @@ // INTERNAL INCLUDES #include #include -#include +#include #include namespace Dali diff --git a/adaptors/base/update-thread.h b/adaptors/base/separate-update-render/update-thread.h similarity index 100% rename from adaptors/base/update-thread.h rename to adaptors/base/separate-update-render/update-thread.h diff --git a/adaptors/base/vsync-notifier.cpp b/adaptors/base/separate-update-render/vsync-notifier.cpp similarity index 98% rename from adaptors/base/vsync-notifier.cpp rename to adaptors/base/separate-update-render/vsync-notifier.cpp index 0bedb62..7ade234 100644 --- a/adaptors/base/vsync-notifier.cpp +++ b/adaptors/base/separate-update-render/vsync-notifier.cpp @@ -25,7 +25,7 @@ // INTERNAL INCLUDES #include -#include +#include #include namespace Dali diff --git a/adaptors/base/vsync-notifier.h b/adaptors/base/separate-update-render/vsync-notifier.h similarity index 100% rename from adaptors/base/vsync-notifier.h rename to adaptors/base/separate-update-render/vsync-notifier.h diff --git a/adaptors/base/thread-controller-interface.h b/adaptors/base/thread-controller-interface.h new file mode 100644 index 0000000..4542fe5 --- /dev/null +++ b/adaptors/base/thread-controller-interface.h @@ -0,0 +1,113 @@ +#ifndef __DALI_INTERNAL_THREAD_CONTROLLER_INTERFACE_H__ +#define __DALI_INTERNAL_THREAD_CONTROLLER_INTERFACE_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. + * + */ + +namespace Dali +{ + +class RenderSurface; + +namespace Internal +{ + +namespace Adaptor +{ + +/** + * Interface Class for all controlling threads. + */ +class ThreadControllerInterface +{ +public: + + /** + * Virtual destructor. Not intended as base class. + */ + virtual ~ThreadControllerInterface() { } + + /** + * Initializes the thread controller + */ + virtual void Initialize() = 0; + + /** + * @copydoc Dali::Adaptor::Start() + */ + virtual void Start() = 0; + + /** + * @copydoc Dali::Adaptor::Pause() + */ + virtual void Pause() = 0; + + /** + * @copydoc Dali::Adaptor::Resume() + */ + virtual void Resume() = 0; + + /** + * @copydoc Dali::Adaptor::Stop() + */ + virtual void Stop() = 0; + + /** + * Called by the adaptor when core requires another update + */ + virtual void RequestUpdate() = 0; + + /** + * Called by the adaptor when core requires one update + * If Adaptor is paused, we do one update and return to pause + */ + virtual void RequestUpdateOnce() = 0; + + /** + * Replaces the surface. + * @param surface new surface + */ + virtual void ReplaceSurface( RenderSurface* surface ) = 0; + + /** + * @copydoc Dali::Adaptor::SetRenderRefreshRate() + */ + virtual void SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender ) = 0; + +protected: + + /** + * Constructor + */ + ThreadControllerInterface() { } + +private: + + // Undefined copy constructor. + ThreadControllerInterface( const ThreadControllerInterface& ); + + // Undefined assignment operator. + ThreadControllerInterface& operator=( const ThreadControllerInterface& ); +}; + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali + +#endif // __DALI_INTERNAL_THREAD_CONTROLLER_INTERFACE_H__ diff --git a/adaptors/base/thread-controller.cpp b/adaptors/base/thread-controller.cpp index 1640c8d..3fa4641 100644 --- a/adaptors/base/thread-controller.cpp +++ b/adaptors/base/thread-controller.cpp @@ -19,12 +19,9 @@ #include "thread-controller.h" // INTERNAL INCLUDES -#include -#include -#include -#include -#include #include +#include +#include namespace Dali { @@ -36,103 +33,67 @@ namespace Adaptor { ThreadController::ThreadController( AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions ) -: mAdaptorInterfaces( adaptorInterfaces ), - mUpdateThread( NULL ), - mRenderThread( NULL ), - mVSyncNotifier( NULL ), - mThreadSync( NULL ), - mNumberOfVSyncsPerRender( 1 ) +: mThreadControllerInterface( NULL ) { - mThreadSync = new ThreadSynchronization( adaptorInterfaces, mNumberOfVSyncsPerRender ); - - mUpdateThread = new UpdateThread( *mThreadSync, adaptorInterfaces, environmentOptions ); - - mRenderThread = new RenderThread( *mThreadSync, adaptorInterfaces, environmentOptions ); - - mVSyncNotifier = new VSyncNotifier( *mThreadSync, adaptorInterfaces, environmentOptions ); - - // Set the thread-synchronization interface on the render-surface - RenderSurface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface(); - if( currentSurface ) + switch( environmentOptions.GetThreadingMode() ) { - currentSurface->SetThreadSynchronization( *mThreadSync ); + case ThreadingMode::SEPARATE_UPDATE_RENDER: + case ThreadingMode::COMBINED_UPDATE_RENDER: + case ThreadingMode::SINGLE_THREADED: + { + mThreadControllerInterface = new SeparateUpdateRenderController( adaptorInterfaces, environmentOptions ); + } } } ThreadController::~ThreadController() { - delete mVSyncNotifier; - delete mRenderThread; - delete mUpdateThread; - delete mThreadSync; + delete mThreadControllerInterface; } void ThreadController::Initialize() { - // Notify the synchronization object before starting the threads - mThreadSync->Initialise(); - - // We want to the threads to be set up before they start - mUpdateThread->Start(); - mRenderThread->Start(); - mVSyncNotifier->Start(); + mThreadControllerInterface->Initialize(); } void ThreadController::Start() { - mThreadSync->Start(); + mThreadControllerInterface->Start(); } void ThreadController::Pause() { - mThreadSync->Pause(); + mThreadControllerInterface->Pause(); } void ThreadController::Resume() { - mThreadSync->Resume(); + mThreadControllerInterface->Resume(); } void ThreadController::Stop() { - // Notify the synchronization object before stopping the threads - mThreadSync->Stop(); - - mVSyncNotifier->Stop(); - mUpdateThread->Stop(); - mRenderThread->Stop(); + mThreadControllerInterface->Stop(); } void ThreadController::RequestUpdate() { - mThreadSync->UpdateRequest(); + mThreadControllerInterface->RequestUpdate(); } void ThreadController::RequestUpdateOnce() { - // if we are paused, need to allow one update - mThreadSync->UpdateOnce(); + mThreadControllerInterface->RequestUpdateOnce(); } void ThreadController::ReplaceSurface( RenderSurface* newSurface ) { - // Set the thread-syncronization on the new surface - newSurface->SetThreadSynchronization( *mThreadSync ); - - // tell render thread to start the replace. This call will block until the replace - // has completed. - RenderSurface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface(); - - // Ensure the current surface releases any locks to prevent deadlock. - currentSurface->StopRender(); - - mThreadSync->ReplaceSurface( newSurface ); + mThreadControllerInterface->ReplaceSurface( newSurface ); } void ThreadController::SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender ) { - mNumberOfVSyncsPerRender = numberOfVSyncsPerRender; - mThreadSync->SetRenderRefreshRate(numberOfVSyncsPerRender); + mThreadControllerInterface->SetRenderRefreshRate( numberOfVSyncsPerRender ); } } // namespace Adaptor diff --git a/adaptors/base/thread-controller.h b/adaptors/base/thread-controller.h index 0413815..fba36c5 100644 --- a/adaptors/base/thread-controller.h +++ b/adaptors/base/thread-controller.h @@ -1,5 +1,5 @@ -#ifndef __DALI_INTERNAL_UPDATE_RENDER_CONTROLLER_H__ -#define __DALI_INTERNAL_UPDATE_RENDER_CONTROLLER_H__ +#ifndef __DALI_INTERNAL_THREAD_CONTROLLER_H__ +#define __DALI_INTERNAL_THREAD_CONTROLLER_H__ /* * Copyright (c) 2015 Samsung Electronics Co., Ltd. @@ -29,12 +29,9 @@ namespace Internal namespace Adaptor { -class UpdateThread; -class RenderThread; -class VSyncNotifier; -class ThreadSynchronization; class AdaptorInternalServices; class EnvironmentOptions; +class ThreadControllerInterface; /** * Class to control all the threads. @@ -108,13 +105,9 @@ private: // Undefined assignment operator. ThreadController& operator=( const ThreadController& ); - AdaptorInternalServices& mAdaptorInterfaces; +private: - 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 + ThreadControllerInterface* mThreadControllerInterface; }; } // namespace Adaptor @@ -123,4 +116,4 @@ private: } // namespace Dali -#endif // __DALI_INTERNAL_UPDATE_RENDER_CONTROLLER_H__ +#endif // __DALI_INTERNAL_THREAD_CONTROLLER_H__ diff --git a/adaptors/base/threading-mode.h b/adaptors/base/threading-mode.h new file mode 100644 index 0000000..73df356 --- /dev/null +++ b/adaptors/base/threading-mode.h @@ -0,0 +1,46 @@ +#ifndef __DALI_INTERNAL_ADAPTOR_THREADING_MODE_H__ +#define __DALI_INTERNAL_ADAPTOR_THREADING_MODE_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. + * + */ + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +struct ThreadingMode +{ + enum Type + { + SEPARATE_UPDATE_RENDER = 0, ///< Event, V-Sync, Update & Render on Separate threads. + COMBINED_UPDATE_RENDER, ///< Three threads: Event, V-Sync & a Joint Update/Render thread. + SINGLE_THREADED, ///< ALL functionality on the SAME thread. + }; +}; + +} // Adaptor + +} // Internal + +} // Dali + +#endif // __DALI_INTERNAL_ADAPTOR_THREADING_MODE_H__