[cairo-commit] cairo-ocaml/src ml_cairo.c, 1.9, 1.10 cairo.mli, 1.7, 1.8 cairo.ml, 1.7, 1.8

Olivier Andrieu commit at pdx.freedesktop.org
Thu Apr 15 16:59:39 PDT 2004


Committed by: oandrieu

Update of /cvs/cairo/cairo-ocaml/src
In directory pdx:/tmp/cvs-serv16155/src

Modified Files:
	ml_cairo.c cairo.mli cairo.ml 
Log Message:
support patterns (requires cairo 0.1.21)


Index: ml_cairo.c
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/ml_cairo.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** a/ml_cairo.c	27 Feb 2004 23:05:28 -0000	1.9
--- b/ml_cairo.c	15 Apr 2004 23:59:37 -0000	1.10
***************
*** 16,23 ****
  Make_Val_final_pointer(cairo_surface_t, Ignore, cairo_surface_destroy, 20)
  #define cairo_surface_t_val(v) ((cairo_surface_t *)Pointer_val(v))
  Make_Val_final_pointer(cairo_matrix_t, Ignore, cairo_matrix_destroy, 100)
  #define cairo_matrix_t_val(v) ((cairo_matrix_t *)Pointer_val(v))
- ML_0(cairo_create, Val_cairo_t)
  
  ML_1(cairo_destroy, cairo_t_val, Unit)
  
--- 16,27 ----
  Make_Val_final_pointer(cairo_surface_t, Ignore, cairo_surface_destroy, 20)
  #define cairo_surface_t_val(v) ((cairo_surface_t *)Pointer_val(v))
+ 
  Make_Val_final_pointer(cairo_matrix_t, Ignore, cairo_matrix_destroy, 100)
  #define cairo_matrix_t_val(v) ((cairo_matrix_t *)Pointer_val(v))
  
+ Make_Val_final_pointer(cairo_pattern_t, Ignore, cairo_pattern_destroy, 20)
+ #define cairo_pattern_t_val(v) ((cairo_pattern_t *)Pointer_val(v))
+ 
+ ML_0(cairo_create, Val_cairo_t)
  ML_1(cairo_destroy, cairo_t_val, Unit)
  
***************
*** 77,80 ****
--- 81,99 ----
  ML_bc6(cairo_set_target_ps)
  
+ #ifdef CAIRO_HAS_PNG_SURFACE
+ CAMLprim value
+ ml_cairo_set_target_png(value v_cr, value v_file, value v_format,
+ 			value v_width, value v_height)
+ {
+   cairo_set_target_png(cairo_t_val(v_cr), FILE_val(v_file),
+ 		       cairo_format_t_val(v_format),
+ 		       Double_val(v_width), Double_val(v_height));
+   check_cairo_status(v_cr);
+   return Val_unit;
+ }
+ #else
+ Unsupported(ml_cairo_set_target_png)
+ #endif /* CAIRO_HAS_PNG_SURFACE */
+ 
  static inline cairo_operator_t
  cairo_operator_t_val(value _v)
***************
*** 154,158 ****
  ml_cairo_set_pattern(value v_cr, value v_pattern)
  {
!   cairo_set_pattern(cairo_t_val(v_cr), cairo_surface_t_val(v_pattern));
    check_cairo_status(v_cr);
    return Val_unit;
--- 173,177 ----
  ml_cairo_set_pattern(value v_cr, value v_pattern)
  {
!   cairo_set_pattern(cairo_t_val(v_cr), cairo_pattern_t_val(v_pattern));
    check_cairo_status(v_cr);
    return Val_unit;
***************
*** 559,562 ****
--- 578,617 ----
  
  CAMLprim value
+ ml_cairo_stroke_extents(value v_cr)
+ {
+   double x1, y1, x2, y2;
+   cairo_stroke_extents(cairo_t_val(v_cr), &x1, &y1, &x2, &y2);
+   check_cairo_status(v_cr);
+   {
+     CAMLparam0();
+     CAMLlocal1(t);
+     t = alloc_tuple(4);
+     Store_field(t, 0, copy_double(x1));
+     Store_field(t, 1, copy_double(y1));
+     Store_field(t, 2, copy_double(x2));
+     Store_field(t, 3, copy_double(y2));
+     CAMLreturn(t);
+   }
+ }
+ 
+ CAMLprim value
+ ml_cairo_fill_extents(value v_cr)
+ {
+   double x1, y1, x2, y2;
+   cairo_fill_extents(cairo_t_val(v_cr), &x1, &y1, &x2, &y2);
+   check_cairo_status(v_cr);
+   {
+     CAMLparam0();
+     CAMLlocal1(t);
+     t = alloc_tuple(4);
+     Store_field(t, 0, copy_double(x1));
+     Store_field(t, 1, copy_double(y1));
+     Store_field(t, 2, copy_double(x2));
+     Store_field(t, 3, copy_double(y2));
+     CAMLreturn(t);
+   }
+ }
+ 
+ CAMLprim value
  ml_cairo_clip(value v_cr)
  {
***************
*** 565,568 ****
--- 620,631 ----
    return Val_unit;
  }
+ 
+ CAMLprim value
+ ml_cairo_init_clip(value v_cr)
+ {
+   cairo_init_clip(cairo_t_val(v_cr));
+   check_cairo_status(v_cr);
+   return Val_unit;
+ }
  Make_Val_final_pointer(cairo_font_t, Ignore, cairo_font_destroy, 20)
  
***************
*** 791,794 ****
--- 854,867 ----
  
  CAMLprim value
+ ml_cairo_current_pattern(value v_cr)
+ {
+   cairo_pattern_t *c_ret;
+   c_ret = cairo_current_pattern(cairo_t_val(v_cr));
+   check_cairo_status(v_cr);
+   cairo_pattern_reference(c_ret);
+   return Val_cairo_pattern_t(c_ret);
+ }
+ 
+ CAMLprim value
  ml_cairo_current_alpha(value v_cr)
  {
***************
*** 908,914 ****
    const cairo_filter_t _conv_tab[] =
      { CAIRO_FILTER_FAST, CAIRO_FILTER_GOOD, CAIRO_FILTER_BEST,
! CAIRO_FILTER_NEAREST, CAIRO_FILTER_BILINEAR, };
    return _conv_tab[Int_val(_v)];
  }
  ML_2(cairo_surface_set_filter, cairo_surface_t_val, cairo_filter_t_val, Val_cairo_status_t)
  
--- 981,1008 ----
    const cairo_filter_t _conv_tab[] =
      { CAIRO_FILTER_FAST, CAIRO_FILTER_GOOD, CAIRO_FILTER_BEST,
!       CAIRO_FILTER_NEAREST, CAIRO_FILTER_BILINEAR, 
!       CAIRO_FILTER_GAUSSIAN };
    return _conv_tab[Int_val(_v)];
  }
+ static inline value
+ Val_cairo_filter_t(cairo_filter_t _s)
+ {
+   switch(_s) 
+     {
+     case CAIRO_FILTER_FAST:
+       return Val_int(0);
+     case CAIRO_FILTER_GOOD:
+       return Val_int(1);
+     case CAIRO_FILTER_BEST:
+       return Val_int(2);
+     case CAIRO_FILTER_NEAREST:
+       return Val_int(3);
+     case CAIRO_FILTER_BILINEAR:
+       return Val_int(4);
+     case CAIRO_FILTER_GAUSSIAN:
+       return Val_int(5);
+     }
+   return 0;
+ }
  ML_2(cairo_surface_set_filter, cairo_surface_t_val, cairo_filter_t_val, Val_cairo_status_t)
  
***************
*** 932,935 ****
--- 1026,1035 ----
  #endif /* CAIRO_HAS_PS_SURFACE */
  
+ #ifdef CAIRO_HAS_PNG_SURFACE
+ ML_4(cairo_png_surface_create, FILE_val, cairo_format_t_val, Double_val, Double_val, Val_cairo_surface_t)
+ #else
+ Unsupported(ml_cairo_png_surface_create)
+ #endif /* CAIRO_HAS_PNG_SURFACE */
+ 
  ML_0(cairo_matrix_create, Val_cairo_matrix_t)
  ML_1(cairo_matrix_destroy, cairo_matrix_t_val, Unit)
***************
*** 1013,1030 ****
  }
  
! #ifdef CAIRO_HAS_PNG_SURFACE
! CAMLprim value
! ml_cairo_set_target_png(value v_cr, value v_file, value v_format,
! 			value v_width, value v_height)
  {
!   cairo_set_target_png(cairo_t_val(v_cr), FILE_val(v_file),
! 		       cairo_format_t_val(v_format),
! 		       Double_val(v_width), Double_val(v_height));
!   check_cairo_status(v_cr);
!   return Val_unit;
  }
! ML_4(cairo_png_surface_create, FILE_val, cairo_format_t_val, Double_val, Double_val, Val_cairo_surface_t)
! #else
! Unsupported(ml_cairo_set_target_png)
! Unsupported(ml_cairo_png_surface_create)
! #endif /* CAIRO_HAS_PNG_SURFACE */
--- 1113,1148 ----
  }
  
! ML_1 (cairo_pattern_create_for_surface, cairo_surface_t_val, Val_cairo_pattern_t)
! ML_4 (cairo_pattern_create_linear, Double_val, Double_val, Double_val, Double_val, Val_cairo_pattern_t)
! ML_6 (cairo_pattern_create_radial, Double_val, Double_val, Double_val, Double_val, Double_val, Double_val, Val_cairo_pattern_t)
! ML_bc6 (cairo_pattern_create_radial)
! ML_6 (cairo_pattern_add_color_stop, cairo_pattern_t_val, Double_val, Double_val, Double_val, Double_val, Double_val, Val_cairo_status_t)
! ML_bc6 (cairo_pattern_add_color_stop)
! ML_2(cairo_pattern_set_matrix, cairo_pattern_t_val, cairo_matrix_t_val, Val_cairo_status_t)
! ML_2(cairo_pattern_get_matrix, cairo_pattern_t_val, cairo_matrix_t_val, Val_cairo_status_t)
! 
! static inline cairo_extend_t
! cairo_extend_t_val(value _v)
  {
!   const cairo_extend_t _conv_tab[] =
!     { CAIRO_EXTEND_NONE, CAIRO_EXTEND_REPEAT, CAIRO_EXTEND_REFLECT };
!   return _conv_tab[Int_val(_v)];
  }
! 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;
! }
! 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)
! ML_1 (cairo_pattern_get_filter, cairo_pattern_t_val, Val_cairo_filter_t)

Index: cairo.mli
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo.mli,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** a/cairo.mli	24 Mar 2004 10:57:27 -0000	1.7
--- b/cairo.mli	15 Apr 2004 23:59:37 -0000	1.8
***************
*** 21,24 ****
--- 21,25 ----
  type surface
  type matrix
+ type pattern
  type image
  
***************
*** 74,78 ****
    = "ml_cairo_set_rgb_color"
  external set_alpha : cr:t -> alpha:float -> unit = "ml_cairo_set_alpha"
! external set_pattern : cr:t -> pattern:surface -> unit
    = "ml_cairo_set_pattern"
  external set_tolerance : cr:t -> tolerance:float -> unit
--- 75,79 ----
    = "ml_cairo_set_rgb_color"
  external set_alpha : cr:t -> alpha:float -> unit = "ml_cairo_set_alpha"
! external set_pattern : cr:t -> pattern:pattern -> unit
    = "ml_cairo_set_pattern"
  external set_tolerance : cr:t -> tolerance:float -> unit
***************
*** 157,160 ****
--- 158,164 ----
  external in_fill : cr:t -> x:float -> y:float -> bool = "ml_cairo_in_fill"
  
+ external stroke_extents : cr:t -> float * float * float * float = "ml_cairo_stroke_extents"
+ external fill_extents : cr:t -> float * float * float * float = "ml_cairo_fill_extents"
+ 
  type flat_path = [
    | `MOVE_TO of point
***************
*** 174,177 ****
--- 178,182 ----
  external copy_page : cr:t -> unit = "ml_cairo_copy_page"
  external show_page : cr:t -> unit = "ml_cairo_show_page"
+ external init_clip : cr:t -> unit = "ml_cairo_init_clip"
  external clip : cr:t -> unit = "ml_cairo_clip"
  
***************
*** 236,240 ****
  external current_target_surface : cr:t -> surface
    = "ml_cairo_current_target_surface"
! 
  
  (** {3 Surface API} *)
--- 241,245 ----
  external current_target_surface : cr:t -> surface
    = "ml_cairo_current_target_surface"
! external current_pattern : cr:t -> pattern = "ml_cairo_current_pattern"
  
  (** {3 Surface API} *)
***************
*** 257,264 ****
--- 262,297 ----
    | FILTER_NEAREST
    | FILTER_BILINEAR
+   | FILTER_GAUSSIAN
  external surface_set_filter : surface:surface -> filter:filter -> unit
    = "ml_cairo_surface_set_filter"
  external surface_finalise : surface -> unit = "ml_cairo_surface_finalise"
  
+ (** {4 Pattern functions} *)
+ external pattern_create_for_surface : surface -> pattern = "ml_cairo_pattern_create_for_surface"
+ 
+ external pattern_create_linear : x0:float -> y0:float -> x1:float -> y1:float -> pattern 
+   = "ml_cairo_pattern_create_linear"
+ external pattern_create_radial : 
+   cx0:float -> cy0:float -> radius0:float ->
+   cx1:float -> cy1:float -> radius1:float -> pattern 
+   = "ml_cairo_pattern_create_radial_bc" "ml_cairo_pattern_create_radial"
+ 
+ external pattern_add_color_stop : 
+   pattern -> offset:float -> 
+   red:float -> green:float -> blue:float -> alpha:float -> unit 
+   = "ml_cairo_pattern_add_color_stop_bc" "ml_cairo_pattern_add_color_stop"
+ 
+ external pattern_set_matrix : pattern -> matrix -> unit = "ml_cairo_pattern_set_matrix"
+ external pattern_get_matrix : pattern -> matrix -> unit = "ml_cairo_pattern_get_matrix"
+ 
+ type extend =
+   | EXTEND_NONE
+   | EXTEND_REPEAT
+   | EXTEND_REFLECT
+ external pattern_set_extend : pattern -> extend -> unit = "ml_cairo_pattern_set_extend"
+ external pattern_get_extend : pattern -> extend = "ml_cairo_pattern_get_extend"
+ external pattern_set_filter : pattern -> filter -> unit = "ml_cairo_pattern_set_filter"
+ external pattern_get_filter : pattern -> filter = "ml_cairo_pattern_get_filter"
+ 
  (** {4 Image surface} *)
  

Index: cairo.ml
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/src/cairo.ml,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** a/cairo.ml	24 Mar 2004 10:57:27 -0000	1.7
--- b/cairo.ml	15 Apr 2004 23:59:37 -0000	1.8
***************
*** 19,22 ****
--- 19,23 ----
  type surface
  type matrix
+ type pattern
  external create : unit -> t = "ml_cairo_create"
  external destroy : cr:t -> unit = "ml_cairo_destroy"
***************
*** 34,37 ****
--- 35,39 ----
  external set_target_png :
    cr:t -> file:Cairo_channel.t -> format -> width:float -> height:float -> unit = "ml_cairo_set_target_png"
+ 
  type operator =
      OPERATOR_CLEAR
***************
*** 55,59 ****
  external set_alpha : cr:t -> alpha:float -> unit = "ml_cairo_set_alpha"
  external set_pattern :
!   cr:t -> pattern:surface -> unit = "ml_cairo_set_pattern"
  external set_tolerance :
    cr:t -> tolerance:float -> unit = "ml_cairo_set_tolerance"
--- 57,61 ----
  external set_alpha : cr:t -> alpha:float -> unit = "ml_cairo_set_alpha"
  external set_pattern :
!   cr:t -> pattern:pattern -> unit = "ml_cairo_set_pattern"
  external set_tolerance :
    cr:t -> tolerance:float -> unit = "ml_cairo_set_tolerance"
***************
*** 130,133 ****
--- 132,138 ----
  external in_stroke : cr:t -> x:float -> y:float -> bool = "ml_cairo_in_stroke"
  external in_fill : cr:t -> x:float -> y:float -> bool = "ml_cairo_in_fill"
+ external stroke_extents : cr:t -> float * float * float * float = "ml_cairo_stroke_extents"
+ external fill_extents : cr:t -> float * float * float * float = "ml_cairo_fill_extents"
+ external init_clip : cr:t -> unit = "ml_cairo_init_clip"
  external clip : cr:t -> unit = "ml_cairo_clip"
  type font
***************
*** 193,196 ****
--- 198,202 ----
  external current_target_surface :
    cr:t -> surface = "ml_cairo_current_target_surface"
+ external current_pattern : cr:t -> pattern = "ml_cairo_current_pattern"
  external surface_create_for_image :
    image -> surface = "ml_cairo_surface_create_for_image"
***************
*** 212,217 ****
--- 218,245 ----
    | FILTER_NEAREST
    | FILTER_BILINEAR
+   | FILTER_GAUSSIAN
  external surface_set_filter :
    surface:surface -> filter:filter -> unit = "ml_cairo_surface_set_filter"
+ external pattern_create_for_surface : surface -> pattern = "ml_cairo_pattern_create_for_surface"
+ external pattern_create_linear : x0:float -> y0:float -> x1:float -> y1:float -> pattern 
+   = "ml_cairo_pattern_create_linear"
+ external pattern_create_radial : 
+   cx0:float -> cy0:float -> radius0:float ->
+   cx1:float -> cy1:float -> radius1:float -> pattern 
+   = "ml_cairo_pattern_create_radial_bc" "ml_cairo_pattern_create_radial"
+ external pattern_add_color_stop : 
+   pattern -> offset:float -> 
+   red:float -> green:float -> blue:float -> alpha:float -> unit 
+   = "ml_cairo_pattern_add_color_stop_bc" "ml_cairo_pattern_add_color_stop"
+ external pattern_set_matrix : pattern -> matrix -> unit = "ml_cairo_pattern_set_matrix"
+ external pattern_get_matrix : pattern -> matrix -> unit = "ml_cairo_pattern_get_matrix"
+ type extend =
+   | EXTEND_NONE
+   | EXTEND_REPEAT
+   | EXTEND_REFLECT
+ external pattern_set_extend : pattern -> extend -> unit = "ml_cairo_pattern_set_extend"
+ external pattern_get_extend : pattern -> extend = "ml_cairo_pattern_get_extend"
+ external pattern_set_filter : pattern -> filter -> unit = "ml_cairo_pattern_set_filter"
+ external pattern_get_filter : pattern -> filter = "ml_cairo_pattern_get_filter"
  external image_surface_create :
    format:format -> width:int -> height:int ->





More information about the cairo-commit mailing list