Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed blitting in Gtk3Agg backend #1578

Merged
merged 1 commit into from

3 participants

spinnau Phil Elson Michael Droettboom
spinnau

Fixed blitting in Gtk3Agg backend as described in issue #1575.

Phil Elson
Collaborator

Looks good to me. To all involved: is it possible to test this programatically?

Michael Droettboom
Owner

+1. I'm not sure how to test this, unfortunately, given that involves opening windows etc. I'd be happy to see this merged in any case.

Phil Elson pelson merged commit 7283784 into from
spinnau

@pelson For testing you have to compare screenshots of opened windows. Thus, on linux machines a running XServer is needed. I don't know if it's the case on the build servers.

I have created a proposal for a test (https://gist.github.com/4254321). It compares two screenshots for normal plot and for blitting. Screenshots are taken with imagemagick. This works independent of the backend, so with a change of the GObject.idle_add line the test can be used for all blitting enabled backends. The imagemagick import command line tool doesn't work under Windows operating systems. Here PIL.ImageGrab could be used instead.

The images shows the screenshots for normal plot (left) and with blitting (right). Without the patch it can be seen, that the figure background and axes labels are missed.

test_without_patch

The screenshots with the patch applied are not exact identical, there are some differences in the plot line thickness.

test_with_patch

Michael Droettboom
Owner

It still likes it might be difficult to throw that test in our automated tests (which have to run without X etc), but maybe we should throw this in unit with some of our other off-line tests?

spinnau

@mdboom If the automated tests have to run without XServer then using it as an off-line test seems to be the only possible solution. I have slightly enhanced the code for the test, so it now uses matplotlib.testing.compare with a small tolerance value instead of PIL for comparing the images (https://gist.github.com/4254321).

spinnau spinnau deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 1 deletion.
  1. +13 −1 lib/matplotlib/backends/backend_gtk3agg.py
14 lib/matplotlib/backends/backend_gtk3agg.py
View
@@ -59,8 +59,20 @@ def on_draw_event(self, widget, ctx):
return False
def blit(self, bbox=None):
+ # If bbox is None, blit the entire canvas to gtk. Otherwise
+ # blit only the area defined by the bbox.
+ if bbox is None:
+ bbox = self.figure.bbox
+
+ allocation = self.get_allocation()
+ w, h = allocation.width, allocation.height
+ x = int(bbox.x0)
+ y = h - int(bbox.y1)
+ width = int(bbox.x1) - int(bbox.x0)
+ height = int(bbox.y1) - int(bbox.y0)
+
self._bbox_queue.append(bbox)
- self.queue_draw()
+ self.queue_draw_area(x, y, width, height)
def print_png(self, filename, *args, **kwargs):
# Do this so we can save the resolution of figure in the PNG file
Something went wrong with that request. Please try again.