summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Andrieu <oandrieu@gmail.com>2005-07-18 19:11:05 +0000
committerHezekiah M. Carty <hcarty@atmos.umd.edu>2009-06-18 13:58:05 -0400
commit1648d302f2bace0d2b9eae4f6127a93392cbc127 (patch)
tree4cd66836e37ef7b71bd7b3c5d447db46a0a4ed45
parentaac26abb43dc65d4274145298cd067d3a295a5a5 (diff)
Bump requirements to Cairo 0.5.2
* configure.ac, README: require cairo 0.5.2 * src/*: adapt to cairo 0.5.1 and 0.5.2 API changes (new status values and functions, new pattern functions) * test/knockout.ml: adapt to API change
-rw-r--r--ChangeLog9
-rw-r--r--README2
-rw-r--r--configure.ac2
-rw-r--r--src/cairo.ml31
-rw-r--r--src/cairo.mli31
-rw-r--r--src/ml_cairo.c8
-rw-r--r--src/ml_cairo.h1
-rw-r--r--src/ml_cairo_path.c2
-rw-r--r--src/ml_cairo_pattern.c99
-rw-r--r--src/ml_cairo_status.c21
-rw-r--r--src/ml_cairo_surface.c14
-rw-r--r--src/ml_cairo_wrappers.h36
-rw-r--r--src/ml_svg_cairo.c11
-rw-r--r--src/svg_cairo.ml3
-rw-r--r--src/svg_cairo.mli3
-rw-r--r--test/knockout.ml8
16 files changed, 168 insertions, 113 deletions
diff --git a/ChangeLog b/ChangeLog
index 4618631..a96242d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-07-18 Olivier Andrieu <oliv__a@users.sourceforge.net>
+
+ * configure.ac, README: require cairo 0.5.2
+
+ * src/*: adapt to cairo 0.5.1 and 0.5.2 API changes (new status
+ values and functions, new pattern functions)
+
+ * test/knockout.ml: adapt to API change
+
2005-05-27 Olivier Andrieu <oliv__a@users.sourceforge.net>
* src/cairo.ml, src/cairo.mli: remove BAD_NESTING error status
diff --git a/README b/README
index d9e6e1c..5eeeb35 100644
--- a/README
+++ b/README
@@ -15,7 +15,7 @@ Dependencies
============
ocaml 3.08
- cairo 0.5.0
+ cairo 0.5.2
libsvg-cairo optional 0.1.5
LablGTK optional
diff --git a/configure.ac b/configure.ac
index b5392e5..03a133b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,7 +5,7 @@ AC_CONFIG_AUX_DIR(support)
AC_PROG_OCAML()
# Check for cairo
-PKG_CHECK_MODULES(CAIRO, cairo >= 0.5.0)
+PKG_CHECK_MODULES(CAIRO, cairo >= 0.5.2)
# Optional GTK support (for the X11 backend)
AC_ARG_WITH(gtk,
diff --git a/src/cairo.ml b/src/cairo.ml
index 8a1f849..30768d4 100644
--- a/src/cairo.ml
+++ b/src/cairo.ml
@@ -7,12 +7,13 @@
(**************************************************************************)
type status =
- NO_MEMORY
+ SUCCESS
+ | NO_MEMORY
| INVALID_RESTORE
| INVALID_POP_GROUP
| NO_CURRENT_POINT
| INVALID_MATRIX
- | NO_TARGET_SURFACE
+ | INVALID_STATUS
| NULL_POINTER
| INVALID_STRING
| INVALID_PATH_DATA
@@ -20,6 +21,7 @@ type status =
| WRITE_ERROR
| SURFACE_FINISHED
| SURFACE_TYPE_MISMATCH
+ | PATTERN_TYPE_MISMATCH
exception Error of status
let init = Callback.register_exception "cairo_status_exn" (Error NULL_POINTER)
@@ -196,19 +198,19 @@ let append_path cr = function
| `CLOSE -> close_path cr
| `CURVE_TO (p1, p2, p3) -> curve_to_point cr p1 p2 p3
-external status : t -> status option = "ml_cairo_status"
-external status_string : t -> string = "ml_cairo_status_string"
+external status : t -> status = "ml_cairo_status"
+external pattern_status : [> `Any] pattern -> status = "ml_cairo_pattern_status"
+external string_of_status : status -> string = "ml_cairo_status_to_string"
(* surface *)
-type format =
- FORMAT_ARGB32
- | FORMAT_RGB24
- | FORMAT_A8
- | FORMAT_A1
+type content =
+ CONTENT_COLOR
+ | CONTENT_ALPHA
+ | CONTENT_COLOR_ALPHA
-external surface_create_similar : 'a surface -> format -> width:int -> height:int -> 'a surface = "ml_cairo_surface_create_similar"
+external surface_create_similar : 'a surface -> content -> width:int -> height:int -> 'a surface = "ml_cairo_surface_create_similar"
external surface_finish : 'a surface -> unit = "ml_cairo_surface_finish"
@@ -217,6 +219,12 @@ external surface_set_device_offset : 'a surface -> float -> float -> unit = "ml_
type image_surface = [`Any|`Image] surface
+type format =
+ FORMAT_ARGB32
+ | FORMAT_RGB24
+ | FORMAT_A8
+ | FORMAT_A1
+
external image_surface_create : format -> width:int -> height:int -> image_surface = "ml_cairo_image_surface_create"
external image_surface_get_width : [>`Image] surface -> int = "ml_cairo_image_surface_get_width"
external image_surface_get_height : [>`Image] surface -> int = "ml_cairo_image_surface_get_height"
@@ -237,10 +245,13 @@ type filter =
| FILTER_BILINEAR
| FILTER_GAUSSIAN
+type solid_pattern = [`Any|`Solid] pattern
type surface_pattern = [`Any|`Surface] pattern
type gradient_pattern = [`Any|`Gradient] pattern
module Pattern = struct
+external create_rgb : red:float -> green:float -> blue:float -> solid_pattern = "ml_cairo_pattern_create_rgb"
+external create_rgba : red:float -> green:float -> blue:float -> alpha:float -> solid_pattern = "ml_cairo_pattern_create_rgba"
external create_for_surface : 'a surface -> surface_pattern = "ml_cairo_pattern_create_for_surface"
external create_linear : x0:float -> y0:float -> x1:float -> y1:float -> gradient_pattern = "ml_cairo_pattern_create_linear"
external create_radial : cx0:float -> cy0:float -> radius0:float -> cx1:float -> cy1:float -> radius1:float -> gradient_pattern = "ml_cairo_pattern_create_radial_bc" "ml_cairo_pattern_create_radial"
diff --git a/src/cairo.mli b/src/cairo.mli
index 991f20f..1396cc5 100644
--- a/src/cairo.mli
+++ b/src/cairo.mli
@@ -11,12 +11,13 @@
(** {3 Error reporting} *)
type status =
- NO_MEMORY
+ SUCCESS
+ | NO_MEMORY
| INVALID_RESTORE
| INVALID_POP_GROUP
| NO_CURRENT_POINT
| INVALID_MATRIX
- | NO_TARGET_SURFACE
+ | INVALID_STATUS
| NULL_POINTER
| INVALID_STRING
| INVALID_PATH_DATA
@@ -24,6 +25,7 @@ type status =
| WRITE_ERROR
| SURFACE_FINISHED
| SURFACE_TYPE_MISMATCH
+ | PATTERN_TYPE_MISMATCH
exception Error of status
val init : unit
@@ -47,8 +49,9 @@ val create : 'a surface -> t
external save : t -> unit = "ml_cairo_save"
external restore : t -> unit = "ml_cairo_restore"
-external status : t -> status option = "ml_cairo_status"
-external status_string : t -> string = "ml_cairo_status_string"
+external status : t -> status = "ml_cairo_status"
+external pattern_status : [> `Any] pattern -> status = "ml_cairo_pattern_status"
+external string_of_status : status -> string = "ml_cairo_status_to_string"
(** {4 Renderer state} *)
@@ -219,13 +222,12 @@ val append_path : t -> [< path] -> unit
(** {3 Surface API} *)
-type format =
- FORMAT_ARGB32
- | FORMAT_RGB24
- | FORMAT_A8
- | FORMAT_A1
+type content =
+ CONTENT_COLOR
+ | CONTENT_ALPHA
+ | CONTENT_COLOR_ALPHA
-external surface_create_similar : 'a surface -> format -> width:int -> height:int -> 'a surface = "ml_cairo_surface_create_similar"
+external surface_create_similar : 'a surface -> content -> width:int -> height:int -> 'a surface = "ml_cairo_surface_create_similar"
external surface_finish : 'a surface -> unit = "ml_cairo_surface_finish"
@@ -235,12 +237,19 @@ external surface_set_device_offset : 'a surface -> float -> float -> unit = "ml_
type image_surface = [`Any|`Image] surface
+type format =
+ FORMAT_ARGB32
+ | FORMAT_RGB24
+ | FORMAT_A8
+ | FORMAT_A1
+
external image_surface_create : format -> width:int -> height:int -> image_surface = "ml_cairo_image_surface_create"
external image_surface_get_width : [>`Image] surface -> int = "ml_cairo_image_surface_get_width"
external image_surface_get_height : [>`Image] surface -> int = "ml_cairo_image_surface_get_height"
(** {4 Patterns} *)
+type solid_pattern = [`Any|`Solid] pattern
type surface_pattern = [`Any|`Surface] pattern
type gradient_pattern = [`Any|`Gradient] pattern
@@ -259,6 +268,8 @@ type filter =
(** Patterns functions *)
module Pattern : sig
+external create_rgb : red:float -> green:float -> blue:float -> solid_pattern = "ml_cairo_pattern_create_rgb"
+external create_rgba : red:float -> green:float -> blue:float -> alpha:float -> solid_pattern = "ml_cairo_pattern_create_rgba"
external create_for_surface : 'a surface -> surface_pattern = "ml_cairo_pattern_create_for_surface"
external create_linear : x0:float -> y0:float -> x1:float -> y1:float -> gradient_pattern = "ml_cairo_pattern_create_linear"
external create_radial : cx0:float -> cy0:float -> radius0:float -> cx1:float -> cy1:float -> radius1:float -> gradient_pattern = "ml_cairo_pattern_create_radial_bc" "ml_cairo_pattern_create_radial"
diff --git a/src/ml_cairo.c b/src/ml_cairo.c
index 42ae6e3..e83ec97 100644
--- a/src/ml_cairo.c
+++ b/src/ml_cairo.c
@@ -10,7 +10,13 @@
wMake_Val_final_pointer(cairo_t, cairo_destroy, 0)
-wML_1(cairo_create, cairo_surface_t_val, Val_cairo_t)
+CAMLprim value
+ml_cairo_create (value surf)
+{
+ cairo_t *p = cairo_create (cairo_surface_t_val (surf));
+ cairo_treat_status (cairo_status (p));
+ return Val_cairo_t (p);
+}
/* cairo_reference */
/* cairo_destroy */
diff --git a/src/ml_cairo.h b/src/ml_cairo.h
index 916b5fe..c3c2309 100644
--- a/src/ml_cairo.h
+++ b/src/ml_cairo.h
@@ -63,6 +63,7 @@ value Val_cairo_text_extents (cairo_text_extents_t *);
void ml_cairo_treat_status (cairo_status_t) Noreturn;
#define cairo_treat_status(s) if (s != CAIRO_STATUS_SUCCESS) ml_cairo_treat_status (s)
#define check_cairo_status(cr) cairo_treat_status (cairo_status (cairo_t_val (cr)))
+#define check_pattern_status(cr) cairo_treat_status (cairo_pattern_status (cairo_pattern_t_val (cr)))
#define report_null_pointer() ml_cairo_treat_status (CAIRO_STATUS_NULL_POINTER)
/* stream callbacks */
diff --git a/src/ml_cairo_path.c b/src/ml_cairo_path.c
index c61a0c6..ecff731 100644
--- a/src/ml_cairo_path.c
+++ b/src/ml_cairo_path.c
@@ -20,6 +20,8 @@ ml_cairo_fold_path (cairo_path_t *path, value f, value acc)
CAMLlocal5(var, t, p1, p2, p3);
int i;
+ cairo_treat_status (path->status);
+
for (i = 0; i < path->num_data; i += path->data[i].header.length)
{
cairo_path_data_t *data = &path->data[i];
diff --git a/src/ml_cairo_pattern.c b/src/ml_cairo_pattern.c
index 29127d0..99092e4 100644
--- a/src/ml_cairo_pattern.c
+++ b/src/ml_cairo_pattern.c
@@ -6,70 +6,91 @@
/* GNU Lesser General Public License version 2.1 (the "LGPL"). */
/**************************************************************************/
+#define W_CHECK_STATUS check_pattern_status
+#define W_CONV_CAIRO cairo_pattern_t_val
+
#include "ml_cairo.h"
wMake_Val_final_pointer(cairo_pattern_t, cairo_pattern_destroy, 0)
-wML_1(cairo_pattern_create_for_surface, cairo_surface_t_val, Val_cairo_pattern_t)
-
-wML_4(cairo_pattern_create_linear, Double_val, Double_val, Double_val, Double_val, Val_cairo_pattern_t)
+CAMLprim value
+ml_cairo_pattern_create_rgb (value r, value g, value b)
+{
+ cairo_pattern_t *p = cairo_pattern_create_rgb (Double_val (r), Double_val (g), Double_val (b));
+ cairo_treat_status (cairo_pattern_status (p));
+ return Val_cairo_pattern_t (p);
+}
-wML_6(cairo_pattern_create_radial, Double_val, Double_val, Double_val, Double_val, Double_val, Double_val, Val_cairo_pattern_t)
+CAMLprim value
+ml_cairo_pattern_create_rgba (value r, value g, value b, value a)
+{
+ cairo_pattern_t *p = cairo_pattern_create_rgba (Double_val (r), Double_val (g),
+ Double_val (b), Double_val (a));
+ cairo_treat_status (cairo_pattern_status (p));
+ return Val_cairo_pattern_t (p);
+}
-/* pattern_reference */
-/* pattern_destroy */
+CAMLprim value
+ml_cairo_pattern_create_for_surface (value surf)
+{
+ cairo_pattern_t *p = cairo_pattern_create_for_surface (cairo_surface_t_val (surf));
+ cairo_treat_status (cairo_pattern_status (p));
+ return Val_cairo_pattern_t (p);
+}
CAMLprim value
-ml_cairo_pattern_add_color_stop_rgb (value p, value off, value r, value g, value b)
+ml_cairo_pattern_create_linear (value x0, value y0, value x1, value y1)
{
- cairo_status_t s;
- s = cairo_pattern_add_color_stop_rgb (cairo_pattern_t_val (p), Double_val (off),
- Double_val (r), Double_val (g), Double_val (b));
- cairo_treat_status (s);
- return Val_unit;
+ cairo_pattern_t *p = cairo_pattern_create_linear (Double_val (x0), Double_val (y0),
+ Double_val (x1), Double_val (y1));
+ cairo_treat_status (cairo_pattern_status (p));
+ return Val_cairo_pattern_t (p);
}
CAMLprim value
-ml_cairo_pattern_add_color_stop_rgba (value p, value off, value r, value g, value b, value a)
+ml_cairo_pattern_create_radial (value cx0, value cy0, value r0,
+ value cx1, value cy1, value r1)
{
- cairo_status_t s;
- s = cairo_pattern_add_color_stop_rgba (cairo_pattern_t_val (p), Double_val (off),
- Double_val (r), Double_val (g), Double_val (b),
- Double_val (a));
- cairo_treat_status (s);
- return Val_unit;
+ cairo_pattern_t *p = cairo_pattern_create_radial (Double_val (cx0), Double_val (cy0), Double_val (r0),
+ Double_val (cx1), Double_val (cy1), Double_val (r1));
+ cairo_treat_status (cairo_pattern_status (p));
+ return Val_cairo_pattern_t (p);
}
-wML_bc6(cairo_pattern_add_color_stop_rgba)
+wML_bc6(cairo_pattern_create_radial)
+
+/* pattern_reference */
+/* pattern_destroy */
+
+wML_4_cairo(pattern_add_color_stop_rgb, Double_val, Double_val, Double_val, Double_val)
+wML_5_cairo(pattern_add_color_stop_rgba, Double_val, Double_val, Double_val, Double_val, Double_val)
CAMLprim value
ml_cairo_pattern_set_matrix (value p, value m)
{
- cairo_status_t s;
#ifdef ARCH_ALIGN_DOUBLE
cairo_matrix_t mat;
ml_convert_cairo_matrix_in (m, &mat);
- s = cairo_pattern_set_matrix (cairo_pattern_t_val (p), &mat);
+ cairo_pattern_set_matrix (cairo_pattern_t_val (p), &mat);
#else
- s = cairo_pattern_set_matrix (cairo_pattern_t_val (p), cairo_matrix_t_val (m));
+ cairo_pattern_set_matrix (cairo_pattern_t_val (p), cairo_matrix_t_val (m));
#endif
- cairo_treat_status (s);
+ check_pattern_status (p);
return Val_unit;
}
CAMLprim value
ml_cairo_pattern_get_matrix (value p)
{
- cairo_status_t s;
#ifdef ARCH_ALIGN_DOUBLE
cairo_matrix_t mat;
- s = cairo_pattern_get_matrix (cairo_pattern_t_val (p), &mat);
- cairo_treat_status (s);
+ cairo_pattern_get_matrix (cairo_pattern_t_val (p), &mat);
+ check_pattern_status (p);
return ml_convert_cairo_matrix_out (m, &mat);
#else
CAMLparam1(p);
value m = caml_alloc_small (6 * Double_wosize, Double_array_tag);
- s = cairo_pattern_get_matrix (cairo_pattern_t_val (p), cairo_matrix_t_val (m));
- cairo_treat_status (s);
+ cairo_pattern_get_matrix (cairo_pattern_t_val (p), cairo_matrix_t_val (m));
+ check_pattern_status (p);
CAMLreturn (m);
#endif
}
@@ -77,27 +98,11 @@ ml_cairo_pattern_get_matrix (value p)
#define cairo_extend_t_val(v) ((cairo_extend_t) Int_val(v))
#define Val_cairo_extend_t(v) Val_int(v)
-CAMLprim value
-ml_cairo_pattern_set_extend (value p, value e)
-{
- cairo_status_t s;
- s = cairo_pattern_set_extend (cairo_pattern_t_val (p), cairo_extend_t_val (e));
- cairo_treat_status (s);
- return Val_unit;
-}
-
+wML_1_cairo(pattern_set_extend, cairo_extend_t_val)
wML_1(cairo_pattern_get_extend, cairo_pattern_t_val, Val_cairo_extend_t)
#define cairo_filter_t_val(v) ((cairo_filter_t) Int_val(v))
#define Val_cairo_filter_t(v) Val_int(v)
-CAMLprim value
-ml_cairo_pattern_set_filter (value p, value e)
-{
- cairo_status_t s;
- s = cairo_pattern_set_filter (cairo_pattern_t_val (p), cairo_filter_t_val (e));
- cairo_treat_status (s);
- return Val_unit;
-}
-
+wML_1_cairo(pattern_set_filter, cairo_filter_t_val)
wML_1(cairo_pattern_get_filter, cairo_pattern_t_val, Val_cairo_filter_t)
diff --git a/src/ml_cairo_status.c b/src/ml_cairo_status.c
index a869529..86aa4cc 100644
--- a/src/ml_cairo_status.c
+++ b/src/ml_cairo_status.c
@@ -8,23 +8,10 @@
#include "ml_cairo.h"
-CAMLprim value
-ml_cairo_status (value v_cr)
-{
- value v;
- cairo_status_t status = cairo_status (cairo_t_val (v_cr));
-
- if (status == CAIRO_STATUS_SUCCESS)
- v = Val_unit;
- else
- {
- v = caml_alloc_small (1, 0);
- Field (v, 0) = Val_int (status - 1);
- }
- return v;
-}
+wML_1 (cairo_status, cairo_t_val, Val_int)
+wML_1 (cairo_pattern_status, cairo_pattern_t_val, Val_int)
-wML_1(cairo_status_string, cairo_t_val, caml_copy_string)
+wML_1 (cairo_status_to_string, Int_val, caml_copy_string)
void
ml_cairo_treat_status (cairo_status_t status)
@@ -42,5 +29,5 @@ ml_cairo_treat_status (cairo_status_t status)
if (cairo_exn == NULL)
caml_failwith ("cairo exception");
}
- caml_raise_with_arg (*cairo_exn, Val_int (status - 1));
+ caml_raise_with_arg (*cairo_exn, Val_int (status));
}
diff --git a/src/ml_cairo_surface.c b/src/ml_cairo_surface.c
index 2ab37ac..26b55d0 100644
--- a/src/ml_cairo_surface.c
+++ b/src/ml_cairo_surface.c
@@ -10,8 +10,20 @@
wMake_Val_final_pointer(cairo_surface_t, cairo_surface_destroy, 0)
+static cairo_content_t
+cairo_content_t_val (value v)
+{
+ switch (Long_val (v))
+ {
+ case 0: return CAIRO_CONTENT_COLOR;
+ case 1: return CAIRO_CONTENT_ALPHA;
+ case 2: return CAIRO_CONTENT_COLOR_ALPHA;
+ default: assert (0);
+ }
+}
+
wML_4(cairo_surface_create_similar, \
- cairo_surface_t_val, cairo_format_t_val, \
+ cairo_surface_t_val, cairo_content_t_val, \
Int_val, Int_val, Val_cairo_surface_t)
/* surface_reference */
diff --git a/src/ml_cairo_wrappers.h b/src/ml_cairo_wrappers.h
index a824519..eb2ffc7 100644
--- a/src/ml_cairo_wrappers.h
+++ b/src/ml_cairo_wrappers.h
@@ -101,50 +101,56 @@ CAMLprim value ml_##cname##_bc (value *argv, int argn) \
CAMLprim value ml_##cname##_bc (value *argv, int argn) \
{ return ml_##cname(argv[0],argv[1],argv[2],argv[3],argv[4],argv[5],argv[6]); }
+#ifndef W_CHECK_STATUS
+# define W_CHECK_STATUS check_cairo_status
+#endif
+#ifndef W_CONV_CAIRO
+# define W_CONV_CAIRO cairo_t_val
+#endif
+
#define wML_0_cairo(cname) \
CAMLprim value ml_cairo_##cname (value v_cr) \
-{ cairo_##cname (cairo_t_val (v_cr)); \
- check_cairo_status (v_cr); \
+{ cairo_##cname (W_CONV_CAIRO(v_cr)); \
+ W_CHECK_STATUS(v_cr); \
return Val_unit; \
}
#define wML_1_cairo(cname, conv1) \
CAMLprim value ml_cairo_##cname (value v_cr, value arg1) \
-{ cairo_##cname (cairo_t_val (v_cr), conv1 (arg1)); \
- check_cairo_status (v_cr); \
+{ cairo_##cname (W_CONV_CAIRO(v_cr), conv1 (arg1)); \
+ W_CHECK_STATUS(v_cr); \
return Val_unit; \
}
#define wML_2_cairo(cname, conv1, conv2) \
CAMLprim value ml_cairo_##cname (value v_cr, value arg1, value arg2) \
-{ cairo_##cname (cairo_t_val (v_cr), conv1 (arg1), conv2 (arg2)); \
- check_cairo_status (v_cr); \
+{ cairo_##cname (W_CONV_CAIRO(v_cr), conv1 (arg1), conv2 (arg2)); \
+ W_CHECK_STATUS(v_cr); \
return Val_unit; \
}
#define wML_3_cairo(cname, conv1, conv2, conv3) \
CAMLprim value ml_cairo_##cname (value v_cr, value arg1, value arg2, value arg3) \
-{ cairo_##cname (cairo_t_val (v_cr), conv1 (arg1), conv2 (arg2), conv3 (arg3)); \
- check_cairo_status (v_cr); \
+{ cairo_##cname (W_CONV_CAIRO(v_cr), conv1 (arg1), conv2 (arg2), conv3 (arg3)); \
+ W_CHECK_STATUS(v_cr); \
return Val_unit; \
}
#define wML_4_cairo(cname, conv1, conv2, conv3, conv4) \
CAMLprim value ml_cairo_##cname (value v_cr, value arg1, value arg2, value arg3, value arg4) \
-{ cairo_##cname (cairo_t_val (v_cr), conv1 (arg1), conv2 (arg2), conv3 (arg3), conv4 (arg4)); \
- check_cairo_status (v_cr); \
+{ cairo_##cname (W_CONV_CAIRO(v_cr), conv1 (arg1), conv2 (arg2), conv3 (arg3), conv4 (arg4)); \
+ W_CHECK_STATUS(v_cr); \
return Val_unit; \
}
#define wML_5_cairo(cname, conv1, conv2, conv3, conv4, conv5) \
CAMLprim value ml_cairo_##cname (value v_cr, value arg1, value arg2, value arg3, value arg4, value arg5) \
-{ cairo_##cname (cairo_t_val (v_cr), conv1 (arg1), conv2 (arg2), conv3 (arg3), conv4 (arg4), conv5 (arg5)); \
- check_cairo_status (v_cr); \
+{ cairo_##cname (W_CONV_CAIRO(v_cr), conv1 (arg1), conv2 (arg2), conv3 (arg3), conv4 (arg4), conv5 (arg5)); \
+ W_CHECK_STATUS(v_cr); \
return Val_unit; \
} \
CAMLprim value ml_cairo_##cname##_bc (value *argv, int argn) \
{ return ml_cairo_##cname (argv[0],argv[1],argv[2],argv[3],argv[4],argv[5]); }
#define wML_6_cairo(cname, conv1, conv2, conv3, conv4, conv5, conv6) \
CAMLprim value ml_cairo_##cname (value v_cr, value arg1, value arg2, value arg3, value arg4, value arg5, value arg6) \
-{ cairo_##cname (cairo_t_val (v_cr), conv1 (arg1), conv2 (arg2), conv3 (arg3), conv4 (arg4), conv5 (arg5), conv6 (arg6)); \
- check_cairo_status (v_cr); \
+{ cairo_##cname (W_CONV_CAIRO(v_cr), conv1 (arg1), conv2 (arg2), conv3 (arg3), conv4 (arg4), conv5 (arg5), conv6 (arg6)); \
+ W_CHECK_STATUS(v_cr); \
return Val_unit; \
} \
CAMLprim value ml_cairo_##cname##_bc (value *argv, int argn) \
{ return ml_cairo_##cname (argv[0],argv[1],argv[2],argv[3],argv[4],argv[5], argv[6]); }
-
diff --git a/src/ml_svg_cairo.c b/src/ml_svg_cairo.c
index 5851cac..0a96ef6 100644
--- a/src/ml_svg_cairo.c
+++ b/src/ml_svg_cairo.c
@@ -20,6 +20,9 @@ ml_svg_cairo_status (svg_cairo_status_t s)
static value *exn;
assert (s != SVG_CAIRO_STATUS_SUCCESS);
+ if (s == SVG_CAIRO_STATUS_NO_MEMORY)
+ caml_raise_out_of_memory ();
+
if (exn == NULL)
{
exn = caml_named_value ("svg_cairo_status_exn");
@@ -27,7 +30,7 @@ ml_svg_cairo_status (svg_cairo_status_t s)
caml_failwith ("svg-cairo exception");
}
- caml_raise_with_arg (*exn, Val_int (s - 1));
+ caml_raise_with_arg (*exn, Val_int (s));
}
#define check_svg_cairo_status(s) if (s != SVG_CAIRO_STATUS_SUCCESS) ml_svg_cairo_status (s)
@@ -119,11 +122,11 @@ ml_svg_cairo_set_viewport_dimension (value v, value w, value h)
CAMLprim value
ml_svg_cairo_get_size (value s)
{
- int w, h;
+ unsigned int w, h;
value r;
svg_cairo_get_size (svg_cairo_t_val (s), &w, &h);
r = caml_alloc_small (2, 0);
- Field (r, 0) = Val_int (w);
- Field (r, 1) = Val_int (h);
+ Field (r, 0) = Val_long (w);
+ Field (r, 1) = Val_long (h);
return r;
}
diff --git a/src/svg_cairo.ml b/src/svg_cairo.ml
index 84b92c1..beed341 100644
--- a/src/svg_cairo.ml
+++ b/src/svg_cairo.ml
@@ -7,7 +7,8 @@
(**************************************************************************)
type status =
- NO_MEMORY
+ SUCCESS
+ | NO_MEMORY
| IO_ERROR
| FILE_NOT_FOUND
| INVALID_VALUE
diff --git a/src/svg_cairo.mli b/src/svg_cairo.mli
index 3814cf9..56b0239 100644
--- a/src/svg_cairo.mli
+++ b/src/svg_cairo.mli
@@ -10,7 +10,8 @@
cairo *)
type status =
- NO_MEMORY
+ SUCCESS
+ | NO_MEMORY
| IO_ERROR
| FILE_NOT_FOUND
| INVALID_VALUE
diff --git a/test/knockout.ml b/test/knockout.ml
index 74fff24..88e7c43 100644
--- a/test/knockout.ml
+++ b/test/knockout.ml
@@ -25,7 +25,7 @@ let fill_checks c x y width height =
let check =
Cairo.surface_create_similar
(Cairo.get_target c)
- Cairo.FORMAT_RGB24 (2 * check_size) (2 * check_size) in
+ Cairo.CONTENT_COLOR (2 * check_size) (2 * check_size) in
begin
let f_size = float check_size in
@@ -72,9 +72,9 @@ let draw c width height =
let yc = float height /. 2. in
let sur = Cairo.get_target c in
- let overlay = Cairo.surface_create_similar sur Cairo.FORMAT_ARGB32 width height in
- let punch = Cairo.surface_create_similar sur Cairo.FORMAT_A8 width height in
- let circles = Cairo.surface_create_similar sur Cairo.FORMAT_ARGB32 width height in
+ let overlay = Cairo.surface_create_similar sur Cairo.CONTENT_COLOR_ALPHA width height in
+ let punch = Cairo.surface_create_similar sur Cairo.CONTENT_ALPHA width height in
+ let circles = Cairo.surface_create_similar sur Cairo.CONTENT_COLOR_ALPHA width height in
fill_checks c 0. 0. width height ;