Fixups of static analysis errors 96/316196/2
authorDavid Steele <david.steele@samsung.com>
Thu, 15 Aug 2024 09:45:28 +0000 (10:45 +0100)
committerDavid Steele <david.steele@samsung.com>
Thu, 15 Aug 2024 10:06:05 +0000 (11:06 +0100)
Change-Id: I9dbd2ab00fc3aecb80d74d9ff4625649afd31d22

dali-scene3d/internal/common/model-load-task.cpp
dali-toolkit/internal/text/async-text/async-text-manager-impl.cpp
dali-toolkit/internal/text/async-text/async-text-manager-impl.h
dali-toolkit/internal/text/async-text/text-load-observer.cpp
dali-toolkit/internal/text/async-text/text-load-observer.h
dali-toolkit/internal/text/async-text/text-loading-task.cpp
dali-toolkit/internal/text/async-text/text-loading-task.h
dali-toolkit/internal/visuals/text/text-visual.cpp
dali-toolkit/internal/visuals/text/text-visual.h

index 5d279e4db58f015b530dd4ad2e05fac9630852b2..fd634f85c1c123d008339d38cf712b08973883ff 100644 (file)
@@ -77,9 +77,8 @@ void ModelLoadTask::Process()
   if(gTraceFilter && gTraceFilter->IsTraceEnabled())
   {
     mStartTimeNanoSceonds = GetNanoseconds();
-    DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_MODEL_LOADING_TASK", [&](std::ostringstream& oss) {
-      oss << "[u:" << mModelUrl << ",dir:" << mResourceDirectoryUrl << "]";
-    });
+    DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_MODEL_LOADING_TASK", [&](std::ostringstream& oss)
+                                            { oss << "[u:" << mModelUrl << ",dir:" << mResourceDirectoryUrl << "]"; });
   }
 #endif
 
@@ -89,21 +88,29 @@ void ModelLoadTask::Process()
     mResourceDirectoryUrl = std::string(modelUrl.parent_path()) + "/";
   }
 
-  Dali::Scene3D::Loader::ResourceBundle::PathProvider pathProvider = [&](Dali::Scene3D::Loader::ResourceType::Value type) {
+  Dali::Scene3D::Loader::ResourceBundle::PathProvider pathProvider = [&](Dali::Scene3D::Loader::ResourceType::Value type)
+  {
     return mResourceDirectoryUrl;
   };
 
   mModelLoader = std::make_shared<Dali::Scene3D::Loader::ModelLoader>(mModelUrl, mResourceDirectoryUrl, mLoadResult);
 
-  bool loadSucceeded  = false;
+  bool loadSucceeded = false;
+
+#ifdef TRACE_ENABLED
   bool useCachedModel = false;
+#endif
+
   {
     // Lock model url during process, so let we do not try to load same model multiple times.
     mModelCacheManager.LockModelLoadScene(mModelUrl);
     if(mModelCacheManager.IsSceneLoaded(mModelUrl))
     {
+#ifdef TRACE_ENABLED
       useCachedModel = true;
-      loadSucceeded  = true;
+#endif
+
+      loadSucceeded = true;
     }
     else
     {
@@ -128,15 +135,15 @@ void ModelLoadTask::Process()
   if(gTraceFilter && gTraceFilter->IsTraceEnabled())
   {
     mEndTimeNanoSceonds = GetNanoseconds();
-    DALI_TRACE_END_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_MODEL_LOADING_TASK", [&](std::ostringstream& oss) {
+    DALI_TRACE_END_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_MODEL_LOADING_TASK", [&](std::ostringstream& oss)
+                                          {
       oss << std::fixed << std::setprecision(3);
       oss << "[";
       oss << "d:" << static_cast<float>(mEndTimeNanoSceonds - mStartTimeNanoSceonds) / 1000000.0f << "ms ";
       oss << "c?" << useCachedModel << " ";
       oss << "s?" << loadSucceeded << " ";
       oss << "dir:" << mResourceDirectoryUrl << " ";
-      oss << "u:" << mModelUrl << "]";
-    });
+      oss << "u:" << mModelUrl << "]"; });
   }
 #endif
   if(!loadSucceeded)
index a75a7eee4fafade692770e58a8986eb172bca93c..ad31e8606664f4bd4c570ef389041736bafec21e 100644 (file)
@@ -27,7 +27,6 @@
 
 // INTERNAL INCLUDES
 
-
 namespace Dali
 {
 namespace Toolkit
@@ -37,7 +36,8 @@ namespace
 const char*    DALI_TEXT_NUMBER_OF_ASYNC_TEXT_LOADER("DALI_TEXT_NUMBER_OF_ASYNC_TEXT_LOADER");
 const int      DEFAULT_NUMBER_OF_LOADER = 4;
 const int      MINIMUM_NUMBER_OF_LOADER = 1;
-const uint32_t EMPTY_TASK_ID = 0u;
+const int      MAXIMUM_NUMBER_OF_LOADER = 16;
+const uint32_t EMPTY_TASK_ID            = 0u;
 
 DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_TEXT_ASYNC, false);
 } // namespace
@@ -59,10 +59,10 @@ AsyncTextManager::AsyncTextManager()
   auto numberOfLoaderString = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_TEXT_NUMBER_OF_ASYNC_TEXT_LOADER);
   int  numberOfLoader       = numberOfLoaderString ? std::atoi(numberOfLoaderString) : DEFAULT_NUMBER_OF_LOADER;
 
-  numberOfLoader = std::max(numberOfLoader, MINIMUM_NUMBER_OF_LOADER);
+  numberOfLoader = std::clamp(numberOfLoader, MINIMUM_NUMBER_OF_LOADER, MAXIMUM_NUMBER_OF_LOADER);
   DALI_LOG_RELEASE_INFO("Number of async text loaders:%d\n", numberOfLoader);
 
-  for(int i = 0; i < numberOfLoader; i ++)
+  for(int i = 0; i < numberOfLoader; i++)
   {
     Text::AsyncTextLoader loader = Text::AsyncTextLoader::New();
     mAvailableLoaders.push_back(loader);
@@ -356,7 +356,7 @@ void AsyncTextManager::ObserverDestroyed(TextLoadObserver* observer)
     if(it->second.mObserver == observer)
     {
       it->second.mObserver = nullptr;
-      it = mRunningTasks.erase(it);
+      it                   = mRunningTasks.erase(it);
     }
     else
     {
@@ -370,7 +370,7 @@ void AsyncTextManager::ObserverDestroyed(TextLoadObserver* observer)
     {
       Dali::AsyncTaskManager::Get().RemoveTask(it->second.mTask);
       it->second.mObserver = nullptr;
-      it = mWaitingTasks.erase(it);
+      it                   = mWaitingTasks.erase(it);
     }
     else
     {
index 7e9eff6f87bbf263de03a30a6cbf56b60964c23f..c0ae8708f08a3519d27f590eeea7fcb5181529a9 100644 (file)
@@ -92,7 +92,7 @@ private:
     {
     }
 
-    LoadElement(Toolkit::Internal::TextLoadingTaskPtr task, TextLoadObserver* observer, AsyncTextParameters parameters)
+    LoadElement(Toolkit::Internal::TextLoadingTaskPtr task, TextLoadObserver* observer, const AsyncTextParameters& parameters)
     : mTask(task),
       mObserver(observer),
       mParameters(parameters)
@@ -134,8 +134,8 @@ private:
 
   std::vector<Text::AsyncTextLoader> mAvailableLoaders; ///< List of available async text loader.
   std::vector<Text::AsyncTextLoader> mRunningLoaders;   ///< List of running async text loader.
-  std::map<uint32_t, LoadElement>    mWaitingTasks; ///< Waiting tasks, key is task id.
-  std::map<uint32_t, LoadElement>    mRunningTasks; ///< Running tasks, key is task id.
+  std::map<uint32_t, LoadElement>    mWaitingTasks;     ///< Waiting tasks, key is task id.
+  std::map<uint32_t, LoadElement>    mRunningTasks;     ///< Running tasks, key is task id.
 };
 
 } // namespace Internal
index 6087f5ef7bdd399f7b5458884c4d240843b371e1..d56e6c86bebf8fdfeb3b4287bd62fa69a2dd42d3 100644 (file)
@@ -24,7 +24,7 @@ namespace Dali
 {
 namespace Toolkit
 {
-TextLoadObserver::TextInformation::TextInformation(Text::AsyncTextRenderInfo renderInfo, Text::AsyncTextParameters parameters)
+TextLoadObserver::TextInformation::TextInformation(const Text::AsyncTextRenderInfo& renderInfo, const Text::AsyncTextParameters& parameters)
 : renderInfo(renderInfo),
   parameters(parameters)
 {
index bb7b021b41c1ca2b5bdc1c8a3b03a98ba46d29cf..8545660dd854dae341e936cac865105060dcd968 100644 (file)
@@ -24,7 +24,6 @@
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/async-text/async-text-loader.h>
 
-
 namespace Dali
 {
 namespace Toolkit
@@ -42,7 +41,7 @@ public:
 
   struct TextInformation
   {
-    TextInformation(Text::AsyncTextRenderInfo renderInfo, Text::AsyncTextParameters parameters);
+    TextInformation(const Text::AsyncTextRenderInfo& renderInfo, const Text::AsyncTextParameters& parameters);
     TextInformation();
 
     Text::AsyncTextRenderInfo renderInfo;
@@ -68,7 +67,7 @@ public:
    * @param[in] loadSuccess True if the text load was successful.
    * @param[in] textureInformation Structure that contains loaded text information.
    */
-  virtual void LoadComplete(bool loadSuccess, TextInformation textInformation) = 0;
+  virtual void LoadComplete(bool loadSuccess, const TextInformation& textInformation) = 0;
 
   /**
    * @brief Returns the destruction signal.
@@ -89,7 +88,6 @@ public:
   bool DisconnectDestructionSignal();
 
 public:
-
 private:
   DestructionSignalType mDestructionSignal;        ///< The destruction signal emitted when the observer is destroyed.
   int                   mDestructionSignalConnect; ///< The number of times DestructionSignal is connected.
index 80ad7acf60548afa176cb618f3aef8e6233e7f4a..10740e42b2f290dc1e479b86d23d6019aae716d8 100644 (file)
@@ -24,7 +24,6 @@
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/trace.h>
 
-
 namespace Dali
 {
 namespace Toolkit
@@ -36,7 +35,7 @@ namespace
 DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_TEXT_ASYNC, false);
 } // namespace
 
-TextLoadingTask::TextLoadingTask(const uint32_t id, Text::AsyncTextParameters parameters, CallbackBase* callback)
+TextLoadingTask::TextLoadingTask(const uint32_t id, const Text::AsyncTextParameters& parameters, CallbackBase* callback)
 : AsyncTask(callback),
   mId(id),
   mParameters(parameters),
@@ -67,7 +66,7 @@ uint32_t TextLoadingTask::GetId()
 void TextLoadingTask::SetLoader(Text::AsyncTextLoader& loader)
 {
   Dali::Mutex::ScopedLock lock(mMutex);
-  mLoader = loader;
+  mLoader  = loader;
   mIsReady = true;
 }
 
index ec96216f98122fb9c8e7b25a3941d5d70a3ecd72..196461e3a1276a330667325e0f4ded9b8b779458 100644 (file)
@@ -25,7 +25,6 @@
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/async-text/async-text-loader.h>
 
-
 namespace Dali
 {
 namespace Toolkit
@@ -47,9 +46,9 @@ public:
    * @param [in] paramaters The async text parameters.
    * @param [in] callback The callback that is called when the operation is completed.
    */
-  TextLoadingTask(const uint32_t            id,
-                  Text::AsyncTextParameters paramaters,
-                  CallbackBase*             callback);
+  TextLoadingTask(const uint32_t                   id,
+                  const Text::AsyncTextParameters& paramaters,
+                  CallbackBase*                    callback);
 
   /**
    * Constructor, empty task for wake up the async task manger.
@@ -116,8 +115,8 @@ public:
   Text::AsyncTextRenderInfo mRenderInfo;
 
 private:
-  bool            mIsReady : 1; ///< Whether this task ready to run
-  Mutex           mMutex;
+  bool  mIsReady : 1; ///< Whether this task ready to run
+  Mutex mMutex;
 };
 
 } // namespace Internal
index 4b82d89073d1a51d72f6d4fdebd02332dd8e38ba..ce7acd0ba1e9cf2e3dc27c9fdaba5a7eee0434a0 100644 (file)
@@ -58,7 +58,7 @@ DALI_INIT_TRACE_FILTER(gTraceFilter2, DALI_TRACE_TEXT_ASYNC, false);
 const int CUSTOM_PROPERTY_COUNT(3); // uTextColorAnimatable, uHasMultipleTextColors, requireRender
 
 const float VERTICAL_ALIGNMENT_TABLE[Text::VerticalAlignment::BOTTOM + 1] =
-{
+  {
     0.0f, // VerticalAlignment::TOP
     0.5f, // VerticalAlignment::CENTER
     1.0f  // VerticalAlignment::BOTTOM
@@ -631,8 +631,8 @@ void TextVisual::UpdateRenderer()
         // When Cutout Enabled, the current visual must draw the entire control.
         // so set the size to controlSize and offset to 0.
 
-        relayoutSize = Vector2(controlWidth, controlHeight);
-        mImpl->mTransform.mSize.width = controlWidth;
+        relayoutSize                   = Vector2(controlWidth, controlHeight);
+        mImpl->mTransform.mSize.width  = controlWidth;
         mImpl->mTransform.mSize.height = controlHeight;
 
         // Relayout to the original size has been completed, so save only the offset information and use it in typesetter.
@@ -708,7 +708,7 @@ void TextVisual::CreateTextureSet(TilingInfo& info, VisualRenderer& renderer, Sa
 
   renderer.SetTextures(textureSet);
 
-  //Register transform properties
+  // Register transform properties
   mImpl->mTransform.SetUniforms(renderer, Direction::LEFT_TO_RIGHT);
 
   // Enable the pre-multiplied alpha to improve the text quality
@@ -725,7 +725,7 @@ void TextVisual::CreateTextureSet(TilingInfo& info, VisualRenderer& renderer, Sa
 }
 
 // From async text manager
-void TextVisual::LoadComplete(bool loadingSuccess, TextInformation textInformation)
+void TextVisual::LoadComplete(bool loadingSuccess, const TextInformation& textInformation)
 {
   Text::AsyncTextParameters parameters = textInformation.parameters;
 
@@ -736,7 +736,7 @@ void TextVisual::LoadComplete(bool loadingSuccess, TextInformation textInformati
   }
 #endif
 
-  switch (parameters.requestType)
+  switch(parameters.requestType)
   {
     case Text::Async::RENDER_FIXED_SIZE:
     case Text::Async::RENDER_FIXED_WIDTH:
@@ -880,7 +880,7 @@ void TextVisual::LoadComplete(bool loadingSuccess, TextInformation textInformati
       }
 
       mImpl->mRenderer.SetTextures(textureSet);
-      //Register transform properties
+      // Register transform properties
       mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
       mImpl->mRenderer.SetProperty(mHasMultipleTextColorsIndex, static_cast<float>(mTextShaderFeatureCache.IsEnabledMultiColor()));
       mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
@@ -1047,7 +1047,7 @@ void TextVisual::RequestAsyncSizeComputation(Text::AsyncTextParameters& paramete
       mIsNaturalSizeTaskRunning = true;
 
       TextLoadObserver* textLoadObserver = this;
-      mNaturalSizeTaskId = Text::AsyncTextManager::Get().RequestLoad(parameters, textLoadObserver);
+      mNaturalSizeTaskId                 = Text::AsyncTextManager::Get().RequestLoad(parameters, textLoadObserver);
       break;
     }
     case Text::Async::COMPUTE_HEIGHT_FOR_WIDTH:
@@ -1059,7 +1059,7 @@ void TextVisual::RequestAsyncSizeComputation(Text::AsyncTextParameters& paramete
       mIsHeightForWidthTaskRunning = true;
 
       TextLoadObserver* textLoadObserver = this;
-      mHeightForWidthTaskId = Text::AsyncTextManager::Get().RequestLoad(parameters, textLoadObserver);
+      mHeightForWidthTaskId              = Text::AsyncTextManager::Get().RequestLoad(parameters, textLoadObserver);
       break;
     }
     default:
@@ -1141,9 +1141,9 @@ bool TextVisual::UpdateAsyncRenderer(Text::AsyncTextParameters& parameters)
   }
 #endif
 
-  mIsTextLoadingTaskRunning = true;
+  mIsTextLoadingTaskRunning          = true;
   TextLoadObserver* textLoadObserver = this;
-  mTextLoadingTaskId = Text::AsyncTextManager::Get().RequestLoad(parameters, textLoadObserver);
+  mTextLoadingTaskId                 = Text::AsyncTextManager::Get().RequestLoad(parameters, textLoadObserver);
 
   return true;
 }
@@ -1164,7 +1164,7 @@ void TextVisual::AddRenderer(Actor& actor, const Vector2& size, bool hasMultiple
     TextureSet textureSet = GetTextTexture(size);
 
     mImpl->mRenderer.SetTextures(textureSet);
-    //Register transform properties
+    // Register transform properties
     mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
     mImpl->mRenderer.SetProperty(mHasMultipleTextColorsIndex, static_cast<float>(hasMultipleTextColors));
     mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
index a6553ac8daf4646488724158563643cb3e85b8db..0bc00d4b7fc367abb256e61e1d1af3166de892a8 100644 (file)
@@ -237,14 +237,14 @@ protected:
 private:
   struct TilingInfo
   {
-    PixelData     textPixelData;
-    PixelData     stylePixelData;
-    PixelData     overlayStylePixelData;
-    PixelData     maskPixelData;
-    int32_t       width;
-    int32_t       height;
-    uint32_t      offsetHeight;
-    Vector2       transformOffset;
+    PixelData textPixelData;
+    PixelData stylePixelData;
+    PixelData overlayStylePixelData;
+    PixelData maskPixelData;
+    int32_t   width;
+    int32_t   height;
+    uint32_t  offsetHeight;
+    Vector2   transformOffset;
 
     TilingInfo(int32_t width, int32_t height)
     : textPixelData(),
@@ -376,7 +376,7 @@ private:
    * @param[in] success True if the load was successful, false otherwise.
    * @param[in] textInformation The text information including render info and parameters.
    */
-  void LoadComplete(bool success, TextInformation textInformation) override;
+  void LoadComplete(bool success, const TextInformation& textInformation) override;
 
 private:
   typedef std::vector<Renderer> RendererContainer;
@@ -400,12 +400,12 @@ private:
   bool              mTextRequireRender : 1;            ///< The flag to indicate whether the text needs to be rendered.
   RendererContainer mRendererList;
 
-  uint32_t          mTextLoadingTaskId;               ///< The currently requested text loading(render) task Id.
-  uint32_t          mNaturalSizeTaskId;               ///< The currently requested natural size task Id.
-  uint32_t          mHeightForWidthTaskId;            ///< The currently requested height for width task Id.
-  bool              mIsTextLoadingTaskRunning    : 1; ///< Whether the requested text loading task is running or not.
-  bool              mIsNaturalSizeTaskRunning    : 1; ///< Whether the requested natural size task is running or not.
-  bool              mIsHeightForWidthTaskRunning : 1; ///< Whether the requested height for width task is running or not.
+  uint32_t mTextLoadingTaskId;               ///< The currently requested text loading(render) task Id.
+  uint32_t mNaturalSizeTaskId;               ///< The currently requested natural size task Id.
+  uint32_t mHeightForWidthTaskId;            ///< The currently requested height for width task Id.
+  bool     mIsTextLoadingTaskRunning : 1;    ///< Whether the requested text loading task is running or not.
+  bool     mIsNaturalSizeTaskRunning : 1;    ///< Whether the requested natural size task is running or not.
+  bool     mIsHeightForWidthTaskRunning : 1; ///< Whether the requested height for width task is running or not.
 };
 
 } // namespace Internal