Skip to content
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

Cleanup QPicture dpi scaling workarounds #58122

Merged
merged 4 commits into from
Jul 17, 2024

Conversation

nyalldawson
Copy link
Collaborator

Unifies the various QPicture DPI scaling workaround implementations, and adds high level methods to make this simpler to handle

@nyalldawson nyalldawson added API API improvement only, no visible user interface changes Cleanup Code cleanup labels Jul 16, 2024
@github-actions github-actions bot added this to the 3.40.0 milestone Jul 16, 2024
Copy link

github-actions bot commented Jul 16, 2024

🪟 Windows builds ready!

Windows builds of this PR are available for testing here. Debug symbols for this build are available here.

(Built from commit f7237e2)

Copy link
Contributor

@troopa81 troopa81 left a comment

Choose a reason for hiding this comment

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

Good move 👍

// Then when being drawn, it scales the painter. The following call
// negates the effect. There is no way of setting QPicture's DPI.
// See QTBUG-20361
const double xScale = static_cast< double >( QgsPainting::qtDefaultDpiX() ) / painter->device()->logicalDpiX();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not calling applyScaleFixForQPictureDpi and using save/restore instead ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's considerable overhead in save/restore calls, and it's trivial to avoid them here.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK.

Just out of curiosity, do you have any discussion/information about this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just my own experiences profiling QGIS rendering. And it makes sense -- saving / restoring QPainter state requires storing a lot of properties, especially when clip masks are in place. In comparison scaling is an almost zero-cost operation.

src/core/effects/qgspainteffect.cpp Show resolved Hide resolved
@troopa81 troopa81 merged commit 25c28d6 into qgis:master Jul 17, 2024
29 checks passed
@nyalldawson nyalldawson deleted the painter_dpi_methods branch July 17, 2024 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API API improvement only, no visible user interface changes Cleanup Code cleanup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants