-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Simplify webagg blitting. #23182
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
Simplify webagg blitting. #23182
Conversation
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.
nice! much simpler
|
||
if self._force_full or np.any(pixels[:, :, 3] != 255): | ||
if (self._force_full | ||
or buff.shape != self._last_buff.shape |
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.
may be nice to add a comment as well about this line. It took me a while to hunt down why it was ok to compare the initial np.empty((0,0))
with the buffer and this line is the escape
|
||
if self._force_full or np.any(pixels[:, :, 3] != 255): | ||
if (self._force_full | ||
or buff.shape != self._last_buff.shape |
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.
or buff.shape != self._last_buff.shape | |
# If the buffer has changed size we need to do a full draw | |
or buff.shape != self._last_buff.shape |
- Directly reuse FigureCanvasAgg.get_renderer. We don't need to init _last_buff there as we can just use buff.copy() in get_diff_image() (If we really care about reusing the same array whenever possible, we could add a shape check before the removed copyto() and reuse the old array if the shapes match, but I doubt it matters.) Instead, init it once to a non-valid shape in the constructor. Note that the comments in the function were outdated since 78c182d. - First creating `pixels` and then viewing it as `buff` is slighly simpler than doing it the other way round.
Added comment as requested. |
Directly reuse FigureCanvasAgg.get_renderer. We don't need to init
_last_buff there as we can just use buff.copy() in get_diff_image()
(If we really care about reusing the same array whenever possible, we
could add a shape check before the removed copyto() and reuse the old
array if the shapes match, but I doubt it matters.) Instead, init it
once to a non-valid shape in the constructor.
Note that the comments in the function were outdated since 78c182d.
First creating
pixels
and then viewing it asbuff
is slighlysimpler than doing it the other way round.
The animation example in #19059 works for me.
PR Summary
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).