X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-scene3d%2Fpublic-api%2Floader%2Falpha-function-helper.cpp;h=9c82704fd1b5f11f6f3cbd66929e784023c717cc;hb=HEAD;hp=1ac61ee04019fa63d16de6b2fca9125ebe8667fb;hpb=f2ee13ccda8c768fddc68f5208b7dcfa54c07242;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-scene3d/public-api/loader/alpha-function-helper.cpp b/dali-scene3d/public-api/loader/alpha-function-helper.cpp index 1ac61ee..9c82704 100644 --- a/dali-scene3d/public-api/loader/alpha-function-helper.cpp +++ b/dali-scene3d/public-api/loader/alpha-function-helper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 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. @@ -14,14 +14,14 @@ * limitations under the License. * */ -#include "dali-scene3d/public-api/loader/alpha-function-helper.h" + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES #include -namespace Dali -{ -namespace Scene3D -{ -namespace Loader +namespace Dali::Scene3D::Loader { namespace { @@ -29,22 +29,26 @@ namespace #define DALI_ALPHA_FUNCTION_ENTRY(x) { #x, AlphaFunction::x } // clang-format on -std::unordered_map sFunctions{ - DALI_ALPHA_FUNCTION_ENTRY(DEFAULT), - DALI_ALPHA_FUNCTION_ENTRY(LINEAR), - DALI_ALPHA_FUNCTION_ENTRY(REVERSE), - DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_SQUARE), - DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_SQUARE), - DALI_ALPHA_FUNCTION_ENTRY(EASE_IN), - DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT), - DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_OUT), - DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_SINE), - DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_SINE), - DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_OUT_SINE), - DALI_ALPHA_FUNCTION_ENTRY(BOUNCE), - DALI_ALPHA_FUNCTION_ENTRY(SIN), - DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_BACK), -}; +std::unordered_map& GetFunctions() +{ + static std::unordered_map sFunctions{ + DALI_ALPHA_FUNCTION_ENTRY(DEFAULT), + DALI_ALPHA_FUNCTION_ENTRY(LINEAR), + DALI_ALPHA_FUNCTION_ENTRY(REVERSE), + DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_SQUARE), + DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_SQUARE), + DALI_ALPHA_FUNCTION_ENTRY(EASE_IN), + DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT), + DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_OUT), + DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_SINE), + DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_SINE), + DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_OUT_SINE), + DALI_ALPHA_FUNCTION_ENTRY(BOUNCE), + DALI_ALPHA_FUNCTION_ENTRY(SIN), + DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_BACK), + }; + return sFunctions; +} #undef DALI_ALPHA_FUNCTION_ENTRY @@ -52,8 +56,8 @@ std::unordered_map sFunctions{ AlphaFunction GetAlphaFunction(const std::string& name, bool* found) { - auto iFind = sFunctions.find(name); - bool success = iFind != sFunctions.end(); + auto iFind = GetFunctions().find(name); + bool success = iFind != GetFunctions().end(); if(found) { *found = success; @@ -63,10 +67,8 @@ AlphaFunction GetAlphaFunction(const std::string& name, bool* found) void RegisterAlphaFunction(const std::string& name, AlphaFunction alphaFn) { - DALI_ASSERT_ALWAYS(sFunctions.insert({name, alphaFn}).second && + DALI_ASSERT_ALWAYS(GetFunctions().insert({name, alphaFn}).second && "Function with given key already exists."); } -} // namespace Loader -} // namespace Scene3D -} // namespace Dali +} // namespace Dali::Scene3D::Loader