-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Rewrite the tk C blitting code #10680
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
Conversation
src/_tkagg.cpp
Outdated
int height, width; | ||
unsigned char *data_ptr; | ||
int x1, x2, y1, y2; | ||
if (!PyArg_ParseTuple(args, "O(iin)(iiii)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a function name here?
src/_tkagg.cpp
Outdated
} | ||
PyObject *py_photo_name; | ||
char const *photo_name; | ||
Tk_PhotoHandle photo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and these too?
(edit: oops, should go below the next)
src/_tkagg.cpp
Outdated
&x1, &x2, &y1, &y2)) { | ||
goto exit; | ||
} | ||
PyObject *py_tk, *py_interpaddr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should all have defaults?
all comments handled |
src/_tkagg.cpp
Outdated
block.height = y2 - y1; | ||
block.pitch = 4 * width; | ||
block.pixelSize = 4; | ||
block.offset[0] = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use this to avoid the buf.take
copy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@mattip Can you verify that this still works with pypy? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modulo confirmation that this still works on pypy
Moved some more work to Python's side, avoiding any need for refcounting at all in the C extension. |
works fine on PyPy just like before the PR (with the nightly builds, not the latest release) Thanks for pinging me |
src/_tkagg.cpp
Outdated
@@ -203,9 +203,49 @@ static PyObject *_tkinit(PyObject *self, PyObject *args) | |||
return Py_None; | |||
} | |||
|
|||
static PyObject *mpl_tk_blit(PyObject *self, PyObject *args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opening function braces go on a new line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, fixed
@mattip 2.2.2 does not work on pypy? |
... to use the standard Python C-API rather than the tk API. We do not need to support colormodes other than 2 (i.e. RGBA) (previously there was 0 = grayscale, 1 = RGB) so it was simpler to just deprecate the previous function and move everything to a new private one (matplotlib.backends._backend_tk.blit).
... to use the standard Python C-API rather than the tk API.
We do not need to support colormodes other than 2 (i.e. RGBA)
(previously there was 0 = grayscale, 1 = RGB) so it was simpler to just
deprecate the previous function and move everything to a new private one
(matplotlib.backends._backend_tk.blit).
Followup to #10486 (comment).
PR Summary
PR Checklist