ProcessEvents on idle when we call Awake during processing 44/299044/3
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 19 Sep 2023 02:03:05 +0000 (11:03 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Thu, 21 Sep 2023 16:00:21 +0000 (01:00 +0900)
Change-Id: Ic2b9de8e1c8a6d4fc3d694b4704a3dd5cd1b133d
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali-csharp-binder/common/processor-controller.cpp
dali-csharp-binder/common/processor-controller.h

index d8d699b..fa2222e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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 "processor-controller.h"
+#include <dali-csharp-binder/common/processor-controller.h>
 
 // EXTERNAL INCLUDES
 #include <dali/devel-api/common/stage-devel.h>
@@ -29,7 +29,9 @@ extern "C" {
 ProcessorController::ProcessorController()
 : mHandler(nullptr),
   mPostHandler(nullptr),
-  mKeepRenderingApplied(false)
+  mKeepRenderingApplied(false),
+  mProcessingEvents(false),
+  mProcessEventsIdleRequested(false)
 {
   {
     try
@@ -59,6 +61,10 @@ void ProcessorController::Process(bool postProcessor)
   {
     // We will ignore Awake events during Process running
     mKeepRenderingApplied = true;
+
+    // Mark as we are processing now.
+    mProcessingEvents = true;
+
     if(DALI_LIKELY(mHandler != nullptr))
     {
       mHandler();
@@ -72,6 +78,10 @@ void ProcessorController::Process(bool postProcessor)
     }
     // Make awake events can be applied after PostProcess done.
     mKeepRenderingApplied = false;
+
+    // Clean up processing and events idle request flag.
+    mProcessingEvents = false;
+    mProcessEventsIdleRequested = false;
   }
 }
 
@@ -96,15 +106,24 @@ void ProcessorController::RemovePostCallback(  ProcessorControllerProcessCallbac
 
 void ProcessorController::Awake()
 {
-  if(DALI_UNLIKELY(!mKeepRenderingApplied))
+  if(!mProcessingEvents && !mKeepRenderingApplied)
   {
-    if(DALI_LIKELY(Dali::Stage::IsInstalled()))
+    if(DALI_LIKELY(Dali::Stage::IsInstalled())) ///< Avoid worker thread calling.
     {
       auto stage = Dali::Stage::GetCurrent();
       stage.KeepRendering(0.0f);
       mKeepRenderingApplied = true;
     }
   }
+  else if(mProcessingEvents && !mProcessEventsIdleRequested)
+  {
+    if(DALI_LIKELY(Dali::Stage::IsInstalled())) ///< Avoid worker thread calling.
+    {
+      // Request ProcessEvents on idle when we are processing now.
+      Dali::Adaptor::Get().RequestProcessEventsOnIdle();
+      mProcessEventsIdleRequested = true;
+    }
+  }
 }
 
 // ProcessorController Bindings
index 25ab994..e6569fc 100644 (file)
@@ -2,7 +2,7 @@
 #define CSHARP_PROCESSOR_CONTROLLER_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -80,7 +80,7 @@ public:
   void RemovePostCallback( ProcessorControllerProcessCallback postCallback );
 
    /**
-    * @brief Awake update thread so dali-core calls the overriden Process() api.
+    * @brief Layout and awake update thread, or re-run registered processor.
     */
   void Awake();
 
@@ -88,7 +88,10 @@ private:
 
   ProcessorControllerProcessCallback mHandler;              ///< PreProcessHandler before Relayout
   ProcessorControllerProcessCallback mPostHandler;          ///< PostProcessHandler after Relayout
-  bool                               mKeepRenderingApplied; ///< True if we call Stage::KeepRendering(0.0f). It need to avoid duplicated keep rendering call
+
+  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.
 };
 
 #endif // CSHARP_PROCESSOR_CONTROLLER_H
\ No newline at end of file