8000 PyQT5 Backend Partial Redraw Fix by pshriwise · Pull Request #14456 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

PyQT5 Backend Partial Redraw Fix #14456

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

Merged
merged 4 commits into from
Aug 29, 2019
Merged

Conversation

pshriwise
Copy link
Contributor

PR Summary

This PR is related to partial redraw buffers for QT5 on screens with devicePixelRatio() > 1 from issue #14160.

At first, this appeared to be a problem with the PyQT5/PySide2 QRectangles being passed to FigureCanvasQT's, but a deeper look showed that there was some confusion about when the FigureCanvasQT._dpi_ratio should be applied. This PR ensures that it is only applied when creating a partial buffer for redraw and that the original rectangle locations from PyQT5/Pyside2 are used to place redrawn region. It still addresses the off-by-one issue by using the bottom coordinate of the rectangle and shifting it by the rectangle's height.

@pshriwise pshriwise changed the title PyQT5 Backend Partial Redraw Fix for devicePixelRatio() > 1 PyQT5 Backend Partial Redraw Fix Jun 5, 2019
@tacaswell tacaswell added this to the v2.2.5 milestone Jun 5, 2019
rect = event.rect()
width = rect.width() * self._dpi_ratio
height = rect.height() * self._dpi_ratio
left, top = self.mouseEventCoords(rect.topLeft())
Copy link
Member

Choose a reason for hiding this comment

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

Can you leave a comment in the code about why we are calling this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah for sure. Good call.

@tacaswell
Copy link
Member

Thanks for digging into this!

The "simple" scaling for hi-dpi has historically been the source of a surprising a amount of grief.

@jklymak
Copy link
Member
jklymak commented Jun 5, 2019

Do we need this change on 3.1.x?

This prob needs someone to check that it works on different operating systems?

@tacaswell
Copy link
Member

This should get interactive testing across several OSs and I think should be backported to both 3.1.x and 2.2.x

@jklymak jklymak modified the milestones: v2.2.5, v3.1.1 Jun 5, 2019
@pshriwise
Copy link
Contributor Author

@tacaswell happy to do it!

@jklymak FWIW I've tested this change on Ubuntu 18.04 and OSX Mojave 10.14.3, though I'm sure more extensive testing is in order.

@pshriwise
Copy link
Contributor Author

Is there anything else I can do here. More testing or tweaks to style?

@pshriwise
Copy link
Contributor Author

Just checking in on this. Anything I can do?

@tacaswell tacaswell requested review from dstansby and anntzer August 27, 2019 02:14
@tacaswell
Copy link
Member

@pshriwise Pinging to get this back on our radar is exactly the right thing to do!

left, top = self.mouseEventCoords(rect.topLeft())
# shift the "top" by the height of the image to get the
# correct corner for our coordinate system
top -= height
Copy link
Contributor
@anntzer anntzer Aug 27, 2019

Choose a reason for hiding this comment

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

I guess the point is that this is really bottomRight(), but with the off-by-1 correction? perhaps move the comment about the off-by-1 there, if I got this correctly... and add a new variable called bottom, otherwise it's quite confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! I'll add a right variable too to make the Bbox construction more clear.

@anntzer
Copy link
Contributor
anntzer commented Aug 27, 2019

just a small clarification needed but otherwise looks good, approving conditional on it (... assuming my understanding is correct :))

Copy link
Contributor
@anntzer anntzer left a comment

Choose a reason for hiding this comment

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

modulo CI

@pshriwise
Copy link
Contributor Author

It looks like CI is failing in the setup step. Is it worth a restart? Or maybe should I rebase this branch?

@anntzer
Copy link
Contributor
anntzer commented Aug 29, 2019

Doc build failure is clearly spurious (this doesn't touch any docstrings).
Thanks for the PR!

@anntzer anntzer merged commit 9856ec2 into matplotlib:master Aug 29, 2019
@lumberbot-app
Copy link
lumberbot-app bot commented Aug 29, 2019

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
$ git checkout v2.2.x
$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 9856ec2966260197563f29ac91c439d917f59814
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am 'Backport PR #14456: PyQT5 Backend Partial Redraw Fix'
  1. Push to a named branch :
git push YOURFORK v2.2.x:auto-backport-of-pr-14456-on-v2.2.x
  1. Create a PR against branch v2.2.x, I would have named this PR:

"Backport PR #14456 on branch v2.2.x"

And apply the correct labels and milestones.

Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon!

If these instruction are inaccurate, feel free to suggest an improvement.

meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Aug 29, 2019
timhoffm added a commit that referenced this pull request Aug 29, 2019
…456-on-v3.1.x

Backport PR #14456 on branch v3.1.x (PyQT5 Backend Partial Redraw Fix)
@tacaswell
Copy link
Member

This code path has diverged significantly from 2.2.x, going to defer backporting this unless there is a champion for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0