Commit | Line | Data |
---|---|---|
0ada181a BG |
1 | From 3c70f2ff18650c4794556049cd4ea22a58cc719e Mon Sep 17 00:00:00 2001 |
2 | From: Christophe Troestler <Christophe.Troestler@umons.ac.be> | |
3 | Date: Sun, 27 Sep 2020 23:20:52 +0200 | |
4 | Subject: [PATCH] Do not store the Caml_ba_array_val pointer during surface | |
5 | creation | |
6 | ||
7 | Extracted from Cairo git-tree on November 22, 2020 by | |
8 | Brett Gilio <brettg@gnu.org> | |
9 | --- | |
10 | src/cairo_stubs.c | 3 ++- | |
11 | tests/image_create.ml | 5 +++-- | |
12 | 2 files changed, 5 insertions(+), 3 deletions(-) | |
13 | ||
14 | diff --git a/src/cairo_stubs.c b/src/cairo_stubs.c | |
15 | index 641ee2c..200abf3 100644 | |
16 | --- a/src/cairo_stubs.c | |
17 | +++ b/src/cairo_stubs.c | |
18 | @@ -1580,6 +1580,7 @@ static cairo_status_t caml_cairo_image_bigarray_attach_proxy | |
19 | caml_cairo_image_bigarray_finalize); | |
20 | } | |
21 | ||
22 | +#define b (Caml_ba_array_val(vb)) | |
23 | #define SURFACE_CREATE_DATA(name) \ | |
24 | CAMLexport value caml_cairo_image_surface_create_for_##name \ | |
25 | (value vb, value vformat, value vwidth, value vheight, value vstride) \ | |
26 | @@ -1588,7 +1589,6 @@ static cairo_status_t caml_cairo_image_bigarray_attach_proxy | |
27 | CAMLlocal1(vsurf); \ | |
28 | cairo_surface_t* surf; \ | |
29 | const int width = Int_val(vwidth); \ | |
30 | - struct caml_ba_array *b = Caml_ba_array_val(vb); \ | |
31 | cairo_status_t status; \ | |
32 | \ | |
33 | if ((b->flags & CAML_BA_MANAGED_MASK) == CAML_BA_MAPPED_FILE) \ | |
34 | @@ -1610,6 +1610,7 @@ static cairo_status_t caml_cairo_image_bigarray_attach_proxy | |
35 | ||
36 | SURFACE_CREATE_DATA(data8) | |
37 | SURFACE_CREATE_DATA(data32) | |
38 | +#undef b | |
39 | ||
40 | #define SURFACE_GET_DATA(type, num_dims, dims ...) \ | |
41 | CAMLexport value caml_cairo_image_surface_get_##type(value vsurf) \ | |
42 | diff --git a/tests/image_create.ml b/tests/image_create.ml | |
43 | index eec98d6..b13c206 100644 | |
44 | --- a/tests/image_create.ml | |
45 | +++ b/tests/image_create.ml | |
46 | @@ -10,6 +10,7 @@ let create() = | |
47 | ||
48 | let () = | |
49 | let cr = create() in | |
50 | + printf "With Cairo handle:\n%!"; | |
51 | set_source_rgb cr 1. 1. 1.; | |
52 | rectangle cr 0. 0. ~w:300. ~h:300.; | |
53 | fill cr; | |
54 | @@ -21,9 +22,9 @@ let () = | |
55 | show_text cr "Hello"; | |
56 | Gc.compact(); Gc.compact(); | |
57 | ||
58 | - eprintf "Write image\n%!"; | |
59 | + eprintf "- Write image\n%!"; | |
60 | PNG.write (get_target cr) "test_image.png"; | |
61 | - eprintf "Finish surface\n%!"; | |
62 | + eprintf "- Finish surface\n%!"; | |
63 | Surface.finish (get_target cr); | |
64 | Gc.compact() | |
65 | ||
66 | -- | |
67 | 2.29.2 | |
68 |