2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-scene3d/public-api/loader/alpha-function-helper.h>
22 #include <unordered_map>
24 namespace Dali::Scene3D::Loader
29 #define DALI_ALPHA_FUNCTION_ENTRY(x) { #x, AlphaFunction::x }
32 std::unordered_map<std::string, AlphaFunction> sFunctions{
33 DALI_ALPHA_FUNCTION_ENTRY(DEFAULT),
34 DALI_ALPHA_FUNCTION_ENTRY(LINEAR),
35 DALI_ALPHA_FUNCTION_ENTRY(REVERSE),
36 DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_SQUARE),
37 DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_SQUARE),
38 DALI_ALPHA_FUNCTION_ENTRY(EASE_IN),
39 DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT),
40 DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_OUT),
41 DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_SINE),
42 DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_SINE),
43 DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_OUT_SINE),
44 DALI_ALPHA_FUNCTION_ENTRY(BOUNCE),
45 DALI_ALPHA_FUNCTION_ENTRY(SIN),
46 DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_BACK),
49 #undef DALI_ALPHA_FUNCTION_ENTRY
53 AlphaFunction GetAlphaFunction(const std::string& name, bool* found)
55 auto iFind = sFunctions.find(name);
56 bool success = iFind != sFunctions.end();
61 return success ? iFind->second : AlphaFunction(AlphaFunction::DEFAULT);
64 void RegisterAlphaFunction(const std::string& name, AlphaFunction alphaFn)
66 DALI_ASSERT_ALWAYS(sFunctions.insert({name, alphaFn}).second &&
67 "Function with given key already exists.");
70 } // namespace Dali::Scene3D::Loader