aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Zapata <jorgeluis.zapata@gmail.com>2013-09-23 20:48:52 +0200
committerCedric Bail <cedric.bail@samsung.com>2013-09-24 12:20:27 +0900
commit538821f09d4dcd71642eb7f4d782ef350b956ddf (patch)
treef95b2eeac2dbd8ebf2f80edf2f78596cf36d0769
parentEvas textblock: Fixed broken test. (diff)
downloadefl-538821f09d4dcd71642eb7f4d782ef350b956ddf.tar.gz
eina: add double_from/to and helper defines in f16p16
-rw-r--r--src/lib/eina/eina_fp.h6
-rw-r--r--src/lib/eina/eina_inline_fp.x17
2 files changed, 23 insertions, 0 deletions
diff --git a/src/lib/eina/eina_fp.h b/src/lib/eina/eina_fp.h
index c73dc16fca..bc6c78d196 100644
--- a/src/lib/eina/eina_fp.h
+++ b/src/lib/eina/eina_fp.h
@@ -60,8 +60,14 @@ static inline unsigned int eina_f32p32_fracc_get(Eina_F32p32 v);
EAPI Eina_F32p32 eina_f32p32_cos(Eina_F32p32 a);
EAPI Eina_F32p32 eina_f32p32_sin(Eina_F32p32 a);
+
+#define EINA_F16P16_ONE (1 << 16)
+#define EINA_F16P16_HALF (1 << 15)
+
static inline Eina_F16p16 eina_f16p16_int_from(int32_t v);
static inline int32_t eina_f16p16_int_to(Eina_F16p16 v);
+static inline Eina_F16p16 eina_f16p16_double_from(double v);
+static inline double eina_f16p16_double_to(Eina_F16p16 v);
static inline Eina_F16p16 eina_f16p16_float_from(float v);
static inline float eina_f16p16_float_to(Eina_F16p16 v);
diff --git a/src/lib/eina/eina_inline_fp.x b/src/lib/eina/eina_inline_fp.x
index de44123b28..e459f82f77 100644
--- a/src/lib/eina/eina_inline_fp.x
+++ b/src/lib/eina/eina_inline_fp.x
@@ -80,6 +80,23 @@ eina_f16p16_float_to(Eina_F16p16 v)
return r;
}
+static inline Eina_F16p16
+eina_f16p16_double_from(double v)
+{
+ Eina_F16p16 r;
+
+ r = (Eina_F16p16)(v * 65536.0 + (v < 0 ? -0.5 : 0.5));
+ return r;
+}
+
+static inline double
+eina_f16p16_double_to(Eina_F16p16 v)
+{
+ double r;
+
+ r = v / 65536.0;
+ return r;
+}
static inline Eina_F8p24