From d02b8be8f3b191f8fb67a00b956f1b48a2a1b015 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Wed, 20 May 2020 15:07:03 +0200 Subject: [PATCH] Inline FigureCanvasGtkFoo._render_figure. Having it as a separate function obscures the flow for little benefit, and caused an unnecessary call to get_allocation() in gtk3agg. --- lib/matplotlib/backends/backend_gtk3agg.py | 6 +----- lib/matplotlib/backends/backend_gtk3cairo.py | 8 +++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/matplotlib/backends/backend_gtk3agg.py b/lib/matplotlib/backends/backend_gtk3agg.py index 239911238a53..5e26ff385282 100644 --- a/lib/matplotlib/backends/backend_gtk3agg.py +++ b/lib/matplotlib/backends/backend_gtk3agg.py @@ -17,9 +17,6 @@ def __init__(self, figure): backend_gtk3.FigureCanvasGTK3.__init__(self, figure) self._bbox_queue = [] - def _render_figure(self, width, height): - backend_agg.FigureCanvasAgg.draw(self) - def on_draw_event(self, widget, ctx): """GtkDrawable draw event, like expose_event in GTK 2.X.""" allocation = self.get_allocation() @@ -71,8 +68,7 @@ def blit(self, bbox=None): def draw(self): if self.get_visible() and self.get_mapped(): - allocation = self.get_allocation() - self._render_figure(allocation.width, allocation.height) + backend_agg.FigureCanvasAgg.draw(self) super().draw() def print_png(self, filename, *args, **kwargs): diff --git a/lib/matplotlib/backends/backend_gtk3cairo.py b/lib/matplotlib/backends/backend_gtk3cairo.py index 433cbb555041..13b4587b2f7c 100644 --- a/lib/matplotlib/backends/backend_gtk3cairo.py +++ b/lib/matplotlib/backends/backend_gtk3cairo.py @@ -20,10 +20,6 @@ def __init__(self, figure): super().__init__(figure) self._renderer = RendererGTK3Cairo(self.figure.dpi) - def _render_figure(self, width, height): - self._renderer.set_width_height(width, height) - self.figure.draw(self._renderer) - def on_draw_event(self, widget, ctx): """GtkDrawable draw event.""" with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar @@ -34,7 +30,9 @@ def on_draw_event(self, widget, ctx): self.get_style_context(), ctx, allocation.x, allocation.y, allocation.width, allocation.height) - self._render_figure(allocation.width, allocation.height) + self._renderer.set_width_height( + allocation.width, allocation.height) + self.figure.draw(self._renderer) @_BackendGTK3.export