Add time function to check text performance 63/296963/2
authorBowon Ryu <bowon.ryu@samsung.com>
Tue, 8 Aug 2023 04:45:05 +0000 (13:45 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Tue, 8 Aug 2023 06:16:21 +0000 (15:16 +0900)
Change-Id: Ifc7f72ab466b5b7a2226a232e8e36eff079f2e37
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
dali/devel-api/text-abstraction/font-client.cpp
dali/devel-api/text-abstraction/font-client.h

index 11ea888..116c00a 100644 (file)
@@ -19,6 +19,7 @@
 #include <dali/devel-api/text-abstraction/font-client.h>
 
 // INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
 #include <dali/internal/text/text-abstraction/font-client-impl.h>
 
 namespace Dali
@@ -50,6 +51,30 @@ const Size FontClient::MAX_SIZE_FIT_IN_ATLAS(MAX_TEXT_ATLAS_WIDTH - PADDING_TEXT
 
 const uint32_t FontClient::NUMBER_OF_POINTS_PER_ONE_UNIT_OF_POINT_SIZE = 64u; //Found this value from toolkit
 
+// For Debug
+static    bool     TEXT_PERFORMANCE_LOG_SET                = false;
+static    uint32_t TEXT_PERFORMANCE_LOG_THRESHOLD_TIME     = 0u;
+constexpr auto     TEXT_PERFORMANCE_LOG_THRESHOLD_TIME_ENV = "DALI_TEXT_PERFORMANCE_LOG_THRESHOLD_TIME";
+
+uint32_t FontClient::GetPerformanceLogThresholdTime()
+{
+  uint32_t time = TEXT_PERFORMANCE_LOG_THRESHOLD_TIME;
+  if(!TEXT_PERFORMANCE_LOG_SET)
+  {
+    // Threshold time in miliseconds.
+    auto timeString = Dali::EnvironmentVariable::GetEnvironmentVariable(TEXT_PERFORMANCE_LOG_THRESHOLD_TIME_ENV);
+    time = timeString ? static_cast<uint32_t>(std::atoi(timeString)) : 0u;
+    TEXT_PERFORMANCE_LOG_THRESHOLD_TIME = time;
+    TEXT_PERFORMANCE_LOG_SET = true;
+  }
+  return time;
+}
+
+bool FontClient::IsPerformanceLogEnabled()
+{
+  return GetPerformanceLogThresholdTime() > 0 ? true : false;
+}
+
 // FontClient
 
 FontClient FontClient::Get()
index ffe3f3b..bce3e4e 100644 (file)
@@ -79,6 +79,10 @@ public:
 
   static const uint32_t NUMBER_OF_POINTS_PER_ONE_UNIT_OF_POINT_SIZE; ///< Factor multiply point-size in toolkit.
 
+  // For Debug
+  static uint32_t GetPerformanceLogThresholdTime(); ///< Return performance log threshold time in miliseconds for debug.
+  static bool     IsPerformanceLogEnabled();        ///< Whether performance log is enabled.
+
   /**
    * @brief Used to load an embedded item into the font client.
    */