Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Convert Agg extension to pybind11 #27011

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

Merged
merged 6 commits into from
Sep 19, 2024
Merged

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Oct 6, 2023

PR summary

This is somewhat partially implemented, in that the NumPy array parts are not changed yet. I think I'll want to do path first, to make this simpler. I'll leave this as draft until then.

PR checklist

@QuLogic
Copy link
Member Author

QuLogic commented Jan 13, 2024

I rebased this on top of #27087 so that I can re-use the type casters that it has. However, there is still an issue with the GCAgg type caster, but I'll leave that for when the other PR is in.

@ianthomas23
Copy link
Member

@QuLogic When you have time and motivation to come back to this, ping me and I will review it.

auto should_simplify = src.attr("should_simplify").cast<bool>();
auto simplify_threshold = src.attr("simplify_threshold").cast<double>();

if (!value.set(vertices.ptr(), codes.ptr(),
if (!value.set(vertices.inc_ref().ptr(), codes.inc_ref().ptr(),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why this change is needed now, but otherwise things randomly crash.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We think there are decrements in the iterator destructor there is a decr which we think we need to keep as there are still other usages of the iterators from c++ that we need to remove first.

should_simplify, simplify_threshold)) {
return false;
throw py::error_already_set();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was technically wrong before, but otherwise, pybind11 would substitute its own generic "cannot convert type PyType to C++Type" error message, so not fatal.

Comment on lines +286 to +289
/* value.clippath = src.attr("get_clip_path")().cast<ClipPath>(); */
convert_clippath(src.attr("get_clip_path")().ptr(), &value.clippath);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I leave the casting version in, then all sorts of memory corruption occurs, and I've yet to figure out why. Instead of wasting even more time on that now, I'd rather get this going, and once we drop NumPy headers, come back to clean this up properly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@QuLogic QuLogic force-pushed the agg-pybind11 branch 4 times, most recently from 11ac056 to 83a882b Compare September 13, 2024 09:48
@QuLogic
Copy link
Member Author

QuLogic commented Sep 13, 2024

I rebased and added the usual namespace py = pybind11;; this was left out earlier due to conflicts and has been fixed by other cleanup PRs (though I don't remember which now). I also converted the Agg-only array_view usage to pybind11; the ones shared with _path will be left for a later PR (or it could be done here too, but this is large enough, I think?)

This is a _very_ straightforward port, and several parts can be cleaned
up in future commits.
This only does the simple ones that are not shared with the path
extension. Those more complex ones will be done separately.
@ksunden ksunden merged commit d4ea011 into matplotlib:main Sep 19, 2024
44 checks passed
@QuLogic QuLogic deleted the agg-pybind11 branch September 19, 2024 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants