Skip to content

Commit e1dca24

Browse files
committed
Fix PDF::To::Cairo regressions
1 parent 365c570 commit e1dca24

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/Cairo.pm6

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,8 @@ class Matrix {
12541254
}
12551255

12561256
class Surface {
1257-
method raw handles <reference destroy flush finish show_page status> { self.surface }
1257+
has cairo_surface_t $.surface is rw handles <reference destroy flush finish show_page status>;
1258+
method set-surface($!surface) {}
12581259

12591260
method write_png(Str $filename) {
12601261
my $result = CairoStatus( $.surface.write_to_png($filename) );
@@ -1280,12 +1281,12 @@ class Surface {
12801281
}
12811282

12821283
class Surface::PDF is Surface {
1283-
has cairo_pdf_surface_t:D $.surface is required;
12841284
has Num:D() $.width is required;
12851285
has Num:D() $.height is required;
12861286

12871287
submethod BUILD(Str:D() :$filename!, :$!width!, :$!height!) is hidden-from-backtrace {
1288-
$!surface .= new: :$!width, :$!height, :$filename;
1288+
my $s = cairo_pdf_surface_t::create($filename, $!width, $!height);
1289+
self.set-surface: $s;
12891290
}
12901291

12911292
method create(Str:D() $filename, Str:D() $width, Str:D() $height) {
@@ -1296,21 +1297,23 @@ class Surface::PDF is Surface {
12961297
$.surface.add_outline: $parent-id, $name, Attrs::serialize(%attrs), $flags;
12971298
}
12981299

1299-
method surface handles<set_metadata> { callsame() }
1300+
method surface returns cairo_pdf_surface_t handles<set_metadata> { callsame() }
13001301
}
13011302

13021303
class Surface::SVG is Surface {
1303-
has cairo_svg_surface_t:D $.surface is required;
13041304
has Num:D() $.width is required;
13051305
has Num:D() $.height is required;
13061306

13071307
submethod BUILD(Str:D() :$filename!, :$!width!, :$!height!) is hidden-from-backtrace {
1308-
$!surface .= new: :$!width, :$!height, :$filename;
1308+
self.set-surface: cairo_svg_surface_t::create $filename, $!width, $!height;
13091309
}
13101310

13111311
method create(Str:D() $filename, Int:D() $width, Int:D() $height) {
13121312
return self.new(:$filename, :$width, :$height);
13131313
}
1314+
1315+
method surface returns cairo_svg_surface_t { callsame }
1316+
13141317
}
13151318

13161319
class RecordingSurface {
@@ -1335,7 +1338,6 @@ class RecordingSurface {
13351338
}
13361339

13371340
class Image is Surface {
1338-
has cairo_surface_t:D $.surface is required;
13391341
sub cairo_image_surface_create(int32 $format, int32 $width, int32 $height)
13401342
returns cairo_surface_t
13411343
is native($cairolib)
@@ -1371,12 +1373,12 @@ class Image is Surface {
13711373
is native($cairolib)
13721374
{*}
13731375

1374-
multi submethod BUILD(cairo_surface_t:D :$!surface) is hidden-from-backtrace {}
1376+
multi submethod BUILD(cairo_surface_t:D :$surface) is hidden-from-backtrace { self.set-surface: $surface}
13751377
multi submethod BUILD(Str:D :$filename!) is hidden-from-backtrace {
1376-
$!surface = cairo_image_surface_create_from_png($filename)
1378+
self.set-surface: cairo_image_surface_create_from_png($filename)
13771379
}
13781380
multi submethod BUILD(Int:D() :$width!, Int:D() :$height!, Int:D() :$format = Cairo::FORMAT_ARGB32) is hidden-from-backtrace {
1379-
$!surface = cairo_image_surface_create($format, $width.Int, $height);
1381+
self.set-surface: cairo_image_surface_create($format, $width, $height);
13801382
}
13811383

13821384
multi method create(Int() $format, Cool $width, Cool $height) {

0 commit comments

Comments
 (0)