summaryrefslogtreecommitdiff
path: root/src/cairo-fixed-private.h
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2008-05-15 20:02:33 -0400
committerBehdad Esfahbod <behdad@behdad.org>2008-05-15 20:02:33 -0400
commitb355ac7a9fe8ecf550ec5f615969b82f0e45a6d6 (patch)
tree767acfd19e565b4b9dc131b0beaffe3073e8c6e5 /src/cairo-fixed-private.h
parent84606a900f0664a0010034f5eb4bdaf159e77bfe (diff)
downloadcairo-b355ac7a9fe8ecf550ec5f615969b82f0e45a6d6.tar.gz
[cairo-fixed] Implement _cairo_fixed_mul_div()
Computes a*b/c where a,b,c are cairo_fixed_t.
Diffstat (limited to 'src/cairo-fixed-private.h')
-rw-r--r--src/cairo-fixed-private.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/cairo-fixed-private.h b/src/cairo-fixed-private.h
index f1d5820d8..630f0327c 100644
--- a/src/cairo-fixed-private.h
+++ b/src/cairo-fixed-private.h
@@ -226,6 +226,17 @@ _cairo_fixed_mul (cairo_fixed_t a, cairo_fixed_t b)
return _cairo_int64_to_int32(_cairo_int64_rsl (temp, CAIRO_FIXED_FRAC_BITS));
}
+/* computes a * b / c */
+static inline cairo_fixed_t
+_cairo_fixed_mul_div (cairo_fixed_t a, cairo_fixed_t b, cairo_fixed_t c)
+{
+ cairo_int64_t ab = _cairo_int32x32_64_mul (a, b);
+ cairo_int64_t c64 = _cairo_int32_to_int64 (c);
+ cairo_int64_t quo = _cairo_int64_divrem (ab, c64).quo;
+
+ return _cairo_int64_to_int32(quo);
+}
+
#else
# error Please define multiplication and other operands for your fixed-point type size
#endif