Add support for blitting in qt5cairo. by anntzer · Pull Request #17478 · matplotlib/matplotlib · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions lib/matplotlib/backends/backend_cairo.py
9 changes: 9 additions & 0 deletions lib/matplotlib/backends/backend_qt5.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,15 @@ def draw_idle(self):
self._draw_pending = True
QtCore.QTimer.singleShot(0, self._draw_idle)

def blit(self, bbox=None):
# docstring inherited
if bbox is None and self.figure:
bbox = self.figure.bbox # Blit the entire canvas if bbox is None.
# repaint uses logical pixels, not physical pixels like the renderer.
l, b, w, h = [pt / self._dpi_ratio for pt in bbox.bounds]
t = b + h
self.repaint(l, self.rect().height() - t, w, h)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

OK, I can't find it - does qt5agg have a rect method? an is self.rect().height() equal to self.renderer.height / self._dpi_ratio?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, that comes to us from qt directly: https://doc.qt.io/qt-5/qwidget.html#rect-prop.


def _draw_idle(self):
with self._idle_draw_cntx():
if not self._draw_pending:
Expand Down
12 changes: 0 additions & 12 deletions lib/matplotlib/backends/backend_qt5agg.py