7c11687cf4192577c03b674225e91ec51dc7c717
[platform/core/uifw/dali-adaptor.git] / third-party / glyphy / glyphy-common.hh
1 /*
2  * Copyright 2012 Google, Inc. All Rights Reserved.
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  * Google Author(s): Behdad Esfahbod, Maysum Panju
17  */
18
19 #ifndef GLYPHY_COMMON_HH
20 #define GLYPHY_COMMON_HH
21
22 #include "glyphy.h"
23
24 #include <cmath>
25 #include <string.h>
26 #include <assert.h>
27 #include <stdio.h>
28 #include <vector>
29 #include <algorithm>
30
31 #ifndef GLYPHY_EPSILON
32 #  define GLYPHY_EPSILON  1e-5
33 #endif
34 #ifndef GLYPHY_INFINITY
35 #  define GLYPHY_INFINITY INFINITY
36 #endif
37
38
39 static inline bool
40 iszero (double v)
41 {
42   return fabs (v) < 2 * GLYPHY_EPSILON;
43 }
44
45
46 #define GLYPHY_MAX_D .5
47
48 #undef  ARRAY_LENGTH
49 #define ARRAY_LENGTH(__array) ((signed int) (sizeof (__array) / sizeof (__array[0])))
50
51 #define _ASSERT_STATIC1(_line, _cond) typedef int _static_assert_on_line_##_line##_failed[(_cond)?1:-1]
52 #define _ASSERT_STATIC0(_line, _cond) _ASSERT_STATIC1 (_line, (_cond))
53 #define ASSERT_STATIC(_cond) _ASSERT_STATIC0 (__LINE__, (_cond))
54
55 #ifdef __ANDROID__
56 #define log2(x) (log(x) / log(2.0))
57 #endif
58
59 #endif /* GLYPHY_COMMON_HH */