From 8b31a18ba313a621729ea71bf53af3c8cf5819ea Mon Sep 17 00:00:00 2001 From: Eunki Hong Date: Thu, 7 Dec 2023 00:52:46 +0900 Subject: [PATCH] SecondPhase initialize for ProcessorController Let we allow to create ProcessController not-main thread. Rather then, let we create & register at App Initialized timing. Change-Id: I59b1d0f04ce08a759e238419ac2996dbdddbf91d Signed-off-by: Eunki Hong --- .../common/processor-controller.cpp | 62 ++++++++++++++----- .../common/processor-controller.h | 8 ++- 2 files changed, 55 insertions(+), 15 deletions(-) diff --git a/dali-csharp-binder/common/processor-controller.cpp b/dali-csharp-binder/common/processor-controller.cpp index fa2222e0..e1869d5c 100644 --- a/dali-csharp-binder/common/processor-controller.cpp +++ b/dali-csharp-binder/common/processor-controller.cpp @@ -21,26 +21,22 @@ // EXTERNAL INCLUDES #include #include +#include +#include -#ifdef __cplusplus -extern "C" { -#endif +namespace +{ +DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false); +} ProcessorController::ProcessorController() : mHandler(nullptr), mPostHandler(nullptr), + mProcessRegistered(false), mKeepRenderingApplied(false), mProcessingEvents(false), mProcessEventsIdleRequested(false) { - { - try - { - Dali::Adaptor::Get().RegisterProcessor(*this); - Dali::Adaptor::Get().RegisterProcessor(*this, true); - } - CALL_CATCH_EXCEPTION(); - } } ProcessorController::~ProcessorController() @@ -48,8 +44,13 @@ ProcessorController::~ProcessorController() { try { - Dali::Adaptor::Get().UnregisterProcessor(*this); - Dali::Adaptor::Get().UnregisterProcessor(*this, true); + if(mProcessRegistered) + { + Dali::Adaptor::Get().UnregisterProcessor(*this); + Dali::Adaptor::Get().UnregisterProcessor(*this, true); + + mProcessRegistered = false; + } } CALL_CATCH_EXCEPTION(); } @@ -67,13 +68,15 @@ void ProcessorController::Process(bool postProcessor) if(DALI_LIKELY(mHandler != nullptr)) { + DALI_TRACE_SCOPE(gTraceFilter, "NUI_PROCESS"); mHandler(); } } else { - if(DALI_LIKELY(mPostHandler != nullptr)) + if(mPostHandler != nullptr) { + DALI_TRACE_SCOPE(gTraceFilter, "NUI_POST_PROCESS"); mPostHandler(); } // Make awake events can be applied after PostProcess done. @@ -106,6 +109,8 @@ void ProcessorController::RemovePostCallback( ProcessorControllerProcessCallbac void ProcessorController::Awake() { + DALI_ASSERT_ALWAYS(mProcessRegistered && "ProcessorController should be initialized before call Awake"); + if(!mProcessingEvents && !mKeepRenderingApplied) { if(DALI_LIKELY(Dali::Stage::IsInstalled())) ///< Avoid worker thread calling. @@ -126,6 +131,25 @@ void ProcessorController::Awake() } } +void ProcessorController::RegisterProcess() +{ + if(!mProcessRegistered) + { + try + { + Dali::Adaptor::Get().RegisterProcessor(*this); + Dali::Adaptor::Get().RegisterProcessor(*this, true); + + mProcessRegistered = true; + } + CALL_CATCH_EXCEPTION(); + } +} + +#ifdef __cplusplus +extern "C" { +#endif + // ProcessorController Bindings SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_new_ProcessorController() { @@ -150,6 +174,16 @@ SWIGEXPORT void SWIGSTDCALL CSharp_Dali_delete_ProcessorController(void * jarg1) } } +SWIGEXPORT void SWIGSTDCALL CSharp_Dali_ProcessorController_Initialize(void* jarg1) +{ + ProcessorController* processorController = (ProcessorController *) jarg1; + + if( processorController ) + { + processorController->RegisterProcess(); + } +} + SWIGEXPORT void SWIGSTDCALL CSharp_Dali_ProcessorController_SetCallback( void* jarg1, ProcessorController::ProcessorControllerProcessCallback callback ) { ProcessorController* processorController = (ProcessorController *) jarg1; diff --git a/dali-csharp-binder/common/processor-controller.h b/dali-csharp-binder/common/processor-controller.h index e6569fc3..9939e67b 100644 --- a/dali-csharp-binder/common/processor-controller.h +++ b/dali-csharp-binder/common/processor-controller.h @@ -38,7 +38,7 @@ public: public: /** - * @brief Constructor - creates a ProcessorController and registers it with dali-core. + * @brief Constructor - creates a ProcessorController. * */ ProcessorController(); @@ -48,6 +48,11 @@ public: */ ~ProcessorController(); + /** + * @brief Register this processor into dali-core. + */ + void RegisterProcess(); + /** * @copydoc Dali::Integration::Processor::Process() */ @@ -89,6 +94,7 @@ private: ProcessorControllerProcessCallback mHandler; ///< PreProcessHandler before Relayout ProcessorControllerProcessCallback mPostHandler; ///< PostProcessHandler after Relayout + bool mProcessRegistered : 1; ///< True if we call RegisterProcess. False otherwise. bool mKeepRenderingApplied : 1; ///< True if we call Stage::KeepRendering(0.0f). It need to avoid duplicated keep rendering call bool mProcessingEvents : 1; ///< True if we are running Process now. bool mProcessEventsIdleRequested : 1; ///< True if we call Adaptor::RequestProcessEventsOnIdle(). It need to avoid duplicated request call. -- 2.34.1