(Build) Ensure default style is installed & remove autoconf file lists
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / third-party / yoga / Utils.cpp
1 /**
2  * Copyright (c) 2014-present, Facebook, Inc.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7
8 #include "Utils.h"
9
10 YGFlexDirection YGFlexDirectionCross(
11     const YGFlexDirection flexDirection,
12     const YGDirection direction) {
13   return YGFlexDirectionIsColumn(flexDirection)
14       ? YGResolveFlexDirection(YGFlexDirectionRow, direction)
15       : YGFlexDirectionColumn;
16 }
17
18 float YGFloatMax(const float a, const float b) {
19   if (!YGFloatIsUndefined(a) && !YGFloatIsUndefined(b)) {
20     return fmaxf(a, b);
21   }
22   return YGFloatIsUndefined(a) ? b : a;
23 }
24
25 float YGFloatMin(const float a, const float b) {
26   if (!YGFloatIsUndefined(a) && !YGFloatIsUndefined(b)) {
27     return fminf(a, b);
28   }
29
30   return YGFloatIsUndefined(a) ? b : a;
31 }
32
33 bool YGValueEqual(const YGValue a, const YGValue b) {
34   if (a.unit != b.unit) {
35     return false;
36   }
37
38   if (a.unit == YGUnitUndefined ||
39       (YGFloatIsUndefined(a.value) && YGFloatIsUndefined(b.value))) {
40     return true;
41   }
42
43   return fabs(a.value - b.value) < 0.0001f;
44 }
45
46 bool YGFloatsEqual(const float a, const float b) {
47   if (!YGFloatIsUndefined(a) && !YGFloatIsUndefined(b)) {
48     return fabs(a - b) < 0.0001f;
49   }
50   return YGFloatIsUndefined(a) && YGFloatIsUndefined(b);
51 }
52
53 float YGFloatSanitize(const float& val) {
54   return YGFloatIsUndefined(val) ? 0 : val;
55 }
56
57 float YGUnwrapFloatOptional(const YGFloatOptional& op) {
58   return op.isUndefined() ? YGUndefined : op.getValue();
59 }
60
61 YGFloatOptional YGFloatOptionalMax(
62     const YGFloatOptional& op1,
63     const YGFloatOptional& op2) {
64   if (!op1.isUndefined() && !op2.isUndefined()) {
65     return op1.getValue() > op2.getValue() ? op1 : op2;
66   }
67   return op1.isUndefined() ? op2 : op1;
68 }