Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upExpose Canvas transform and save/restore to C #216
Conversation
| @@ -310,6 +310,26 @@ pub unsafe extern "C" fn PFCanvasSetLineDash(canvas: PFCanvasRef, | |||
| (*canvas).set_line_dash(slice::from_raw_parts(new_line_dashes, new_line_dash_count).to_vec()) | |||
| } | |||
|
|
|||
| #[no_mangle] | |||
| pub unsafe extern "C" fn PFCanvasSetCurrentTransform(canvas: PFCanvasRef, transform: *const PFTransform2F) { | |||
| (*canvas).set_current_transform(&(*transform).to_rust()); | |||
This comment has been minimized.
This comment has been minimized.
toolness
Jul 14, 2019
Author
Contributor
This is interesting because it seems like we're ultimately copying the transform twice--once to make it owned by Pathfinder, but then the canvas copies it again to make it its own. Is there a way to optimize this to only be one copy? Or will Rust actually be super smart and optimize things at compile time?
This comment has been minimized.
This comment has been minimized.
pcwalton
Jul 22, 2019
Collaborator
It shouldn't be a big deal either way. None of the canvas methods are optimized that well to begin with—the performance-critical parts are the scene building.
|
Hmm, I am not sure what is going on with Travis--looks like cargo is failing with |
toolness commentedJul 14, 2019
This exposes the Canvas' transform and save/restore functionality to the C API.
The only method I haven't added here is
Canvas::current_transform(), which I can add for completeness if you want.