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

Skip to content

Commit f73c9d1

Browse files
committed
GTK3Agg backend: Only convert the cairo context to a cairocffi context once.
1 parent cb2a52a commit f73c9d1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/matplotlib/backends/backend_gtk3agg.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ def on_draw_event(self, widget, ctx):
4646
else:
4747
bbox_queue = self._bbox_queue
4848

49+
if HAS_CAIRO_CFFI:
50+
ctx = cairo.Context._from_pointer(
51+
cairo.ffi.cast('cairo_t **',
52+
id(ctx) + object.__basicsize__)[0],
53+
incref=True)
54+
4955
for bbox in bbox_queue:
5056
area = self.copy_from_bbox(bbox)
5157
buf = np.fromstring(area.to_string_argb(), dtype='uint8')
@@ -56,10 +62,6 @@ def on_draw_event(self, widget, ctx):
5662
height = int(bbox.y1) - int(bbox.y0)
5763

5864
if HAS_CAIRO_CFFI:
59-
ctx = cairo.Context._from_pointer(
60-
cairo.ffi.cast('cairo_t **',
61-
id(ctx) + object.__basicsize__)[0],
62-
incref=True)
6365
image = cairo.ImageSurface.create_for_data(
6466
buf.data, cairo.FORMAT_ARGB32, width, height)
6567
else:

0 commit comments

Comments
 (0)