[cairo-commit] cairo-ocaml/src ml_cairo_wrappers.c, 1.1, 1.2 ml_cairo_status.c, 1.2, 1.3 ml_cairo_path.c, 1.1, 1.2 ml_cairo_channel.c, 1.2, 1.3 ml_cairo_bigarr.c, 1.3, 1.4 ml_cairo.h, 1.4, 1.5 ml_cairo.c, 1.12, 1.13 cairo_lablgtk.mli, 1.2, 1.3 cairo_channel.mli, 1.1.1.1, 1.2 cairo_bigarray.mli, 1.1.1.1, 1.2 cairo_bigarray.ml, 1.1.1.1, 1.2 cairo.mli, 1.10, 1.11

Olivier Andrieu commit at pdx.freedesktop.org
Thu Oct 28 06:46:03 PDT 2004


Committed by: oandrieu

Update of /cvs/cairo/cairo-ocaml/src
In directory gabe:/tmp/cvs-serv7750/src

Modified Files:
	ml_cairo_wrappers.c ml_cairo_status.c ml_cairo_path.c 
	ml_cairo_channel.c ml_cairo_bigarr.c ml_cairo.h ml_cairo.c 
	cairo_lablgtk.mli cairo_channel.mli cairo_bigarray.mli 
	cairo_bigarray.ml cairo.mli 
Log Message:
* src/*.c: beautify code, run it through indent.

* src/ml_cairo.[ch]: direcly map enums to caml variants.

* configure.ac: do not fail if GTK+ is missing.

* test/spline.ml: do not use POINTER_MOTION_HINT, apparently that's evil.


Index: ml_cairo_wrappers.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_wrappers.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ml_cairo_wrappers.c	18 Oct 2004 00:27:34 -0000	1.1
+++ ml_cairo_wrappers.c	28 Oct 2004 13:46:00 -0000	1.2
@@ -2,17 +2,22 @@
 #include <caml/alloc.h>
 #include "ml_cairo_wrappers.h"
 
-int ml_pointer_compare (value a, value b)
+int
+ml_pointer_compare (value a, value b)
 {
-  void *p1 = Pointer_val(a);
-  void *p2 = Pointer_val(b);
-  if (p1 == p2) return 0;
-  else if (p1 < p2) return -1;
-  else return 1;
+  void *p1 = Pointer_val (a);
+  void *p2 = Pointer_val (b);
+  if (p1 == p2)
+    return 0;
+  else if (p1 < p2)
+    return -1;
+  else
+    return 1;
 }
 
-long ml_pointer_hash (value a)
+long
+ml_pointer_hash (value a)
 {
-  void *p = Pointer_val(a);
+  void *p = Pointer_val (a);
   return (long) p;
 }

Index: ml_cairo_status.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_status.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ml_cairo_status.c	18 Oct 2004 00:27:34 -0000	1.2
+++ ml_cairo_status.c	28 Oct 2004 13:46:00 -0000	1.3
@@ -6,45 +6,52 @@
 #include "ml_cairo_status.h"
 
 void
-cairo_treat_status(cairo_status_t s)
+cairo_treat_status (cairo_status_t s)
 {
   static value *cairo_exn;
   int status;
 
-  switch (s) {
+  switch (s)
+    {
     case CAIRO_STATUS_SUCCESS:
       return;
     case CAIRO_STATUS_NO_MEMORY:
-      raise_out_of_memory();
+      raise_out_of_memory ();
     case CAIRO_STATUS_INVALID_RESTORE:
-      status = 0; break;
+      status = 0;
+      break;
     case CAIRO_STATUS_INVALID_POP_GROUP:
-      status = 1; break;
+      status = 1;
+      break;
     case CAIRO_STATUS_NO_CURRENT_POINT:
-      status = 2; break;
+      status = 2;
+      break;
     case CAIRO_STATUS_INVALID_MATRIX:
-      status = 3; break;
+      status = 3;
+      break;
     case CAIRO_STATUS_NO_TARGET_SURFACE:
-      status = 4; break;
+      status = 4;
+      break;
     case CAIRO_STATUS_NULL_POINTER:
-      status = 5; break;
-  }
-  
+      status = 5;
+      break;
+    }
+
   if (cairo_exn == NULL)
     {
-      cairo_exn = caml_named_value("cairo_status_exn");
+      cairo_exn = caml_named_value ("cairo_status_exn");
       if (cairo_exn == NULL)
-	failwith("cairo exception");
+	failwith ("cairo exception");
     }
 
-  raise_with_arg (*cairo_exn, Val_int(status));
+  raise_with_arg (*cairo_exn, Val_int (status));
 }
 
 void
 check_cairo_status (value cr)
 {
-  struct ml_cairo *ml_c = Data_custom_val(cr);
-  if (! ml_c->suspend_exn) 
+  struct ml_cairo *ml_c = Data_custom_val (cr);
+  if (!ml_c->suspend_exn)
     {
       cairo_status_t status;
       status = cairo_status (ml_c->cr);

Index: ml_cairo_path.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_path.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ml_cairo_path.c	22 Feb 2004 22:45:56 -0000	1.1
+++ ml_cairo_path.c	28 Oct 2004 13:46:00 -0000	1.2
@@ -17,123 +17,128 @@
 #define CAML_CLOSE_TAG    0x8ca29f31L
 #define CAML_CURVE_TO_TAG 0x84e3bcd7L
 
-struct caml_fold_info {
+struct caml_fold_info
+{
   value closure;
   value val;
 };
 
-static value make_point(double x, double y)
+static value
+make_point (double x, double y)
 {
   value p;
-  p = alloc_small(2 * Double_wosize, Double_array_tag);
-  Store_double_field(p, 0, x);
-  Store_double_field(p, 1, y);
+  p = alloc_small (2 * Double_wosize, Double_array_tag);
+  Store_double_field (p, 0, x);
+  Store_double_field (p, 1, y);
   return p;
 }
 
 static void
-ml_cairo_move_to_cb(void *data, double x, double y)
+ml_cairo_move_to_cb (void *data, double x, double y)
 {
   struct caml_fold_info *p = data;
-  CAMLparam0();
-  CAMLlocal2(path_elem, point);
-  if (! Is_exception_result(p->val)) {
-    point = make_point(x, y);
-    path_elem = alloc_small(2, 0);
-    Field(path_elem, 0) = CAML_MOVE_TO_TAG;
-    Field(path_elem, 1) = point;
-    p->val = callback2_exn(p->closure, p->val, path_elem);
-  }
+  CAMLparam0 ();
+  CAMLlocal2 (path_elem, point);
+  if (!Is_exception_result (p->val))
+    {
+      point = make_point (x, y);
+      path_elem = alloc_small (2, 0);
+      Field (path_elem, 0) = CAML_MOVE_TO_TAG;
+      Field (path_elem, 1) = point;
+      p->val = callback2_exn (p->closure, p->val, path_elem);
+    }
   CAMLreturn0;
 }
 
 static void
-ml_cairo_line_to_cb(void *data, double x, double y)
+ml_cairo_line_to_cb (void *data, double x, double y)
 {
   struct caml_fold_info *p = data;
-  CAMLparam0();
-  CAMLlocal2(path_elem, point);
-  if (! Is_exception_result(p->val)) {
-    point = make_point(x, y);
-    path_elem = alloc_small(2, 0);
-    Field(path_elem, 0) = CAML_LINE_TO_TAG;
-    Field(path_elem, 1) = point;
-    p->val = callback2_exn(p->closure, p->val, path_elem);
-  }
+  CAMLparam0 ();
+  CAMLlocal2 (path_elem, point);
+  if (!Is_exception_result (p->val))
+    {
+      point = make_point (x, y);
+      path_elem = alloc_small (2, 0);
+      Field (path_elem, 0) = CAML_LINE_TO_TAG;
+      Field (path_elem, 1) = point;
+      p->val = callback2_exn (p->closure, p->val, path_elem);
+    }
   CAMLreturn0;
 }
 
 static void
-ml_cairo_curve_to_cb(void *data, 
-		     double x1, double y1, 
-		     double x2, double y2, 
-		     double x3, double y3)
+ml_cairo_curve_to_cb (void *data,
+		      double x1, double y1,
+		      double x2, double y2, double x3, double y3)
 {
   struct caml_fold_info *p = data;
-  CAMLparam0();
-  CAMLlocal5(path_elem, tuple, point1, point2, point3);
-  if (! Is_exception_result(p->val)) {
-    point1 = make_point(x1, y1);
-    point2 = make_point(x2, y2);
-    point3 = make_point(x3, y3);
-    tuple = alloc_small(3, 0);
-    Field(tuple, 0) = point1;
-    Field(tuple, 1) = point2;
-    Field(tuple, 2) = point3;
-    path_elem = alloc_small(2, 0);
-    Field(path_elem, 0) = CAML_CURVE_TO_TAG;
-    Field(path_elem, 1) = tuple;
-    p->val = callback2_exn(p->closure, p->val, path_elem);
-  }
+  CAMLparam0 ();
+  CAMLlocal5 (path_elem, tuple, point1, point2, point3);
+  if (!Is_exception_result (p->val))
+    {
+      point1 = make_point (x1, y1);
+      point2 = make_point (x2, y2);
+      point3 = make_point (x3, y3);
+      tuple = alloc_small (3, 0);
+      Field (tuple, 0) = point1;
+      Field (tuple, 1) = point2;
+      Field (tuple, 2) = point3;
+      path_elem = alloc_small (2, 0);
+      Field (path_elem, 0) = CAML_CURVE_TO_TAG;
+      Field (path_elem, 1) = tuple;
+      p->val = callback2_exn (p->closure, p->val, path_elem);
+    }
   CAMLreturn0;
 }
 
 static void
-ml_cairo_close_cb(void *data)
+ml_cairo_close_cb (void *data)
 {
   struct caml_fold_info *p = data;
-  if (! Is_exception_result(p->val)) {
-    p->val = callback2_exn(p->closure, p->val, CAML_CLOSE_TAG);
-  }
+  if (!Is_exception_result (p->val))
+    {
+      p->val = callback2_exn (p->closure, p->val, CAML_CLOSE_TAG);
+    }
 }
 
 CAMLprim value
-ml_cairo_current_path(value v_cr, value closure, value init)
+ml_cairo_current_path (value v_cr, value closure, value init)
 {
-  CAMLparam1(v_cr);
-  CAMLlocalN(v_p, 2);
-  struct caml_fold_info *p = (struct caml_fold_info *)v_p;
+  CAMLparam1 (v_cr);
+  CAMLlocalN (v_p, 2);
+  struct caml_fold_info *p = (struct caml_fold_info *) v_p;
   p->closure = closure;
   p->val = init;
-  cairo_current_path(cairo_t_val(v_cr),
-		     ml_cairo_move_to_cb,
-		     ml_cairo_line_to_cb,
-		     ml_cairo_curve_to_cb,
-		     ml_cairo_close_cb, p);
-  check_cairo_status(v_cr);
-  if (Is_exception_result(p->val)) {
-    value ex = Extract_exception(p->val);
-    mlraise(ex);
-  }
-  CAMLreturn(p->val);
+  cairo_current_path (cairo_t_val (v_cr),
+		      ml_cairo_move_to_cb,
+		      ml_cairo_line_to_cb,
+		      ml_cairo_curve_to_cb, ml_cairo_close_cb, p);
+  check_cairo_status (v_cr);
+  if (Is_exception_result (p->val))
+    {
+      value ex = Extract_exception (p->val);
+      mlraise (ex);
+    }
+  CAMLreturn (p->val);
 }
 
 CAMLprim value
-ml_cairo_current_path_flat(value v_cr, value closure, value init)
+ml_cairo_current_path_flat (value v_cr, value closure, value init)
 {
-  CAMLparam1(v_cr);
-  CAMLlocalN(v_p, 2);
-  struct caml_fold_info *p = (struct caml_fold_info *)v_p;
+  CAMLparam1 (v_cr);
+  CAMLlocalN (v_p, 2);
+  struct caml_fold_info *p = (struct caml_fold_info *) v_p;
   p->closure = closure;
   p->val = init;
-  cairo_current_path_flat(cairo_t_val(v_cr),
-			  ml_cairo_move_to_cb,
-			  ml_cairo_line_to_cb,
-			  ml_cairo_close_cb, p);
-  check_cairo_status(v_cr);
-  if (Is_exception_result(p->val)) {
-    value ex = Extract_exception(p->val);
-    mlraise(ex);
-  }
-  CAMLreturn(p->val);
+  cairo_current_path_flat (cairo_t_val (v_cr),
+			   ml_cairo_move_to_cb,
+			   ml_cairo_line_to_cb, ml_cairo_close_cb, p);
+  check_cairo_status (v_cr);
+  if (Is_exception_result (p->val))
+    {
+      value ex = Extract_exception (p->val);
+      mlraise (ex);
+    }
+  CAMLreturn (p->val);
 }

Index: ml_cairo_channel.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_channel.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ml_cairo_channel.c	22 Feb 2004 19:21:08 -0000	1.2
+++ ml_cairo_channel.c	28 Oct 2004 13:46:01 -0000	1.3
@@ -13,46 +13,47 @@
 #include "caml_io.h"
 #include "ml_cairo_channel.h"
 
-static value ml_FILE_of_fd(int fd)
+static value
+ml_FILE_of_fd (int fd)
 {
   int new_fd;
   FILE *f;
 
-  new_fd = dup(fd);
+  new_fd = dup (fd);
   if (new_fd < 0)
     goto fail;
-  f = fdopen(new_fd, "w");
+  f = fdopen (new_fd, "w");
   if (!f)
     goto fail;
-  return Val_ptr(f);
+  return Val_ptr (f);
 
 fail:
-  raise_sys_error(copy_string(strerror(errno)));
+  raise_sys_error (copy_string (strerror (errno)));
 }
 
 CAMLprim value
-ml_FILE_of_channel(value v)
+ml_FILE_of_channel (value v)
 {
-  struct channel *c = Channel(v);
-  flush(c);
+  struct channel *c = Channel (v);
+  flush (c);
   return ml_FILE_of_fd (c->fd);
 }
 
 CAMLprim value
-ml_FILE_of_file_descr(value v)
+ml_FILE_of_file_descr (value v)
 {
 #ifndef _WIN32
-  return ml_FILE_of_fd (Int_val(v));
+  return ml_FILE_of_fd (Int_val (v));
 #else
-  return failwith("unsupported");
+  return failwith ("unsupported");
 #endif
 }
 
 CAMLprim value
-ml_fclose(value v)
+ml_fclose (value v)
 {
-  FILE *f = FILE_val(v);
-  if (fclose(f))
-    raise_sys_error(copy_string(strerror(errno)));
+  FILE *f = FILE_val (v);
+  if (fclose (f))
+    raise_sys_error (copy_string (strerror (errno)));
   return Val_unit;
 }

Index: ml_cairo_bigarr.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo_bigarr.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ml_cairo_bigarr.c	22 Feb 2004 19:21:08 -0000	1.3
+++ ml_cairo_bigarr.c	28 Oct 2004 13:46:01 -0000	1.4
@@ -1,26 +1,27 @@
 
 #include <caml/bigarray.h>
 
-unsigned long bigarray_byte_size(struct caml_bigarray *);
+unsigned long bigarray_byte_size (struct caml_bigarray *);
 
 CAMLprim value
-ml_bigarray_byte_size(value b)
+ml_bigarray_byte_size (value b)
 {
-  return Val_long(bigarray_byte_size(Bigarray_val(b)));
+  return Val_long (bigarray_byte_size (Bigarray_val (b)));
 }
 
 CAMLprim value
-bigarray_kind_float(value v)
+bigarray_kind_float (value v)
 {
-  struct caml_bigarray *ba = Bigarray_val(v);
+  struct caml_bigarray *ba = Bigarray_val (v);
 
-  switch (ba->flags & BIGARRAY_KIND_MASK) {
-  case BIGARRAY_FLOAT32:
-  case BIGARRAY_FLOAT64:
-  case BIGARRAY_COMPLEX32:
-  case BIGARRAY_COMPLEX64:
-    return Val_true;
-  default:
-    return Val_false;
-  }
+  switch (ba->flags & BIGARRAY_KIND_MASK)
+    {
+    case BIGARRAY_FLOAT32:
+    case BIGARRAY_FLOAT64:
+    case BIGARRAY_COMPLEX32:
+    case BIGARRAY_COMPLEX64:
+      return Val_true;
+    default:
+      return Val_false;
+    }
 }

Index: ml_cairo.h
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ml_cairo.h	18 Oct 2004 00:27:34 -0000	1.4
+++ ml_cairo.h	28 Oct 2004 13:46:01 -0000	1.5
@@ -4,30 +4,8 @@
 };
 #define cairo_t_val(v) (((struct ml_cairo *) Data_custom_val(v))->cr)
 
-static inline cairo_format_t
-cairo_format_t_val(value _v)
-{
-  const cairo_format_t _conv_tab[] =
-    { CAIRO_FORMAT_ARGB32, CAIRO_FORMAT_RGB24, 
-      CAIRO_FORMAT_A8, CAIRO_FORMAT_A1, };
-  return _conv_tab[Int_val(_v)];
-}
-
-static inline value
-Val_cairo_format_t(cairo_format_t fmt)
-{
-  switch (fmt) {
-  case CAIRO_FORMAT_ARGB32:
-    return Val_int(0);
-  case CAIRO_FORMAT_RGB24:
-    return Val_int(1);
-  case CAIRO_FORMAT_A8:
-    return Val_int(2);
-  case CAIRO_FORMAT_A1:
-  default:
-    return Val_int(3);
-  }
-}
+#define cairo_format_t_val(v) ((cairo_format_t) Int_val(v))
+#define Val_cairo_format_t(v) Val_int(v)
 
 value Val_cairo_surface_t (cairo_surface_t *);
 value Val_cairo_t (cairo_t *);

Index: ml_cairo.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- ml_cairo.c	18 Oct 2004 00:27:34 -0000	1.12
+++ ml_cairo.c	28 Oct 2004 13:46:01 -0000	1.13
@@ -11,26 +11,28 @@
 #include "ml_cairo_status.h"
 #include "ml_cairo.h"
 
-static void 
+static void
 ml_final_cairo_t (value val)
-{ 
-  cairo_t *cr = cairo_t_val(val);
-  if (cr != NULL) cairo_destroy (cr);
+{
+  cairo_t *cr = cairo_t_val (val);
[...1579 lines suppressed...]
-static inline value
-Val_cairo_extend_t(cairo_extend_t _s)
-{
-  switch (_s)
-    {
-    case CAIRO_EXTEND_NONE:
-      return Val_int(0);
-    case CAIRO_EXTEND_REPEAT:
-      return Val_int(1);
-    case CAIRO_EXTEND_REFLECT:
-      return Val_int(2);
-    }
-  return 0;
-}
+#define cairo_extend_t_val(v) ((cairo_extend_t) Int_val(v))
+#define Val_cairo_extend_t(v) Val_int(v)
+
 ML_2 (cairo_pattern_set_extend, cairo_pattern_t_val, cairo_extend_t_val, Val_cairo_status_t)
 ML_1 (cairo_pattern_get_extend, cairo_pattern_t_val, Val_cairo_extend_t)
 ML_2 (cairo_pattern_set_filter, cairo_pattern_t_val, cairo_filter_t_val, Val_cairo_status_t)

Index: cairo_lablgtk.mli
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo_lablgtk.mli,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cairo_lablgtk.mli	24 Mar 2004 10:39:24 -0000	1.2
+++ cairo_lablgtk.mli	28 Oct 2004 13:46:01 -0000	1.3
@@ -1,3 +1,4 @@
+(** Support for the X11 backend, via LablGTK *)
 
 external image_of_pixbuf : GdkPixbuf.pixbuf -> Cairo.image = "cairo_lablgtk_of_pixbuf"
 external shuffle_pixels  : GdkPixbuf.pixbuf -> unit = "cairo_lablgtk_shuffle_pixels"

Index: cairo_channel.mli
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo_channel.mli,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- cairo_channel.mli	18 Nov 2003 19:02:26 -0000	1.1.1.1
+++ cairo_channel.mli	28 Oct 2004 13:46:01 -0000	1.2
@@ -1,3 +1,5 @@
+(** Support module for file-based backends (PostScript and PNG) *)
+
 type t
 external of_out_channel : out_channel -> t = "ml_FILE_of_channel"
 external of_file_descr : Unix.file_descr -> t = "ml_FILE_of_file_descr"

Index: cairo_bigarray.mli
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo_bigarray.mli,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- cairo_bigarray.mli	18 Nov 2003 19:02:26 -0000	1.1.1.1
+++ cairo_bigarray.mli	28 Oct 2004 13:46:01 -0000	1.2
@@ -1,3 +1,5 @@
+(** Support for the in-memory image backend, via Bigarray *)
+
 open Bigarray
 
 val of_bigarr :

Index: cairo_bigarray.ml
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo_bigarray.ml,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- cairo_bigarray.ml	18 Nov 2003 19:02:25 -0000	1.1.1.1
+++ cairo_bigarray.ml	28 Oct 2004 13:46:01 -0000	1.2
@@ -6,7 +6,7 @@
     stride : int ;
   }
 
-let conv : image -> Cairo.image = Obj.magic
+external conv : image -> Cairo.image = "%identity"
 
 open Bigarray
 
@@ -15,8 +15,7 @@
 external bigarray_byte_size  : ('a, 'b, c_layout) Array2.t -> int
   = "ml_bigarray_byte_size"
 
-let bigarray_data : ('a, 'b, c_layout) Array2.t -> Obj.t = 
-  fun arr -> Obj.field (Obj.repr arr) 1
+external bigarray_data : ('a, 'b, c_layout) Array2.t -> Obj.t = "%field1"
 
 let of_bigarr arr format ~width ~height ~stride =
   if bigarray_kind_float arr
@@ -67,19 +66,21 @@
 	 stride = w ;
        }
 
+let output_pixel oc p =
+  let r = (p lsr 16) land 0xff in
+  output_byte oc r ;
+  let g = (p lsr 8) land 0xff in
+  output_byte oc g ;
+  let b = p land 0xff in
+  output_byte oc b 
+
 let write_ppm_int32 oc (arr : (int32, int32_elt, c_layout) Array2.t) =
   let h = Array2.dim1 arr in
   let w = Array2.dim2 arr in
   Printf.fprintf oc "P6 %d %d 255\n" w h ;
   for i=0 to pred h do
     for j=0 to pred w do
-      let p = Int32.to_int arr.{i, j} in
-      let r = (p lsr 16) land 0xff in
-      output_byte oc r ;
-      let g = (p lsr 8) land 0xff in
-      output_byte oc g ;
-      let b = p land 0xff in
-      output_byte oc b 
+      output_pixel oc (Int32.to_int arr.{i, j})
     done
   done ;
   flush oc
@@ -90,13 +91,7 @@
   Printf.fprintf oc "P6 %d %d 255\n" w h ;
   for i=0 to pred h do
     for j=0 to pred w do
-      let p = arr.{i, j} in
-      let r = (p lsr 16) land 0xff in
-      output_byte oc r ;
-      let g = (p lsr 8) land 0xff in
-      output_byte oc g ;
-      let b = p land 0xff in
-      output_byte oc b 
+      output_pixel oc arr.{i, j}
     done
   done ;
   flush oc

Index: cairo.mli
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo.mli,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- cairo.mli	18 Oct 2004 00:27:34 -0000	1.10
+++ cairo.mli	28 Oct 2004 13:46:01 -0000	1.11
@@ -228,6 +228,7 @@
 external current_font : cr:t -> font = "ml_cairo_current_font"
 external current_font_extents : cr:t -> font_extents
   = "ml_cairo_current_font_extents"
+external set_font : cr:t -> font:font -> unit = "ml_cairo_set_font"
 external text_extents : t -> utf8:string -> text_extents = "ml_cairo_text_extents"
 external glyph_extents : t -> glyph array -> text_extents = "ml_cairo_glyph_extents"
 external text_path : t -> utf8:string -> unit = "ml_cairo_text_path"
@@ -360,7 +361,6 @@
    Mostly unusable ATM. It needs other libraries (freetype2/fontconfig). 
 *)
 
-external set_font : cr:t -> font:font -> unit = "ml_cairo_set_font"
 external font_set_transform : font:font -> matrix:matrix -> unit
   = "ml_cairo_font_set_transform"
 external font_current_transform : font:font -> matrix:matrix -> unit




More information about the cairo-commit mailing list