@@ -1254,7 +1254,8 @@ class Matrix {
1254
1254
}
1255
1255
1256
1256
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 ) {}
1258
1259
1259
1260
method write_png (Str $ filename ) {
1260
1261
my $ result = CairoStatus( $ . surface . write_to_png($ filename ) );
@@ -1280,12 +1281,12 @@ class Surface {
1280
1281
}
1281
1282
1282
1283
class Surface::PDF is Surface {
1283
- has cairo_pdf_surface_t: D $ . surface is required ;
1284
1284
has Num : D () $ . width is required ;
1285
1285
has Num : D () $ . height is required ;
1286
1286
1287
1287
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 ;
1289
1290
}
1290
1291
1291
1292
method create (Str : D () $ filename , Str : D () $ width , Str : D () $ height ) {
@@ -1296,21 +1297,23 @@ class Surface::PDF is Surface {
1296
1297
$ . surface . add_outline: $ parent-id , $ name , Attrs::serialize(% attrs ), $ flags ;
1297
1298
}
1298
1299
1299
- method surface handles <set_metadata > { callsame () }
1300
+ method surface returns cairo_pdf_surface_t handles <set_metadata > { callsame () }
1300
1301
}
1301
1302
1302
1303
class Surface::SVG is Surface {
1303
- has cairo_svg_surface_t: D $ . surface is required ;
1304
1304
has Num : D () $ . width is required ;
1305
1305
has Num : D () $ . height is required ;
1306
1306
1307
1307
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 ;
1309
1309
}
1310
1310
1311
1311
method create (Str : D () $ filename , Int : D () $ width , Int : D () $ height ) {
1312
1312
return self . new (: $ filename , : $ width , : $ height );
1313
1313
}
1314
+
1315
+ method surface returns cairo_svg_surface_t { callsame }
1316
+
1314
1317
}
1315
1318
1316
1319
class RecordingSurface {
@@ -1335,7 +1338,6 @@ class RecordingSurface {
1335
1338
}
1336
1339
1337
1340
class Image is Surface {
1338
- has cairo_surface_t: D $ . surface is required ;
1339
1341
sub cairo_image_surface_create (int32 $ format , int32 $ width , int32 $ height )
1340
1342
returns cairo_surface_t
1341
1343
is native($ cairolib )
@@ -1371,12 +1373,12 @@ class Image is Surface {
1371
1373
is native($ cairolib )
1372
1374
{* }
1373
1375
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 }
1375
1377
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 )
1377
1379
}
1378
1380
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 );
1380
1382
}
1381
1383
1382
1384
multi method create (Int () $ format , Cool $ width , Cool $ height ) {
0 commit comments