Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Canvas transform and save/restore to C #216

Merged
merged 2 commits into from Jul 22, 2019

Conversation

@toolness
Copy link
Contributor

toolness commented Jul 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.

@@ -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.

@toolness

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.

@pcwalton

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.

@toolness
Copy link
Contributor Author

toolness commented Jul 14, 2019

Hmm, I am not sure what is going on with Travis--looks like cargo is failing with error trying to exec 'cc1obj': execvp: No such file or directory and that doesn't seem to be related to the content of my PR.

@pcwalton pcwalton merged commit 3c18f99 into servo:master Jul 22, 2019
0 of 2 checks passed
0 of 2 checks passed
Travis CI - Pull Request Build Failed
Details
continuous-integration/travis-ci/pr The Travis CI build failed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.